Brendan Eich wrote:
Allen Wirfs-Brock wrote:
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.

I know it's orthogonal -- please!

It was not clear which of the two (or both) Herby was raising.

Both, and in fact all the three (including, but not mentioning realm indepndence, which is a plus for such cases).

I felt as a good thing having specific naming, realm independence and unique identity in one language construct. That's why I naturally think of symbols as usable in such situations.

Allen wrote: "The @ is primarily for literal property naming
>> syntactic contexts. EG, after a dot." Primarily means, I can use it also out of the "after the dot (including concise method names / extended literal property names)" context. Is it encouraged to use them in such a way? As a "unique, realm-independent object with @name"? Or this use case is discouraged? Or no opinion given in spec leaving the wild to find its use?

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...)

The realm independence is interesting. That could be compelling indeed
for StopIteration, except we already proposed isStopIteration.

/be

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

Reply via email to