Claude Pache (2014-02-12T08:30:02.000Z)
Le 11 févr. 2014 à 20:04, Allen Wirfs-Brock <allen at wirfs-brock.com> a écrit :

> 
> Symbol("string") is a symbol factory call,  not a coercion of "string" to a symbol. The argument is not a value to be coerced to  symbol but a string value that is part of the state of the new symbol value. In particular:
>    console.log(Symbol("x") === Symbol("x"))  //false, each call to Symbol returns a new unique symbol value
> 
> If Symbol(sym) returned sym, that would break the invariant that calling Symbol always produces a new symbol value. Rather that reenforcing the fact the Symbol has its own usage patterns that are different from Number/String/Boolean it would  partially blur that distinction. 
> 

Good point. `Symbol(x)` consistently produces a different value at each call, whereas for other primitives, `Primitive(x)` consistently produces the same value.

If we wanted absolutely to be consistent with other primitives, we could make `Symbol(...)` a function that casts to symbol (and, in fact, throws a TypeError in most cases), and use another function (e.g., `Symbol.spawn("name")`) in order to produce new symbols. But it is probably not worth to do that.

—Claude
domenic at domenicdenicola.com (2014-02-18T04:32:15.093Z)
Le 11 févr. 2014 à 20:04, Allen Wirfs-Brock <allen at wirfs-brock.com> a écrit :

> 
> Symbol("string") is a symbol factory call,  not a coercion of "string" to a symbol. The argument is not a value to be coerced to  symbol but a string value that is part of the state of the new symbol value. In particular:
>
> ```js
> console.log(Symbol("x") === Symbol("x"))  //false, each call to Symbol returns a new unique symbol value
> ```
> 
> If Symbol(sym) returned sym, that would break the invariant that calling Symbol always produces a new symbol value. Rather that reenforcing the fact the Symbol has its own usage patterns that are different from Number/String/Boolean it would  partially blur that distinction. 
> 

Good point. `Symbol(x)` consistently produces a different value at each call, whereas for other primitives, `Primitive(x)` consistently produces the same value.

If we wanted absolutely to be consistent with other primitives, we could make `Symbol(...)` a function that casts to symbol (and, in fact, throws a TypeError in most cases), and use another function (e.g., `Symbol.spawn("name")`) in order to produce new symbols. But it is probably not worth to do that.