Symbols, Protocols, Frames, and Versioning
allen at wirfs-brock.com
Sat Oct 6 18:37:46 PDT 2012
On Oct 6, 2012, at 2:57 PM, Kevin Smith wrote:
> The issue, is providing access to an already created symbol across such boundaries. As I have pointed out in other messages, this isn't a problem that it unique to symbols. It is isomorphic with use cases for sharing any kind of object across such boundaries.
> I disagree. The only reason this issue looks like a nail is because you're gripping that symbol hammer so hard. ; ) The problem is a quack.
> This is duck-typing, plain and simple. The only issue is what kind of a quack we are looking for. Do we identify the quack by using a flat identifier namespace (as we typically do), or do we go for something stronger?
> There's nothing wrong with using "iterator" as the quack. But the option exists for something stronger, if we are willing to create the syntax to support it.
> Let's call it strong-duck-typing. Instead of a quack being an identifier in the flat namespace of identifier names, the quack is a globally unique string. There are only two sane options for globally unique names: uuids (or random equivalents) and DNS-based paths. Let's arbitrarily choose uuids.
I don't think "strong" is the right adjective for what you are trying to say. I think "immune to unintended conflicting usage of a property name" is the idea you are getting at. It a property is named using commonly used word, it has a higher probability that somebody will choose that same word to name a property that has a different intended semantics than the original usage. They appear to be polymorphicly equivalent properties but they really aren't. They won't "act like the same duck".
Being globally unique is not sufficient. ECMAScript names are globally unique, but many string values are subject to unintended semantic conflict (reassignment of meaning) exactly because they are globally available to everybody and likely to be chosen the a good property name. DNS-based paths use of UUIDs DNS-bassed paths reduces (significantly) the probably of an unintended conflicting reuse of a name. But it does not guarantee that it won't occur.
The alternative is to use a unique value that can't be unintentionally recreated. That is what a symbol is. It is an unforgeable, unguessable property name. If you want to define a property that will be recognized to have some specific meaning you must obtain the symbol to use as the property key from some dispensing authority.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss