Fork me on GitHub
#cursive
<
2022-02-15
>
imre13:02:08

It appears #_ doesn't work fully correctly with type hints, not sure if this had already been reported? I can create an issue if not. In the attached screenshot, [chan] should also be highlighted as commented out

emccue13:02:29

I think this is correct behavior. As edn it is read literally as

* the symbol ^ActionListener
* a vector containing
  * the symbol chan
The #_ signals to the edn reader to discard the next form, which is the symbol ^ActionListener. All this happens before clojure has a chance / wants to add special interpretation to the symbol/vector pair

emccue13:02:25

aaaand nope, nvm I am exactly wrong

Alex Miller (Clojure team)13:02:56

The discard is discarding the thing after the type hint here

Alex Miller (Clojure team)13:02:26

That is, it does not mean what you think it means

imre13:02:41

Does the discard also discard the type hint or only what comes after it? My expectation is that it discards both

imre13:02:12

And that Cursive should highlight both as discarded

emccue13:02:14

Huh, thats probably a bug in clojure.edn then

(require '[clojure.edn :as edn])
=> nil
(edn/read-string "#_ ^a [3]")
=> nil

emccue13:02:42

since afaik metadata isn't part of the EDN spec, so this is clojure specific behavior

Alex Miller (Clojure team)13:02:10

The Clojure edn reader supports some extensions beyond the spec

Alex Miller (Clojure team)13:02:56

re the question above, it discards the next read value, which in this case is a vector with meta

1
imre13:02:39

@U0567Q30W are you aware of a related open issue?

cfleming19:02:39

No, I’m not - an issue would be great, thanks.

cfleming19:02:25

Does that mean that #_ ^:foo bar baz would return baz without meta, or that the meta would apply to bar and would get dropped?

Alex Miller (Clojure team)19:02:01

those sound like the same thing :)

Alex Miller (Clojure team)19:02:20

the meta would be attached to bar, and bar would be discarded, and you would get baz with no meta

cfleming19:02:25

In my defence, it’s 8am here, and I should be doing other things rather than replying to Slack without thinking properly 🙂

Alex Miller (Clojure team)19:02:10

the key is, it's a stack

Alex Miller (Clojure team)19:02:32

#_ says read the next thing and drop it
  ^:foo says here's some meta, read the next thing and give it that meta
    read bar symbol
  ... meta is applied to bar
... #_ drops bar w/meta
read baz symbol

Alex Miller (Clojure team)19:02:42

(the stack being actual stack frames in the LispReader, not an explicit stack)

cfleming19:02:36

Right, that makes sense, thanks. So I guess ^:foo #_ bar baz would leave baz with meta applied.

imre19:02:40

I think that's correct. Probably also important to repeat that the current behaviour is expected in edn. I'll record an issue

imre19:02:55

hmm now I'm unsure about that edn part

imre19:02:03

(clojure.edn/read-string "[^asdf foo]")
=> [foo]
(clojure.edn/read-string "[#_^asdf foo]")
=> []

staypufd06:02:15

Alex Miller said above: “the meta would be attached to bar, and bar would be discarded, and you would get baz with no meta”

staypufd06:02:06

So I'm confused. Colin's says that baz would have the meta, Alex said it wouldn't.

staypufd06:02:21

Gonna try in REPL

cfleming21:02:14

Alex is definitely correct here.

Jakub Holý (HolyJak)13:02:59

Hm, "Edit REPL Commands" allows me to change/delete but not to add a command (nor it points to where I could add one)?!

2
Jakub Holý (HolyJak)13:02:22

Ah, thanks! I should have thought of checking that first.

Old account14:02:09

Is there a way to get symbol information from REPL rather the setting everything manually as documentation says? I have Macro heavy code with a lot of unresolvable vars.

imre14:02:09

Not at the moment as far as I know

😢 1
😿 1
cfleming23:02:18

No, Cursive doesn’t support this. It will in the future support customisation for macro forms, but doesn’t do that yet.