untangled

NEW CHANNEL: #fulcro
2017-03-25T14:23:39.923802Z

@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.kay 2017-03-25T19:37:33.733562Z

@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

2017-03-25T19:37:57.735109Z

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

2017-03-25T19:38:21.736607Z

Actually I was struggling quite a bit right now 😛

2017-03-25T19:39:15.739653Z

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

tony.kay 2017-03-25T19:39:33.740709Z

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

2017-03-25T19:40:22.743711Z

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.kay 2017-03-25T19:40:49.745271Z

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

tony.kay 2017-03-25T19:40:54.745588Z

unifies the syntax a bit

tony.kay 2017-03-25T19:41:38.748116Z

The “Implicit Sugar” section

2017-03-25T19:41:49.748672Z

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

tony.kay 2017-03-25T19:42:05.749666Z

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

2017-03-25T19:42:19.750416Z

Oh right I kinda remember reading that now 🙂

tony.kay 2017-03-25T19:42:32.751242Z

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

tony.kay 2017-03-25T19:42:46.751997Z

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

tony.kay 2017-03-25T19:43:54.755771Z

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

2017-03-25T19:44:14.756837Z

Ah makes sense 🙂

tony.kay 2017-03-25T19:44:42.758392Z

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

tony.kay 2017-03-25T19:45:24.760754Z

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

tony.kay 2017-03-25T19:45:52.762420Z

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

tony.kay 2017-03-25T19:46:19.763881Z

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

2017-03-25T19:46:38.765024Z

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.kay 2017-03-25T19:46:40.765117Z

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

tony.kay 2017-03-25T19:47:09.766725Z

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

tony.kay 2017-03-25T19:47:15.767042Z

and it is transparent

1
tony.kay 2017-03-25T19:47:36.768331Z

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

2017-03-25T19:48:16.770604Z

Ok that refines my mental model of cljs macros 🙂

tony.kay 2017-03-25T19:48:28.771307Z

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

tony.kay 2017-03-25T19:48:40.772022Z

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

2017-03-25T19:49:22.774275Z

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

tony.kay 2017-03-25T19:50:12.776861Z

and on your ref to spec.

tony.kay 2017-03-25T19:50:38.778508Z

DOES have the require-macros

tony.kay 2017-03-25T19:50:48.779099Z

you can have CLJ and CLJS file separately…works fine

tony.kay 2017-03-25T19:50:54.779385Z

does not have to be a cljc file per-se

tony.kay 2017-03-25T19:51:03.779957Z

so you can use :refer with it

tony.kay 2017-03-25T19:51:43.782338Z

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

2017-03-25T19:51:45.782476Z

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

tony.kay 2017-03-25T19:52:06.783660Z

right

tony.kay 2017-03-25T19:52:56.786707Z

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

tony.kay 2017-03-25T19:53:08.787395Z

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

🙃 1