This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-15
Channels
- # bangalore-clj (4)
- # beginners (53)
- # boot (7)
- # cider (1)
- # clara (1)
- # cljs-dev (13)
- # clojure (29)
- # clojure-dusseldorf (3)
- # clojure-russia (7)
- # clojure-spec (63)
- # clojure-uk (7)
- # clojurescript (51)
- # css (1)
- # datomic (5)
- # emacs (1)
- # events (1)
- # fulcro (15)
- # hoplon (3)
- # immutant (3)
- # juxt (1)
- # midje (2)
- # off-topic (24)
- # om (1)
- # parinfer (1)
- # portkey (54)
- # re-frame (4)
- # reagent (13)
- # schema (1)
- # shadow-cljs (19)
- # sql (1)
- # testing (37)
- # yada (2)
But cljs =
is more expensive in js (a fn call, typeof
check, and worse) to get the right equality semantics clojure expects
In theory cljs could use type info to weaken = to identical if it can prove type of its args
> It’s not really an intern vs not because js doesn’t expose any such semantics
Hmm. I can't quite square this against my comment, so I'm wondering if we are talking past each other on different tangents. So, just for clarity, all I'm saying is ...
At the js
console:
{"hello": "world"} === {"hello": "world"}
is always false
(all implementations I'm aware of)
("hello" + " " + "world") === "hello world"
is always true
(all implementations I'm aware of)
The 2nd result only happens because js
platforms intern strings. So, to me the semantics are exposed. In fact, so much so that they are explicitly exploited (efficiency!) by the reader conditional code fork questioned by thheller.
To me, intern means all instances with same value have same memory address. === has specified behavior for certain types and does not care about interning. If it exists, it allows for a faster compare, but not interned necessarily
Modern Js vms use many different types internally for strings (eg ropes, views, char set-specific encodings, etc), only some of which are interned. Large strings are not interned
👍 - also, === afaik is defined to be indistinguishable from == for primitives, and strings are primitives in js (but not in java)
So in Java, strings are objects, so they would be identical only if the object referenced match - which could be an effect of interning