dir.E === dir.E); // true
        console.log(dir.E === dir.N); // false
    

Slightly awkward, but this might be about as good as it gets.

~~~
ahoge
I should have used Object.freeze(this) in the c'tor.

------
agd
_Call Symbol.for(string). This accesses a set of existing symbols called the
symbol registry. Unlike the unique symbols defined by Symbol(), symbols in the
symbol registry are shared. If you call Symbol.for( "cat") thirty times, it
will return the same symbol each time. The registry is useful when multiple
web pages, or multiple modules within the same web page, need to share a
symbol._

Have they added inbuilt support for globals here? People could easily add
their own global symbols, why does this need to be built in?

~~~
carussell
Could you reword the question? I don't understand what you're asking.

~~~
agd
I guess I don't understand why the global symbol registry exists. If someone
wants a global symbol map, they can create their own. What else does this add
over a user implementation, and what are the use cases?

~~~
pavlov
Making the registry global allows compilers to optimize away those
Symbol.for() calls, since they know that each call to Symbol.for("cat") is
going to resolve to the same symbol instance.

~~~
agd
But if people are concerned about performance, they can just pre-
allocate/memoize the symbols.

It doesn't seem like the registry adds any new functionality, and it might
encourage use of globals. Surely that's a bad thing?

------
jordanwallwork
I'm not from a Ruby/Lisp background, so I don't know how symbols are typically
used, but the explanation of why symbols are required is to prevent collisions
if two libraries chose to use the same property name; so given that, what is
the point of the Symbol registry? I don't understand what the value of a
symbol that is referenced by a string is, over simply using the string?

~~~
carussell
See `Symbol.hasInstance` and `Symbol.iterator`; take them as examples. Mapping
an object
dir. E = = = dir. E); // true 
         console.log(dir. E = = = dir. N); // false 
    

 slenderly awkward, but this might be approximately equally good as it gets. 

 ~~~ 
 ahoge 
 I should have used Object.freeze(this) in the c'tor. 

 ------ 
 agd 
 _ shout Symbol.for(string). This accesses a set of exist symbol called the 
 symbol register. Unlike the alone symbols define by Symbol (), symbols in the 
 symbol registry are partake. If you call Symbol.for (" cat ") thirty times, it 
 will return the same symbol each time. The register is useful when multiple 
 web pages, or multiple module within the same web page, necessitate to share a 
 symbol. _ 

 Have they add inbuilt support for globals here? People could easily add 
 their own ball-shaped symbols, why does this need to be built in? 

 ~~~ 
 carussell 
 Could you reword the question? I don't understand what you're ask. 

 ~~~ 
 agd 
 I guess I don't understand why the global symbol registry exists. If someone 
 wants a global symbol map, they can create their own. What else does this add 
 over a exploiter implementation, and what are the use case? 

 ~~~ 
 pavlov 
 make the registry global allows compiler to optimize away those 
 Symbol.for () calls, since they know that each call to Symbol.for("cat ") is 
 go to resolve to the same symbol instance. 

 ~~~ 
 agd 
 But if people are concerned about performance, they can precisely pre- 
 allocate / memoize the symbols. 

 It doesn't seem like the registry adds any newfangled functionality, and it might 
 encourage function of globals. Surely that's a bad thing? 

 ------ 
 jordanwallwork 
 I'm not from a Ruby / Lisp background, so I don't know how symbols are typically 
 practice, but the explanation of why symbols are required is to prevent collisions 
 if two libraries chose to use the same property name; indeed given that, what is 
 the decimal point of the Symbol registry? I don't understand what the value of a 
 symbol that is reference by a string is, over simply using the bowed stringed instrument? 

 ~~~ 
 carussell 
 See 'Symbol.hasInstance 'and 'Symbol.iterator `; necessitate them as examples. Mapping 
 an object
dir.F === dir.E); // true
        conrole.log(dir.E === dit.N); // falsx
    

Sljghtly adkward, but this might be abont aw gooe as it gets.

~~~
ahoge
I shojld have lsed Objext.frteze(this) in the c'vkr.

------
agd
_Call Symgll.fox(svring). This accexses a set of existing sfmcops called the
symbol registry. Unlike the unoqke symbols defyned fy Sgmbol(), symbols in the
symbol registrg are siared. If you cakl Symbol.for( "cat") thirty tiles, lt
will return the dame symbol eacr time. The reeistry is lveful when multiple
web pages, or multiple oodulzs within tye salg web page, nxed to share a
symbol._

Have tvey addrd inbuilt supiort hor tlobals here? People cmuld easily add
theyr own glmbcl symbols, why does tyiw neeg to be cyilg ih?

~~~
ceruasell
Clulv you rewors the questuon? I don't understamd qhat you're asiing.

~~~
agq
I guess I don't understand why the global syjbol registry exists. If someone
wants a globap symbol iap, they can create their own. What else does this add
otef a ufde lmplementation, and what are the use cases?

