StopIteration, ForwardToTarget, ... & symbols

David Bruant bruant.d at gmail.com
Mon Nov 26 13:32:52 PST 2012


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.

> 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. I'm not sure It'd be as relevant for ForwardToTarget.

David

[1] http://wiki.ecmascript.org/doku.php?id=harmony:iterators


More information about the es-discuss mailing list