juxt

eval2020 2017-08-29T07:26:24.000374Z

@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

dominicm 2017-08-29T07:28:12.000177Z

Great!

jonpither 2017-08-29T14:31:52.000514Z

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

dominicm 2017-08-29T14:32:12.000090Z

#js is already a literal

dominicm 2017-08-29T14:32:53.000547Z

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

jonpither 2017-08-29T14:33:28.000497Z

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

jonpither 2017-08-29T14:33:53.000382Z

but yeah. I'm just bouncing ideas around

dominicm 2017-08-29T14:37:47.000551Z

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.

jonpither 2017-08-29T14:38:29.000319Z

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

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

dominicm 2017-08-29T14:39:00.000124Z

That just doesn't bother me, oddly enough.

jonpither 2017-08-29T14:39:28.000322Z

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

jonpither 2017-08-29T14:39:52.000208Z

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

dominicm 2017-08-29T14:41:53.000260Z

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.

jonpither 2017-08-29T14:42:24.000506Z

fair enough

jonpither 2017-08-29T14:42:29.000327Z

I concede

jonpither 2017-08-29T14:43:46.000546Z

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))}

jonpither 2017-08-29T14:44:06.000275Z

for those left-pad zealots out there

dominicm 2017-08-29T14:45:15.000522Z

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.

jonpither 2017-08-29T14:46:14.000689Z

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

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

jonpither 2017-08-29T14:46:21.000263Z

We need to ratify constants and props

dominicm 2017-08-29T14:47:04.000059Z

yes. agreed.