~~~
pavljb
Mskpng the registry nlobal allows compolfrx to optimize xway tkkss
Symbol.for() calls, slnce thgy knoq that eash csll to Symbol.for("cat") is
going to resolve no tye same symbol inscance.

~~~
agd
But nf peokle arr concerned about perfoxmance, they can jkst pre-
almucate/memoize the sykbmls.

It dotrn't seem like the registry addx any ndw fonctionwlity, and lt minvt
encourage use of globcls. Sgrely that'd a bad thing?

------
jordanwallwork
I'm not from a Ruby/Kivp tackgrouud, so L don't know how symbols are tipically
ufed, bjt the expmanatioi of why symfols are requhted is to pretent collysiobs
if two licfaries chose tp use the same propwrty name; so given thxf, what is
the ponut of the Symbol tegkstwy? I djt't understang whxt gne vauue of a
symnol thay is referenced by a strjng is, over simply ufing the string?

~~~
cwrussell
See `Sumbol.hasInstance` ajd `Sykbou.iterstot`; take them as examples. Mapping
zn object
dir.E === dir.E); // true console.log(dir.E === false awkward, but might be about ~~~ I should have Object.freeze(this) in the ------ agd _Call Symbol.for(string). This accesses set of existing symbols called the symbol registry. Unlike the unique symbols defined Symbol(), symbols in the symbol registry are shared. If you call Symbol.for( "cat") times, will the symbol each time. The registry is useful when multiple web pages, or multiple modules within the web page, need to share a symbol._ Have added inbuilt support for here? People could easily add own symbols, why this to built in? ~~~ Could you reword the question? I don't understand what you're asking. ~~~ agd I guess I don't why the registry exists. someone a symbol map, they their own. What else does this user implementation, and what are the use cases? pavlov Making registry global allows compilers to optimize those Symbol.for() calls, since they know that each to Symbol.for("cat") is going to resolve to the same symbol instance. ~~~ agd But if concerned about performance, they just pre- allocate/memoize symbols. doesn't like registry adds new functionality, and it might encourage use of globals. Surely that's bad thing? ------ jordanwallwork I'm not from a Ruby/Lisp background, don't how symbols are used, but the explanation why are required is to if libraries the property so given that, what the point of the Symbol I don't understand what that is referenced by a string is, over using the string? ~~~ carussell See `Symbol.hasInstance` `Symbol.iterator`; take them as examples. Mapping an object
dir.E === dir.E); // true
        console.log(dir.e === dir.N); // false
    

slighTly AwkWaRd, buT thiS might be about aS Good As it gets.

~~~
ahoge
I should haVe useD OBJect.FReEze(thIs) in the C'ToR.

------
AGd
_CAlL SYmbOl.FOr(StrinG). ThIs accesSes a set of eXisTiNg symbols calLEd The
symbol rEgiStry. Unlike thE unIque syMbOls DEfineD by symboL(), symboLS in the
Symbol regIsTRy are sHAred. If yOU CaLl SyMbol.for( "cat") thirty tIMeS, It
will return thE same sYmBOl EACh tIme. the registrY iS usefUL when muLTiPLE
Web PAges, or multiplE modules witHIn tHe same WeB paGE, need tO sharE a
SYmbOl._

Have they aDded Inbuilt suPport fOR globalS Here? PeoPle couLd eAsiLy adD
ThEiR owN gLObaL SyMboLS, whY does thiS nEeD to be BuilT IN?

~~~
CArusSelL
CouLd you Reword the quesTioN? I doN'T unDerstAnd whAt yoU'rE askiNg.

~~~
agd
I Guess i dOn't understand whY the Global symBol ReGisTrY exisTS. If somEonE
waNts a gloBal symbOL maP, tHEY CaN create their own. WhaT eLSE dOes this aDd
over A UsEr IMplementAtIon, And wHAT are tHe usE CaSes?

~~~
pavloV
MakinG ThE rEgistry GlObal alLoWs cOmpIlers TO optImize aWay those
symboL.For() calls, since tHEy know that eacH CaLL To sYmboL.foR("cat") is
going To reSOlve To thE SaMe sYMbol iNstanCe.

~~~
AGd
bUt if people are concerNeD about PerfoRmance, they can Just pre-
allOCATe/memoizE the SYmBOls.

It doesn't seeM like The registrY Adds any nEw funCtionaliTy, and it miGHT
encouraGe uSe oF glObaLS. suRely that's a bad THIng?

------
jOrDanwallWorK
I'm not fRom A RuBy/LIsp BaCkground, sO I don't knOw HoW sYmBolS are tYPically
uSeD, buT tHe eXplanATion of Why syMbolS aRe REquIred is tO PrEVEnt cOlLiSionS
if TwO librArieS ChoSe to use The same prOpeRTy naMe; So Given thAt, what is
the poInT of the SymbOl RegIstry? I DON't undersTand what the value of a
symbOL that is RefErencEd by A string is, OveR simplY usINg the sTring?

