This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-15
Channels
- # announcements (8)
- # architecture (9)
- # autochrome-github (1)
- # babashka (48)
- # beginners (55)
- # calva (36)
- # cider (16)
- # clj-commons (1)
- # clj-kondo (38)
- # cljs-dev (44)
- # cljsrn (1)
- # clojure (164)
- # clojure-europe (35)
- # clojure-nl (2)
- # clojure-norway (10)
- # clojure-uk (23)
- # clojurescript (50)
- # conjure (24)
- # core-async (1)
- # cryogen (2)
- # cursive (38)
- # datalevin (11)
- # datascript (2)
- # datomic (13)
- # duct (1)
- # emacs (16)
- # events (12)
- # exercism (3)
- # figwheel-main (7)
- # fulcro (26)
- # honeysql (5)
- # integrant (1)
- # jobs (3)
- # kaocha (6)
- # lsp (72)
- # malli (22)
- # nextjournal (35)
- # nrepl (1)
- # off-topic (34)
- # pathom (5)
- # polylith (8)
- # portal (40)
- # re-frame (14)
- # reagent (42)
- # reitit (1)
- # releases (1)
- # remote-jobs (1)
- # reveal (9)
- # sci (2)
- # shadow-cljs (13)
- # sql (3)
- # tools-deps (33)
- # vim (25)
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 pairThe discard is discarding the thing after the type hint here
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
Huh, thats probably a bug in clojure.edn then
(require '[clojure.edn :as edn])
=> nil
(edn/read-string "#_ ^a [3]")
=> nil
The Clojure edn reader supports some extensions beyond the spec
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?
Does that mean that #_ ^:foo bar baz
would return baz
without meta, or that the meta would apply to bar
and would get dropped?
those sound like the same thing :)
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 🙂
I hear ya :)
the key is, it's a stack
#_ 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
(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
(clojure.edn/read-string "[^asdf foo]")
=> [foo]
(clojure.edn/read-string "[#_^asdf foo]")
=> []
oh yeah, that's the https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/EdnReader.java#L53 Alex mentioned
Alex Miller said above: “the meta would be attached to bar, and bar would be discarded, and you would get baz with no meta”
Hm, "Edit REPL Commands" allows me to change/delete but not to add a command (nor it points to where I could add one)?!
Ah, thanks! I should have thought of checking that first.
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.