Fork me on GitHub
#clojurescript
<
2016-07-17
>
ajchemist09:07:03

has anyone experienced node is not a child exception only when :advanced optimizations?

dnolen11:07:10

@ajchemist: that error is deep in Closure Compiler so unlikely

dnolen11:07:54

might want to figure out what the reproducer is - I suspect probably nothing to do with ClojureScript though and it will probably need to be reported to the Closure Compiler mailing list

ajchemist11:07:20

@dnolen: thanks for quick weekend reply 😀

ajchemist11:07:04

currently I stick to :simple optimizations that works for now

mfikes12:07:26

@ajchemist: That has evidently been reported previously in some unclarified context (see https://github.com/google/closure-compiler/issues/1339#issuecomment-167011814)

ajchemist12:07:54

I'm not sure but It seems that the codes in binaryage/chromex trigger node is not a child exception in some place.

ajchemist12:07:31

@mfikes: thanks. I’ve also seen the issue.

martinklepsch12:07:26

I have some data created by a macro that I want to use in CLJS without it being evaluated — How can I quote the return value of a macro?

darwin12:07:03

emit (quote …)?

darwin13:07:35

well, using macroexpand inside defmacro looks like a code smell to me

darwin13:07:32

macros are expanded by compiler going outside-in, so if your macro generates code which contains macros, they will get expanded on the way down

martinklepsch13:07:11

right that makes sense, it was just the only way I could figure out that would give me the result of the macro as data

darwin13:07:02

also wondering why do you use mapv instead of map?

martinklepsch13:07:11

@darwin: no particular reason for that (I guess I added it because when looking at the output it's visually easier to parse forms that are in a vector vs in a list)

darwin13:07:51

this should emit a list of html-simplified calls

darwin13:07:58

(not tested)

martinklepsch13:07:31

@darwin: the issue is I want to evaluate these html-simplified calls and get the returned forms as data

darwin13:07:37

then you need eval (in general case)

darwin13:07:08

or you can implement html-simplified* as a normal function and call it from within compile-mult

darwin13:07:41

this won’t prevent you from wraping html-simplified* in html-simplified macro if you still want to expose it as macro to cljs

martinklepsch13:07:18

@darwin: I just experimented with eval a bit but maybe this is better. I'll chew on it a bit, thanks so much for your guidance!

martinklepsch17:07:51

When I have a (def thing [:some :data]) that I want to pass to a macro, can I do that from a cljs file? Just referencing thing passes the symbol which isn't what I want

darwin17:07:54

a macro rewrites code into other code during compile-time, if you write code which calls the macro with a symbol thing, it sees just the symbol and cannot look what it maps to

darwin17:07:59

also defs mappings can be manipulated at runtime, this in-principle cannot be solved by macros

martinklepsch17:07:39

Ok I kind of expected that to be the answer 😅

darwin17:07:15

any chance you could be writing macro calls with those things inlined?

darwin17:07:36

eg. (my-macro [:some :data])

martinklepsch17:07:40

With that in mind, how can I read and edn file and pass it's value to a macro as if I'd write that data out, passing it to the macro directly?

martinklepsch17:07:19

@darwin: right that's what I'm doing right now but I need to pass the same data to multiple macros so it becomes a bit annoying

darwin17:07:31

write a macro for that

darwin17:07:07

once you cross this line, you have to stay on compile-time side with macros

darwin17:07:10

there is one trick you could do, cljs compiler exposes analyzer datastructures, you can work with them in macros

martinklepsch17:07:33

I just realized I can just make a bigger macro, lol

darwin17:07:34

so in this particular case, you should be able to walk defs and “resolve” the mapping in your macro

darwin17:07:58

but I would not recommend it

martinklepsch17:07:10

Regarding the edn thing I was thinking of reading that during compile time so that seems like an equally OK approach?

darwin17:07:21

you for readability/maintainability reasons

darwin17:07:24

ad edn reading, I’m sorry I cannot really tell which approach is better without seeing bigger picture, sorry

darwin17:07:18

also when inlining external data into your cljs sources, please pay attention to source-code size implications

darwin17:07:44

especially when writing macros which duplicate the same data all over the place

martinklepsch17:07:41

thanks, in this case I don't care about size as it's just some experiment 🙂

martinklepsch17:07:49

I wen't with the bigger macro all working now

martinklepsch17:07:48

Your earlier snippet also helped me a lot, so thanks for that again 🙂

darwin17:07:36

glad it helped, you are welcome

darwin17:07:48

btw. I had to learn deeper macro stuff when writing chromex, it was a nice exercise which forced me to really learn beyond simple oneliners: https://github.com/binaryage/chromex/blob/master/src/lib/chromex/wrapgen.clj

darwin18:07:46

FYI today I learned really neat trick, for new cljs-devtools I’m writing a renderer from hiccup-like data structure into json-ml, and it has somewhat circular nature, so I have to maintain a map of all available hiccup “tags”, today I discovered a way how generate the map via a macro by walking analyzer’s defs data structure, the trick is this line: https://github.com/binaryage/cljs-devtools/commit/9a64e34330ba597b32de035d4299e17b6102f8cd#diff-69e303bb2f588f5ef48b209d7fa7da6fR7

richiardiandrea19:07:19

@darwin that's totally wizard 😄 nice

richiardiandrea19:07:53

when I was working for LambdaX btw I added an AST layer in replumb for common compiler state inspection, this is the mandatory link (sorry not spamming myself, just genuinly trying to share knowledge): http://lambdax.io/blog/posts/2016-03-22-replumb-ast.html

richiardiandrea19:07:46

it is pretty neat that anytime you can peak at compiler data, it was like prying into the secret life of it (him? her? 😄)