Fork me on GitHub
#clojurescript
<
2017-02-15
>
thedavidmeister08:02:15

i'm confused about how NaN works in cljs

thedavidmeister08:02:35

(def a NaN)
NaN
(if a :foo :bar)
:foo
(if NaN :foo :bar)
:bar

pesterhazy08:02:03

That can't be right

thedavidmeister08:02:16

js works like this

thedavidmeister08:02:18

var a = NaN;
undefined
if (a) { 1; } else { 2; }
2

pesterhazy08:02:48

NaN is truthy in cljs

thedavidmeister08:02:30

so then why (if NaN :foo :bar)?

thedavidmeister08:02:16

oh, js/NaN works differently it seems

pesterhazy08:02:23

Yeah that's it

pesterhazy08:02:06

NaN is not a special symbol in cljs

qqq08:02:14

wait, so the answer is js/NaN = truthy, but NaN = undefined symbol = nil = falsey?

minikomi08:02:12

And in clojure, only nil and false are falsey.. in js... well.. http://stackoverflow.com/questions/19839952/all-falsey-values-in-javascript

metametadata10:02:58

@shader I guess splitting projects into backend and frontend ones is fine. And Bidi routes then can still live in a common .cljc file visible by both projects, so there's no need to serve them dynamically via server API.

pesterhazy10:02:42

if you hava an SPA mounted at /foo, you can just serve /foo/* to the same static route on the server

pesterhazy10:02:03

don't see a need for the server to know about client routes

pesterhazy10:02:24

ah that's what @metametadata said, sorry 🙂

metametadata10:02:20

@pesterhazy well, not exactly the same 🙂

metametadata10:02:36

actually I too mostly use /foo/* approach so that server knows nothing about SPA routes. It's easier, but means 404 pages are generated by SPA.

fifigyuri13:02:09

Hi, we have a js codebase, and I’m thinking about the possibility to use clojurescript in some parts. Is it possible to use immutable datastructures used in clojurescript inside js projects? I’ve seen mori, but I’m not sure whather that’s the same as the data structures in cljs

dnolen14:02:08

@fifigyuri Mori is in fact ClojureScript

fifigyuri14:02:41

@dnolen, so passing a clojurescript datasctructure to a js code can be understood using mori, and vice-versa..

dnolen14:02:31

yes but the caveat is that ClojureScript data structures cannot be used like JS data structure literals

dnolen14:02:48

so no JS object property access or array access

dnolen14:02:35

we do support ES6 Map interface for hash maps and Iterable protocols for all the collections

dnolen14:02:18

but these limitations are pretty much the same as Immutable.js

fifigyuri14:02:39

thanks I’ll try that, want to keep a door open for clojurescript

lockdownz14:02:14

@fifigyuri didn't quite understand your question, why not add clojurescript directly to your js project instead of using mori?

dnolen14:02:34

bringing ClojureScript into an existing JavaScript application isn’t really all that practical

dnolen14:02:26

we’re working on making it more practical, but we’re not there yet

lockdownz14:02:33

yeah, was confused cause he said "thinking about the possibility to use clojurescript in some parts"

lockdownz14:02:29

but then he mentioned mori

fifigyuri14:02:01

@lockdownz if I want to introduce a clojurescript code to our codebase, it has to somehow live inside of the already existing application, right now we have backbone models, can be used by clojurescript I know, but that’s not real deal of clojurescript. we use in some subparts of application an immutable data structures and use react. we can choose between immutable.js and mori, using mori gives us later the option to use in parts clojurescript. I’m thinking about a gradual process, using mori with react in some parts can be a way to start

negaduck16:02:29

why does compiler gives a warning for (- nil 1), but doens’t for (- (first '()) 1)?

bronsa16:02:26

the first one is easy to statically check, the other is not so easy so cljs doesn't attempt to

bronsa16:02:57

just like (nil) throws at compile time but ((do nil)) doesn't

negaduck16:02:19

hm. So this is a compile-time warning, ok. I thought (- nil 1) is a problem during run-time.

negaduck16:02:02

does nil here implicitly get converted to a number?

bronsa16:02:25

sorry, didn't realize this was #clojurescript

bronsa16:02:47

don't really know how clojurescript handles that but I'd assume what I said above would be valid too

bronsa16:02:18

yeah it's a compile time warning in cljs

bronsa16:02:40

as per nil being implicitely converted to a number, that's probably just what javascript does for numbers

bronsa16:02:52

cljs.user> (js* "null - 1")
-1

negaduck16:02:33

interesting. Thank you.

vemv16:02:33

hiya there, first post. just a quicky q: why I can't (require 'clojure.zip) in clojurescript?

vemv16:02:44

it will say No such namespace

henriklundahl17:02:19

@vemv I can require it.

vemv17:02:41

perhaps depends on the clojurescript version...?

vemv17:02:01

I'm running 1.9.293 which seems recent enough

pesterhazy17:02:19

that's not an official page

vemv17:02:41

wondering if it could be some configuration in the project I'm working on (it's a large one I didn't create... so there's plenty of places too look at :s)

vemv17:02:51

found the issue. clojurescript version was recent enough, but versions of lein-cljsbuild/figwheel/figwheel-sidecar weren't