Le 13/04/2013 09:31, Andreas Rossberg a écrit :
On 13 April 2013 00:12, Brandon Benvie <bben...@mozilla.com> wrote:
3.) A new type of primitive along with a new type of wrapper. In this case
we use the String/Number/Boolean precedent where `Symbol()` and `new
Symbol()` produce different kinds of results. The problem here is the
confusion that comes with ToString/ToPropertyKey when called on a Symbol
wrapper. What does `obj[new Symbol] = 5` do, for example? It allows footguns
like `obj[key + '_ext']` to silently do the wrong thing.
That was the consensus at the last meeting, and it's already
implemented in V8. The decision included that
Symbol.prototype.toString is poisoned, i.e., any attempt to implicitly
convert a symbol or a wrapped symbol to a string will throw, including
both of your examples.
Just to clarify, implicit conversion is the behavior of ToString (ES5.1 - 9.8 with Table 13), not Symbol.prototype.toString. And that's what I read from the notes too. Do you confirm? Apparently, symbols have a [[name]] [1]. It would be good if they even had a public "name" property (or rather Symbol.prototype.name getter) at least for debugging purposes. It would make sense if Symbol.prototype.toString (when called explicitly) returned symbol.name.

David

[1] http://wiki.ecmascript.org/doku.php?id=harmony:function_name_property#symbols
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to