Fork me on GitHub
#clojurescript
<
2017-03-04
>
deas07:03:10

wrt node modules: Assuming a module exports just an object which other code expects as is. How is this supposed to handled in cljs given that modules map to namespaces which are not first class?

markel11:03:10

Hi guys! I'm pretty new to Clojure and Clojurescript, hoping to perform a switch from JS. Now it's time for me to try it out on a real project, so I've decided to take a shot with React Native and Re-Natal seems to be the best choice out there. Please cheer me up! 🙂 The Re-Natal channel is not so active as this one, so I guess I'll ask the question here, maybe someone can help... So here's the question. Re-Natal uses the 23 target android version by default, how to properly change it?

pesterhazy12:03:33

it's prtty active

qqq12:03:42

learning cljs + learning reactive native together is like learning how to surf + learning how to juggle chainsaws together

qqq12:03:57

each is intense enough on its own

pesterhazy12:03:30

yeah it'll be a nice challenge 🙂

hlolli13:03:41

Is this the smell of javascript at work here

(defmacro weird []
  `(+ 1 (symbol "a"))) => "1a"

markel13:03:51

@pesterhazy Thanks, I'll try @qqq Well, the React Native seems to be just a set of components, magically turned into the native app... basically 🙂

jaymartin13:03:31

How can we build better "first contact" experiences for new programmers and Clojurians? Our open source learning group is hosting the free online webinar Essential Klipse TODAY at 7 pm UTC (2 pm Eastern) to address that question. Everyone is welcome! http://discuss.thevalueoflearning.org/t/webinar-discussion-2-essential-klipse/39?u=jay

pesterhazy13:03:38

clojurescript is really just javascript with a few layers of parentheses on top

markel13:03:03

...and the power of Clojure and functional stuff, right? 🙂 I'm a big fan of FP, Haskell, Elm, Redux, etc. But I'm just bored of JS

pesterhazy13:03:24

yes of course, clojurescript is an amazing tool, but pretty soon you need to understand the host, warts and all

borkdude14:03:18

@hlolli I got:

cljs.user=> (+ 1 'a)
"1a"
WARNING: cljs.core/+, all arguments must be numbers, got [number cljs.core/Symbol] instead. at line 1
in lumo 🙂

hlolli14:03:15

ok vey well, try this in lumo

(cljs.core/+ 1 (cljs.core/symbol "a"))

borkdude14:03:02

No warning there. It probably only checks non-lists? Hm

hlolli14:03:44

yes, I wonder if this warning should just be an error?

borkdude14:03:01

Don't know how this works

bronsa14:03:42

cljs only warns if it can figure out at compile time that you're not using a number

pesterhazy15:03:38

Cljs and clj have different behavior here. Clojure lets incorrect arities or argument types pass at compile time but throws an exception at runtime, whereas Clojurescript warns about these mistakes at compile time (in static contexts) but doesn't usually throw at runtime (resulting in weak typing and padding of missing args with nils).

hlolli15:03:05

I guess that's a good reason to use clojure.spec unsparingly.

anmonteiro17:03:07

+ is both a macro and a function in ClojureScript

anmonteiro17:03:53

As @bronsa said, if you use the macro version you'll get that warning

anmonteiro17:03:20

However, if (+ 1 'a) doesn't produce a warning in Lumo that's a bug

anmonteiro17:03:47

Pls open an issue :-)

anmonteiro17:03:16

We're probably not binding *print-err-fn*

hlolli17:03:49

no Lumo is behaving well here 🙂

lumo.repl=> (+ 1 'a)
"1a"
WARNING: cljs.core/+, all arguments must be numbers, got [number cljs.core/Symbol] instead. at line 1 

hlolli17:03:59

only with namespaced symbol it doesn't. If its a macro then its expected

anmonteiro17:03:02

No bug then!

hlolli17:03:16

yes move along, nothing to see 🙂

anmonteiro17:03:47

So cljs.core/+ will be the function

anmonteiro17:03:14

If you use cljs.core$macros/+ you'll probably get the warning

anmonteiro17:03:52

@hlolli can you confirm that? Not at the computer atm

hlolli17:03:03

lumo.repl=> (cljs.core/+ 1 'a)
"1a"
WARNING: cljs.core/+, all arguments must be numbers, got [number cljs.core/Symbol] instead. at line 1 
lumo.repl=> (+ 1 (symbol "a"))
"1a"
lumo.repl=> 

hlolli17:03:52

lumo.repl=> (cljs.core$macros/+ 1 'a)
"1a"
WARNING: cljs.core$macros/+, all arguments must be numbers, got [number cljs.core/Symbol] instead. at line 1 
lumo.repl=> 

bobcalco18:03:37

A Node.js<—>CLJS interop problem I’ve asked about before but forgot the answer to, wasn’t in a position to try when I got the answer the first time I asked (now I am!), and which might be helpful for others currently who are banging their heads on related questions: If I want to write a JavaScript module in ClojureScript for interoperability with Node.js that would be consumed by standard JavaScript via ‘require' according to a loose plugin “protocol” whereby module.exports is defined as a JavaScript hash containing an implementation of specific key-value pairs (some of which resolve to functions), how might that look in my ClojureScript source code and be compiled for minimum friction? The one I have in mind requires initialize(), start() and stop() and a small number of optional priority level indicators — kind of like stuartsierra/component with benefits. Moreover this plugin framework knows nada about namespaces.

nidu19:03:00

Hello. Is there any handy function in cljs.spec which can be easily used in :pre and which will print wrong data and the cause? Using valid? doesn't help a lot and fdef looks like an overkill (or maybe i'm just wrong)

rauh19:03:53

@nidu s/assert, but watch out for nilable

qqq22:03:49

in my cljs dev setup, I have chrome set to "pause on exception" -- this is great, except .it also prevents reloading is there some commandline program I can run which sends chrome a signal to "hey, force reload" ?