Implicit coercion of Symbols

Andrea Giammarchi andrea.giammarchi at
Sat Jan 3 15:30:43 PST 2015

Agreed with Brendan,
  and I've  thought the same.

It's been also years we have problems using unknonw objects in the wild,

var n = {__proto__:null};
var s = String(n); // error, No default value
var s = '' + n; // error, No default value
Same if used as [property accessor] so I am not sure why `String(o)` when
`o` is `Symbol` should not throw.

I'd expect it to throw all the time and let developers be a bit more
careful on their explicit or implicit casts.

The `toString` and `valueOf` are great examples that could compromise a lot
of real-world code.

Being `Symbols` new we should probably/hopefully get them in the right way.

I feel like throwing either cases is the right way.

Just my thoughts,
  Best Regards

On Sat, Jan 3, 2015 at 11:56 PM, Brendan Eich <brendan at> wrote:

> Rick Waldron wrote:
>> Subjectively: I think it's nice in theory, but bad in practice.
> Compared to what? Converting a symbol to asilent-but-deadly string?
> I thought you were gonna raise the other way to restore consistency: make
> String(sym) throw too. Then we'd need a new Reflect op to get a string from
> a symbol.
> /be
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list