StopIteration, ForwardToTarget, ... & symbols

Brendan Eich brendan at mozilla.org
Mon Nov 26 17:27:27 PST 2012


David Bruant wrote:
> Le 26/11/2012 22:11, Brendan Eich a écrit :
>> 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'm not sure not being a property key is that big of a constraint, so 
> I would say that objects and symbols are both valid equally valid.

Perhaps not, but it's odd to make a symbol just for (e.g.) immutability 
with no properties or [[Prototype]]. For realm-independence is more 
interesting. More below, on your good point I had forgotten momentarily 
in replying to Allen a minute ago.

>> I think this applies to StopIteration.
> It is suggested on the strawman that StopIteration be a constructor 
> [1] and I support this idea for StopIteration because an iterator may 
> have different reasons to stop and building instances with a message 
> (or any property) attached.

Yes, indeed, and StopIteration as constructor is used implicitly when a 
generator function returns a value. This makes the case for object not 
symbol. isStopIteration copes with realm-dependence.

> I'm not sure It'd be as relevant for ForwardToTarget.

I leave that to you and Tom :-P.

Thanks,

/be

>
> David
>
> [1] http://wiki.ecmascript.org/doku.php?id=harmony:iterators
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list