Fork me on GitHub
#clojurescript
<
2017-08-06
>
noisesmith00:08:12

so nil? isn't an option?

mfikes00:08:51

@noisesmith nil? returns true for js/undefined

mfikes00:08:36

Unfortunately, it leads to a difference with Clojure for

(def x)
(nil? x)

anmonteiro00:08:51

can you even (def x ) in Clojure?

anmonteiro00:08:23

it’ll be “unbound”, IIRC

noisesmith00:08:40

right, it's a special placeholder class

noisesmith00:08:21

clojure.lang.Var$Unbound - pretty much just exists to say something meaningful via its name in stack trace (and to check for equality to itself of course)

andrea.crotti18:08:06

if I want to send emails via sendgrid (or any other mail service) I should still go through my own backend right?

andrea.crotti18:08:21

otherwise I would have to put my key in the JS code

andrea.crotti18:08:41

and related question, there seems to be many libraries to do HTTP calls in cljs

andrea.crotti18:08:46

any suggestions on which one to use?

luchini18:08:58

As for your first question, you are correct.

andrea.crotti19:08:11

ah cool @luchini , looks like it requires cljs spec alpha though

andrea.crotti19:08:48

or maybe not might be an unrelated error sorry

urbank19:08:29

So how do I use macros from clojurescript? If I have two files clj/a.clj and cljs/a.cljs both with namespace a. If I defmacro in a.cljs, the macro should be available in cljs/a.cljs, correct?

urbank20:08:02

Hm... it only seems to work if I name the clj file differently

urbank20:08:47

I think the issue was that I was using :require-macros in the .clj file

sundarj20:08:27

ah, fair enough

urbank22:08:52

How would I define a macro m that does this:

urbank22:08:54

(m ['a 'b]) => (fn [a b])

darwin22:08:15

@urbank what about this?

urbank22:08:16

@darwin Aha, right. But I need to be able to use the symbols in the body of the function. Is that even still in the scope of macros?

urbank22:08:42

I'll be more specific about what exactly I want. Now perhaps a macro should not be used for this, but here goes:

darwin22:08:17

@urbank this can be done by a macro, macros simply generate code your would want to write by hand

darwin22:08:11

I just don’t follow why ‘foo and ‘bar have to be quoted, and why you even specify some names there, the generated function will not “expose” them outside

darwin22:08:25

the way you wrote the examples, the macro will generate a code defining a lambda function for you, but names of parameters will be irrelevant at that point

urbank22:08:31

@darwin But you have to tell the macro somehow how many arguments you want and where to put them in the get-in vector, right?

urbank22:08:16

@darwin Right, that's good, but I don't know what to use to take an arbitrary vector amount of _s and make them correspond to arguments of a function, and then refer to them in the body of that function. If that makes sense. So p1# and p2# can't be referred to directly inside the macro because you don't know in advance the number of _s.

darwin22:08:31

macro gets input code form as data and can do whatever it wants to generate a new form as data which will replace the macro “invocation” in-place - so you can use your clojure-fu to inspect input vector, process _ positions and generate code based on that

urbank22:08:49

@darwin Heh, not sure what do say. Sounds obvious now that you say it. It is just clojure data structures after all. Thanks! 🙂

darwin22:08:18

@urbank wait, will give you some start code you could tweak further

urbank23:08:04

@darwin Cool. I'll delve into it tomorrow. Have to get some sleep now. Thanks very much 🙂

darwin23:08:22

np, good night 🙂