Fork me on GitHub
#cljs-dev
<
2018-12-05
>
mfikes00:12:38

Yes, I’m the ersatz GitHub CI :robot_face: Will kick it off when back to computer.

👍 4
4
dnolen01:12:00

I think 1.9.660 is probably long enough go to not be too concerned about it

dnolen01:12:10

I'm ok with the patch and we'll see what the feedback is

juhoteperi05:12:49

Reagent fixed the variadic IFn method in 0.7.0 (2017-06-27), should be fine to drop support now

john15:12:51

It appears CLJS's defn quotes the map passed in as metadata, whereas CLJ doesn't. CLJS:

cljs.user=> (defn x {:x/y (atom 1)} [z] (inc z))
#'cljs.user/x
cljs.user=> (-> x quote resolve meta :x/y)
(atom 1)
CLJ:
user=> (defn x {:x/y (atom 1)} [z] (inc z))
#'user/x
user=> (-> x quote resolve meta :x/y)
#object[clojure.lang.Atom 0x27494e46 {:status :ready, :val 1}]
Intended?

john15:12:32

Or maybe necessary?

Alex Miller (Clojure team)15:12:44

it’s certainly intentional in clj

john15:12:33

strange... I'd think the atom would get eval'd by the time we get here https://github.com/clojure/clojurescript/blob/r1.10.439/src/main/clojure/cljs/core.cljc#L3206 and I don't see any quoting of the meta prior

darwin15:12:40

defn is a macro, so fdecl should be un-evaluated form (AFAICT)

john15:12:52

ah, :macro true?

john15:12:19

I think that's just quoting the arg lists

john15:12:28

within the meta

john15:12:19

I'm not familiar with this def :macro true thing. Can we unquote in this body like regular macros?

darwin15:12:36

I’m noob, but I would work around it by writing my own macro, which would set metadata on the var after defn macro executes. There must be a way how to mutate metadata on a var.

john15:12:32

I think setting meta on a fn post-hoc drops it into a meta-fn... maybe

darwin15:12:33

ah, probably emit alter-meta! after defn emitted-code

john15:12:13

I'll try that

john15:12:21

aahk, Metadata of vars cannot be altered since they are statically determined at compile-time.

john15:12:05

oh, you mean in the cljs source for defn?

john15:12:34

As long as all the machinery is looking at the same var afterwards

darwin15:12:28

I don’t know, sorry

john15:12:24

I guess it wouldn't need to be unquoted but actually eval'd :thinking_face:

thheller17:12:25

@john CLJS does not have vars at runtime so you can't alter it or use it in the way you'd do with CLJ

thheller17:12:52

since vars don't exist it would create a "new" instance of whatever metadata you created. it would never be the same instance of an atom for example

thheller17:12:26

(var 'the.thing/foo) recreates the metadata from the analyzer data (at compile time. not runtime)

john17:12:27

@thheller Thanks. Yeah, I figured. But technically I'm not altering it... But I guess any data you're passing in via the metadata option must be readable by both CLJ and CLJS? I'm assuming the construction is on the CLJ side? So the atom would be a CLJ atom at this phase?

thheller17:12:09

since the metadata is not evaluated its never an atom. always just a list

john17:12:33

Can the analyzer data not contain an atom?

john17:12:40

a cljs atom?

thheller17:12:41

no. its just clojure data.

thheller17:12:00

well you can do some rather ugly hacks with macros but please don't. its not gonna be reliable and break all caching.

john17:12:37

Well, I guess if you could, that sure would side-step the lack of alter on vars at runtime. Cool. I'll just use another atom outside

dnolen17:12:46

@john all of this intentional

dnolen17:12:06

what Clojure does is not practical (for ClojureScript)

dnolen17:12:26

no vars, means no runtime metadata, means no references to runtime stuff in the metadata

dnolen17:12:52

everything must be static and data only, thus we quote

dnolen17:12:55

you cannot refer to any runtime constructs so trying to use atom isn't going to work

john18:12:30

@dnolen thanks. Understood.