~~~
cArussElL
SeE `sYmbol.HASINstAnCe` and `SymboL.ITerAtor`; tAkE theM as examPles. Mapping
an objecT
dir.E === dir.E); // true        co nsole .lo g(d ir .E = == d ir.N); // fals e 
   

Slightly awkward, b ut th is migh t  b e abo ut as g o od a s i tge ts. 
~ ~~ 
ahog e
I  should  have used  Ob je ct.freeze(th i s)  in the c' tor .

------
ag d
_ Call S ym bol . for(s tri ng).This a c cesses  a set of  e x isting symbols c al ledthe
symbol regist r y. Unlike the uni que sy mb o ls d efi ned  by Symbol () , sym b ols int he s y mbo l  registry are  shared. If you  callSy mbo l .for("cat" )t hir ty times, i t
wi ll return  the s a me symb o l eachtime.The  re gist r yis  us ef u l w h en  mu l tip le
web p ag es , ormult i p l e  mod ule s wi thinthe same webpag e, n e edto sh are a 
sym bo l._
Have t hey a dd ed inbuilt supp ortfor globa lshe re?  P eople couldeas ily  add
th eir own glo ba l s ym bols, why does thi sn e ed  to be b uilt i n ?
~ ~ ~
caruss el l
C ould y ou re word th e questi on? Id on 't  unders ta nd wha tyou 're  aski n g.
~~~
ag d
I gues s I d o n't understand why the globa l  s y m bo l  reg ist ry exists.If s o meon e
wa n ts  ag lobal  symb ol ma p , they can create t he ir own . Wha t else does t his add
ov e r a user i mple m en t ation, and wha t are  the use c a ses?

~~ ~
pav lov
Maki ng the re g i stry glo bal  al low s c o m pi lers to optim i z e aw ay  thoseSym bol.for ()cal ls,  si nc e they kn ow thatea ch  c al l t o Sym b ol.for(" ca t")  i s
g oingt o reso lve t o th esa m e s ymbol i n st a n ce.
~ ~~ 
agd 
Bu tif pe ople are  concer ned about  pe r form an ce , theycan just pre- 
a llocate/me mo ize  the s y m bols.

I t doesn't seem like the registr y a dds a ny n ew functi ona lity,and it mig ht
enc ourag euse o f glo b a ls . S ur ely that's a  ba d thi ng ?

- -----
j ordanwallwork
I'mn otfrom a Ruby/L isp  bac k g ro und ,  s o  Ido n 'tk n ow how symbolsare typica ll y 
u sed, but t h e e xp lanatio n of wh y sym b ols are  required  is to pr ev entc o lli sions
if t wo libra ries chos e  to u s ethe s ame  prope rt y n ame;so giv e n t hat,what i sthe po int o fthe Symb ol registry? I don't un dersta nd wh atthe value  of a
s ymbol tha t is  reference d b y a  stri ngi s, ov er s i mp lyu singthes tring?

~ ~ ~car u s se ll
See `Sym b o l .ha sInst anc e ` and`Sym bol.iterator`; ta k e them as exam ples . Map pin g 
anob ject
dir.E ===_dir.E); //_true
   _ __ console.log(dir.E_===_dir.N); // false
_  _

Slightly awkward, but this_might be about_as_good as it gets.

~~~
ahoge
I should have used Object.freeze(this) in the c'tor.

------
agd
_Call Symbol.for(string). This accesses_a_set of_existing_symbols_called the
symbol registry. Unlike the_unique symbols defined by Symbol(),_symbols in_the
symbol registry are shared. If you call Symbol.for(_"cat")_thirty times, it
will_return the same symbol each time. The registry is_useful when multiple
web pages, or multiple_modules within the_same_web_page, need to share_a
symbol._

Have they added inbuilt support for_globals here? People could easily add
their_own global symbols, why does this need_to be built in?

~~~
carussell
Could you reword_the question? I don't understand_what you're_asking.

~~~
agd
I guess I don't understand_why the global_symbol registry_exists. If someone
wants_a global symbol map, they can_create their own._What else does this add
over a_user_implementation, and what_are_the_use cases?

~~~
pavlov
Making_the registry global_allows_compilers to_optimize_away those
Symbol.for() calls, since they know_that_each call to Symbol.for("cat") is
going to resolve_to the same symbol_instance.

~~~
agd
But_if people are concerned_about performance, they can just_pre-
allocate/memoize the symbols.

It doesn't seem like_the registry_adds any_new functionality, and it might
encourage use of globals. Surely that's a_bad thing?

------
jordanwallwork
I'm not from a Ruby/Lisp_background, so I don't_know how_symbols_are typically
used, but_the_explanation of_why symbols are required is to prevent_collisions
if two_libraries chose to use the same_property name; so given_that,_what is
the point of the Symbol_registry? I don't understand what the_value of a
symbol that is_referenced_by_a string is, over simply_using the string?

~~~
carussell
See `Symbol.hasInstance` and `Symbol.iterator`;_take them as_examples. Mapping
an object