Fork me on GitHub
#hoplon
<
2017-07-16
>
dm314:07:24

@alandipert so https://github.com/dm3/javelin/tree/macros-split-clj now has a Clojure implementation based on Plumbata. It passes all of the tests. Javelin also passes all of the tests in self-host Clojurescript mode. However I can’t figure out how to make it work under normal JVM Clojurescript! 🙂 The only significant change was splitting macros out into a separate namespace. I think the macros can be returned into javelin.core but I’d like to figure out JVM Clojurescript first…

dm318:07:07

@flyboarder that’s not the problem. The code works as intended under self-host. The problem is when compiling javelin.macros - due to the way the Clojurescript is compiled it chooses the wrong hoisting code-walking implementation when compiling JVM Clojurescript and I can’t figure out how to do it properly.

flyboarder18:07:41

where is it loading the code from for the incorrect walk?

flyboarder18:07:37

you are using cljc files, so this will effect macro expansion will it not?

dm318:07:49

yes, so this macros.cljc file when compiled for JVM Clojure uses javelin.macros.clj ns for the hoist function

flyboarder18:07:49

my understanding was that with cljc files you use reader conditionals inside your macro to change what happens during clj/cljs builds

dm318:07:27

when compiled by self-host cljs it uses javelin.macros.js for that same function - as specified in the (:require) of the ns

dm318:07:52

the problem is that when compiling for the non self-host Clojurescript, the javelin.macros.clj is loaded

dm318:07:00

as per (:require..)

dm318:07:50

at least that’s what I think is happening. I really should have looked into the JVM Clojurescript compiled output

flyboarder18:07:09

right so inside the macro’s within javelin.macros.clj the macro should determine what to do for clj/cljs

dm318:07:23

yeah, the namespaces are already separate

dm318:07:28

one for clj, one for js

dm318:07:37

so the idea is to make that choice in javelin.macros

flyboarder18:07:49

right but there should be some overlap within javelin.macros

dm318:07:22

with self host you have another problem

dm318:07:29

it’s not just :clj and :cljs

dm318:07:32

when writing macros

flyboarder18:07:42

javelin.macros have no reader conditionals right now

flyboarder18:07:47

other than the namespace

flyboarder18:07:09

which doesnt help during runtime as per my understanding

dm318:07:17

also lines 11 and 55

dm318:07:35

note that line 11 is another problem

flyboarder18:07:42

ah ok yes I see

dm318:07:11

I want to use clojure.core/destructure. I can use it in JVM Clojure. However, in JVM Clojurescript I need cljs.core/destructure and in self-hosted I need cljs.core$macros/destructure

dm318:07:22

(because of yet unidentified resolver bug)

flyboarder18:07:18

so wouldnt it be the same for self-hosted and cljs?

flyboarder18:07:29

i thought the compiler sorted that out

dm318:07:48

the last one is self-host bug

dm319:07:04

also note line 55 - you have to be careful when using reader conditionals inside macros as you need to think of what you’re targeting instead of where you are being compiled

dm319:07:34

so it’s not using a reader conditional, but rather macrovich/case

flyboarder19:07:00

right macros in cljc files each macro should have a condition for clj/cljs unless it can be used for both

dm319:07:28

anyway, I’ve tried a lot of things

dm319:07:32

but couldn’t get it to work

flyboarder19:07:22

@dm3 do you have a sample project you are building with?

dm319:07:02

no, just check out that branch and try running tests

dm319:07:24

boot test-cljs