Fork me on GitHub
#juxt
<
2017-08-29
>
eval202007:08:24

@dominicm thanks - got it to work:

{
 mach/constant {msg "World"}

 hello (println (str "Hello " #ref [mach/constant msg])) 
}
# $ mach hello
# => Hello World
# $ mach --constant '{msg "Mars"}'
# => Hello Mars

jonpither14:08:52

@dominicm coming back to our earlier conversation of pondering making this kind of thing nicer: ((js/require "request") "" callback), one might imagine a literal to assist (#js ...)

dominicm14:08:12

#js is already a literal

dominicm14:08:53

I'd never use require inline like that. I'd always def it as request first.

jonpither14:08:28

I think the context is different in Mach to building usual CLJS programs

jonpither14:08:53

but yeah. I'm just bouncing ideas around

dominicm14:08:47

so many node libraries require one of these forms:

(def r (js/require "request"))
(def r ((js/require "request")))
(def r (.request (js/require "request")))
Making one pretty & not the others in a consistent way is confusing to use.

jonpither14:08:29

{mach/npm [["left-pad" "1.1.3"]]

 pad-foo (println ((js/require "left-pad") "foo" 5))}

dominicm14:08:00

That just doesn't bother me, oddly enough.

jonpither14:08:28

I don't really have a strong motivation - just revisiting this area

jonpither14:08:52

but it occurs you could also mess with the mach/npm directive, to add a symbol there you want to def the lib to

dominicm14:08:53

Hmm, also a case fraught with peril given e.g. require('material-components-web/dist/material-components-web') is a part of the material-components-web module.

jonpither14:08:46

we currently have this to tidy up also:

{mach/npm [["left-pad" "1.1.3"]]
 mach/init (def lp (js/require "left-pad"))

 pad-foo (println (lp "foo" 5))}

jonpither14:08:06

for those left-pad zealots out there

dominicm14:08:15

That syntax obviously works quite consistently. Not opposed to something like:

mach/constants {lp (js/require "left-pad")}
 pad-foo (println (lp "foo" 5))
Anything that can create a body of bindings for you.

jonpither14:08:14

{mach/npm [["left-pad" "1.1.3"]]
 mach/props [lp (js/require "left-pad")]

 pad-foo (println (lp "foo" 5))}

jonpither14:08:21

We need to ratify constants and props

dominicm14:08:04

yes. agreed.