On Nov 26, 2012, at 1:11 PM, Brendan Eich wrote:

> Herby Vojčík wrote:
>> Hi,
>> 
>> shouldn't StopIteration, ForwardToTarget from "Notification proxies" thread 
>> and similar ones be rather well-known unique symbols (like @iterator), now 
>> that we have them, instead of well-known globals? \
> 
> Why?
> 
> Let's separate the naming and unique identity concerns. Objects have unique 
> identity, so do symbols. But if a unique identity is required without being a 
> property key, then an object is the right answer, not a symbol. I think this 
> applies to StopIteration.
> 
> Then there's the naming question. Should one have to use an @-name to 
> reference a singleton object? Again I say no. APIs have public names, mostly 
> or always. An identifier is a fine public name, better than a non-private 
> symbol if bound in a namespace object or module -- or even if a global like 
> JSON.

Orthogonal issues. A symbol object object can be the value bound to a regular 
identifier.  The @ is primarily for  literal property naming syntactic 
contexts.  EG, after a dot.

> 
>> On the more general line, I got pretty fond of (unique) symbols, they seem 
>> like very good things for these sentinel-like objects. Is it ok / preferable 
>> to use them for that? No need to use empty objects bearing only their 
>> identity any more, imo.
> 
> For unique identity, why do you care between symbol and object?

A nice thing about Symbols as I've now spec'ed them in the latest draft.  It 
that they are truly immutable, stateless, and Realm independent.  They don't 
carry any other object references at all.  Not even to their toString method.  
(fun things that can be done via the MOP...)

Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to