Fork me on GitHub
#untangled
<
2017-03-25
>
danielstockton14:03:39

@tony.kay I think you said something about ui-reactkey but I couldn't read it at the time; now I can't find it. Did you delete it or has slack lost it for me? EDIT: Nvm, I found it in #om

tony.kay19:03:33

@nha are you familiar with the new implicit macro stuff for cljs? It seems you changed one (or more) of my refers to a conditional in cljc

nha19:03:57

@tony.kay not familiar with macros in cljs at all

nha19:03:21

Actually I was struggling quite a bit right now 😛

nha19:03:15

Thanks for your commit by the way 🙂 it helps having the tooling to work on this

tony.kay19:03:33

yes, it does…also the fact that there are macros involved in cljc can be a challenge

nha19:03:22

Yes well I never wrote a useful macro even in clj, so I am learning both at the same time. What is this implicit macro stuff?

tony.kay19:03:49

it’s just a way you can avoid needing to do the :refer-macros stuff

tony.kay19:03:54

unifies the syntax a bit

tony.kay19:03:38

The “Implicit Sugar” section

nha19:03:49

I thought :`refer-macros` was the new bit ^^ Thanks will read 🙂

tony.kay19:03:05

but since you’re in cljc, you have to add the self-refer in a cljs conditional block.

nha19:03:19

Oh right I kinda remember reading that now 🙂

tony.kay19:03:32

no, refer-macros is because the macros happen in clj before the compile

tony.kay19:03:46

so, it is telling the cljs compiler to go load them into the clj env

tony.kay19:03:54

text file -> EDN read -> data structures -> macro expansion -> expanded data structures -> compile

nha19:03:14

Ah makes sense 🙂

tony.kay19:03:42

when you have a cljc file, you’ve got two things you’re generating that have the same kinda path: clj and cljs

tony.kay19:03:24

The EDN read step just sets up to emit whichever side of a conditional is relevant (clj or cljs)

tony.kay19:03:52

text file -> cljs EDN read -> cljs data structures -> macros -> expanded -> compile

tony.kay19:03:19

so the macro needs to emit something that will work on either side

nha19:03:38

So if there was a #?(:cljs (:require-macros untangled-spec.core)) in https://github.com/untangled-web/untangled-spec/blob/develop/src/untangled_spec/core.clj#L1 and it was a cljc file it would have worked? That's nice

tony.kay19:03:40

easier to write that so the macro uses helper functions that you can make behave properly

tony.kay19:03:09

right…if you have that, you can just :refer

tony.kay19:03:15

and it is transparent

tony.kay19:03:36

unfortunately not all libs have ported to that, so sometimes you’re still stuck with :refer-macros

nha19:03:16

Ok that refines my mental model of cljs macros 🙂

tony.kay19:03:28

and in cljc it gets super-confusing, because the refer will work no matter what there for the CLJ side of the compile

tony.kay19:03:40

but will complain when doing the cljs that it can’t find it

nha19:03:22

yes I kinda understood that part. compile vs run time (I think)

tony.kay19:03:12

and on your ref to spec.

tony.kay19:03:38

DOES have the require-macros

tony.kay19:03:48

you can have CLJ and CLJS file separately…works fine

tony.kay19:03:54

does not have to be a cljc file per-se

tony.kay19:03:03

so you can use :refer with it

tony.kay19:03:43

the implicit stuff is enabled when the CLJS file requires the macros from the like-named clj namespace

nha19:03:45

Oh ok makes sense after all. cljc emits clj + cljs files so you can do it yourself 🙂

tony.kay19:03:56

Yeah, worth learning these little ins-and-outs of macros. They make the whole thing less of a hair-pulling experience

tony.kay19:03:08

If you just try to “do it” in an experimental fashion, it is maddening