This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-22
Channels
- # aws (12)
- # babashka (24)
- # beginners (51)
- # biff (2)
- # cherry (4)
- # cider (2)
- # clj-kondo (4)
- # cljs-dev (19)
- # clojure (70)
- # clojure-australia (4)
- # clojure-europe (39)
- # clojure-nl (4)
- # clojure-norway (6)
- # clojure-spec (9)
- # clojurescript (21)
- # component (6)
- # cursive (18)
- # data-science (9)
- # datomic (18)
- # events (2)
- # expound (4)
- # fulcro (15)
- # graalvm (2)
- # graphql (5)
- # jobs (1)
- # juxt (2)
- # leiningen (8)
- # malli (4)
- # meander (21)
- # nrepl (3)
- # observability (14)
- # off-topic (49)
- # other-languages (1)
- # pathom (13)
- # pedestal (7)
- # rdf (5)
- # re-frame (10)
- # reitit (1)
- # sql (4)
- # squint (30)
- # tools-deps (1)
- # vim (11)
might be for historic reasons. I do remember some browsers (at least IE) not doing too well with extending native types
@lilactown I think the idea is that you have to control the protocol or the type
> if you use a protocol and a type you don’t control then you will have conflicts I recall the case of MooTools monkeypatching core JS objects causing trouble for newer ECMAscripts, with conflicting methods changing underlying semantics. Are there are other good examples where this wasn't just a theoretical problem?
it happened all the time - in the early days it prevented using different libs together on the same webpage
does the introduction of Symbol
and extending built ins using them eliminate most of the risk of conflicts?
@lilactown If you own the protocol, what is exactly the risk?
Symbol is a means to an end, a unique string property would have the same effect I think?
yeah, there's certain other nice properties of using symbols that don't have to do with avoiding conflicts
you don't have to use Symbol.for
. Symbol("foo")
creates a completely unique symbol each time, so as long as you can reference the value returned by it, using Symbol.for
is not needed and you can avoid conflicts compeletely
but also, Symbols as properties on objects don't show up in the enumerable properties of objects, so you can avoid problems with serialization too
so if have an object {}
and do {}[Symbol("foo")] = 1
twice, it has two new properties?