Separating a Hash type from Object
andrew at andrewdupont.net
Wed May 2 09:40:46 PDT 2007
On May 2, 2007, at 1:40 AM, Brendan Eich wrote:
> Indeed, #. etc. is just a thought experiment. But just providing
> the ability to override . and  wouldn't help so much without a
> default implementation -- it would force everyone wanting a hash
> unpolluted by Object.prototype to reinvent the wheel.
And there's the rub: how do we make a default implementation without
introducing too much magic? No matter how we do it, a Hash class
would introduce a completely different relationship between an object
and its properties.
Reinventing the wheel is less surprising to developers because it's
their wheel and they know how it works. But I think the initial
unpleasantness of special-casing Hash is better than the ongoing pain
of each developer writing his own implementation of hashes.
I'm entirely in favor of a way to override "." and "", whether or
not ES4 introduces a magic Hash class. That, at least, gives the
developer a chance to solve the problem on her own.
More information about the Es4-discuss