Fork me on GitHub
#clojure
<
2018-08-18
>
dominicm15:08:24

Is there a way for macros to expand such that they contain private vars, short of using #'?

mfikes15:08:03

I’m not aware of any way. (In fact in some ClojureScript core macros there is a bit of a hack to work around that in order to avoid unnecessary code bloat. https://github.com/clojure/clojurescript/commit/3123aa32851c01682cf076e0e3b497e890b26922)

dominicm15:08:03

@mfikes OT, why ~js* over #'? I'm writing clojure, so I don't think I have an option, but I'm curious

mfikes15:08:58

Right, in Clojure, I’m not aware of such a workaround. (In Clojure, if pressed, I’d make a var public but name it something that indicates its private nature, maybe foo*) In ClojureScript, the use of var is problematic because it expands to a bunch of JavaScript. That’s arguably OK in many cases, but in those particular core macros, it is a hard pill to swallow, given the potential effect on generated code size.

mfikes15:08:09

(So, in those core macros it uses js* because it knows what it’s doing and that essentially emits the desired JavaScript—`js*` is used often in ClojureScript’s core macros.)

mfikes15:08:24

Dunno, perhaps something similar is possible via Java interop if you really really need to do it in Clojure.

dominicm15:08:26

That's very interesting. Very cool 🙂. I suppose that could easily become undone without knowing why it's like that :thinking_face:. I'm thinking I'll move the code to an impl namespace where it's public. This is the first time I've actually needed impl rather than just using it for aesthetic reasons.

emccue22:08:26

@hiredman, it seems to be a hard incompatibility. I tried the example code from the front page and am getting random errors depending on what i change. the most recent is java.lang.NoClassDefFoundError: org/eclipse/jetty/server/NegotiatingServerConnection$CipherDiscriminator

emccue22:08:25

i have jetty as a dependency and it was working just fine with ring-jetty-adapter

hiredman22:08:08

maybe, I doubt it has anything to do with being on windows though, I bet something is pulling in conflicting versions of jetty or something

emccue22:08:25

okay. Ill be in dependency hell for a week or two then

emccue22:08:42

ill let you know what i find

dadair22:08:38

You may be able to get more information in #pedestal; the new maintainer regularly frequents the channel