This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-09
Channels
- # alda (9)
- # announcements (1)
- # beginners (6)
- # boot (140)
- # cbus (2)
- # cider (27)
- # cljs-dev (19)
- # cljsrn (17)
- # clojure (104)
- # clojure-art (1)
- # clojure-brasil (5)
- # clojure-colombia (2)
- # clojure-russia (146)
- # clojure-sg (3)
- # clojurescript (64)
- # clojurex (1)
- # cursive (17)
- # data-science (22)
- # datomic (41)
- # editors-rus (5)
- # events (1)
- # hoplon (61)
- # ldnclj (35)
- # lein-figwheel (1)
- # off-topic (1)
- # om (119)
- # onyx (214)
- # re-frame (3)
- # reagent (13)
- # robots (5)
- # slack-help (1)
- # yada (17)
When compiling a file with a "if expression” which contains constants in the then/else branches, the resulting js file has empty then and else branches. Whereas, when the then/else branches contain for example vectors, the then/else branches contain the vectors. The following gist shows the behaviour I am trying to describe: https://gist.github.com/mneise/9a94f49f2960d5ee1445. It seems that constants are not emitted when the context is a statement (https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/compiler.cljc#L418). Does someone know why this is the case?
@maria the analyzer does not correctly identify the vector (or anything beyond basic types) as a constant
when the result of a branch is needed the compiler will emit x = pred ? true : false;
yeah, just tried that, too Cool, makes sense, thank you for explaining. And I guess you can’t completely remove it, since the test expression could have side effects?
David suggested at one point that the analyzer should be able to identify vectors/maps as constants
And how does it work in the REPL? Everything that gets passed to eval is handled as an expression?