Fork me on GitHub
#clojurescript
<
2015-12-31
>
mfikes00:12:38

@crocket: you at least get a partial order based on ns dependencies

crocket00:12:53

What do you mean?

mfikes00:12:31

The order of side effects (like setting a dynamic var) are only guaranteed as a result of one namespace depending on another. I suspect this is relevant to your main question.

mfikes00:12:49

In concrete terms if namespace a depends on namespace b, then b can execute side effects that a can rely upon.

crocket01:12:08

Does the namespace that sets *main-cli-fn* last wins? I'm not sure about exactly when *main-cli-fn* is executed.

crocket02:12:36

@mfikes: My theory is that if namespace a(the :main namespace) depends on namespace b and both namespaces set! *main-cli-fn*, a gets to set *main-cli-fn* lastly, so a wins.

crocket03:12:13

When I invoke clojurescript functions in nodejs, javascript allows to pass fewer arguments than function signatures to functions. How can I enforce arity in javascript?

crocket03:12:57

I know that people just manually check for null in javascript.

akiva04:12:10

This is what I would call a time for defensive programming. The function should be able to handle multiple arity.

crocket04:12:15

That sounds simple but a little inelegant.

akiva04:12:47

I disagree. If the function would just kick an error if the wrong number of arguments were sent, then yeah. But you could return (partial) functions and such which provides you the means toward composability on the caller side.

crocket04:12:56

What if I want to enforce one arity in javascript runtime?

akiva04:12:30

Think about it from the other direction: what do you want to happen if the arity isn’t correct?

akiva04:12:18

It’s an API issue. If you’re in control of both the Node side and the CLJS side then it’s up to you figure out the choke point (basically a façade pattern) between the two sides that will check that the n-arity is obeyed.

crocket04:12:49

In clojure and clojurescript, arity is enforced. It's javascript that ignores arity.

akiva04:12:50

Right. So either you put a façade of functions on the JavaScript side that throw on bad arity or you handle it on the ClojureScript side by having it return what you want on a bad arity.

crocket04:12:08

I somehow hope that clojurescript adds arity enforcement on javascript.

akiva04:12:57

I don’t. Personally, when I’m designing an API, I want it to be as flexible as possible. A throw is the very last thing I ever want anything to do.

crocket04:12:02

Then, javascript semantics leak into clojurescript. It adds to my headache. I'd rather reduce complexity.

akiva04:12:34

I’ve never found complexity reduced by nailing doors shut. Build a 10’ tall wall and someone will build a 12’ tall ladder.

akiva04:12:10

And there’s always going to be a bit of an awkward dance between ClojureScript and JavaScript just because JavaScript is kind of unhinged anyway.

akiva04:12:31

It’s why I usually shore up the CLJS side.

crocket04:12:50

Please note that my use case is valid as well.

akiva04:12:09

Oh, of course. I don’t mean to in any way suggest otherwise.

akiva04:12:41

I’m just expressing my opinions based on my experience. When I’m doing interop, getting an exception from a call is quick to see but every time you get that, it’s a limitation you have to work around.

crocket04:12:13

Limitation on mutability is a bless of clojurescript. The right kinds of limitation reduce complexity.

akiva04:12:31

I like your edits. simple_smile

akiva04:12:49

I don’t mean to suggest that every function should be an n-arity free-for-all.

akiva04:12:15

What I was trying to say is that you need to figure out where it is along the chain where you want to put the limitation. Do you do it on the JavaScript side? Make a wrapper around the calls to the CLJS stuff? Or do you buttress the CLJS functions and let them handle multiple arity by sending back partial functions so you kind of have a bit of currying so to speak.

akiva04:12:55

I’m partial (ha ha) to the latter. I like the flexibility. Let the caller deal with the results but make sure it’s documented.

crocket04:12:13

I like flexibility to the extent that it lets me avoid implementing things that I don't need in the foreseeable future.

akiva04:12:32

But the API you’re working on isn’t always for you.

akiva04:12:25

Or maybe it is but you might need something more from it seven months from now.

crocket04:12:10

Flexibility lets me implement things that I haven't thought of before, so I can implement just what I need for now.

crocket04:12:43

Without flexibility, I'd have to rebuild from scratch when some requirements are added later.

akiva04:12:18

Right. Is it possible we’re saying the same thing but in a different way? Or maybe from a different perspective?

crocket04:12:47

If clojurscript had support for enforcing arity, it'd be better. A compiler option would break a lot of things, so it may be a function or a macro.

akiva04:12:06

[chuckles] Maybe so. As an option.

akiva04:12:44

And a lot of what they do with ClojureScript and the direction in which it is urged is tied to what what, say, Google Closure lets them do. When you’re compiling—or transpiling or whatever—, you’re always at the mercy of the compiler and in our case, as far as I understand it, there’s only so much they can do.

akiva04:12:41

To make matters more interesting, the development cycle of JavaScript is becoming increasingly rapid and they’re getting more bold. The next three years are going to be amazing to see.

crocket04:12:09

ES6 may break clojurescript compiler.

akiva04:12:19

There will be some work to be done, definitely. But there are some preternaturally smart people at work on Clojure and ClojureScript. I have a lot of faith in the efforts.

akiva04:12:39

Thanks for the discussion, by the way; I had fun.

crocket11:12:15

I created a new leiningen template for writing clojurescript npm modules. https://github.com/crocket/cljs-npm-template

crocket11:12:17

With this template, it is not hard to create an npm module in clojurescript.

panesofglass18:12:59

@dnolen: thank you for all you’ve done with Om this year. I’m excited to see your progress with Om/Next in 2016.

dnolen18:12:29

@panesofglass: your welcome, looking forward to it as well simple_smile

hugod20:12:37

Would anyone have an exmple of how to use a react native ListView with om.next?

adamfrey20:12:06

@hugod there is a #C0E1SN0NM channel for React Native discussion. You might have more luck asking there.

hugod20:12:46

@adamfrey: thanks for the pointer