Fork me on GitHub
#cursive
<
2017-01-06
>
ambrosebs19:01:58

(identity '^:foo a) ;; incorrect arity 2 for clojure.core/identity

ambrosebs19:01:04

do other people get this warning?

kenny19:01:41

@ambrosebs Remove the quote. (identity ^:foo a)

potetm19:01:50

He wants the metadata attached to the symbol.

potetm19:01:55

e.g.

(let [a 1]
  (meta (identity ^:foo 'a)))
=> nil
(let [a 1]
  (meta (identity '^:foo a)))
=> {:foo true}

kenny19:01:22

TIL. That is not documented in the reader docs.

potetm19:01:53

Yeah it happens for me too @ambrosebs. Pretty sure its a bug?

potetm19:01:13

Yeah I have no idea if it's a feature or a happy accident. My thought was the same as yours at first kenny, but I figured ambrosebs knows the clojure pretty gud, so I checked 🙂

kenny19:01:41

Yeah, I haven't seen that before. I'm curious if it is officially supported or if the behavior will be removed in a future version of Clojure.

Alex Miller (Clojure team)21:01:34

I think that all flows from the reader rules, even though it’s not obvious

Alex Miller (Clojure team)21:01:30

^:foo is applied to the next thing read

Alex Miller (Clojure team)21:01:50

’x is expanded to (quote x)

Alex Miller (Clojure team)21:01:17

so (identity ^:foo ‘a) expands to (identity ^:foo (quote a)) - note that the meta is applied to the list, so after evaluation you’re left with just the symbol a with no meta

Alex Miller (Clojure team)21:01:04

and (identity '^:foo a) expands to (identity (quote ^:foo a)) which returns a symbol with meta for the same reasons

potetm21:01:21

Right that makes sense. I thought that might be the case.

ambrosebs23:01:44

Is there only one dev on Cursive atm?