Fork me on GitHub

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


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


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


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


And that Cursive should highlight both as discarded


Huh, thats probably a bug in clojure.edn then

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


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


@U0567Q30W are you aware of a related open issue?


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


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


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)


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


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


hmm now I'm unsure about that edn part


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


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


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


Gonna try in REPL


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)?!

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.


Not at the moment as far as I know

😢 1
😿 1

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