Speaking of Lisp...

P T Withington ptw at pobox.com
Fri Jan 5 19:51:29 PST 2007

On 2007-01-05, at 20:14 EST, Brendan Eich wrote:

> ECMA TG1 has not considered symbols.  Macros and property quotation  
> facilities have been mentioned for post-ES4 work, so who knows?

That would suffice.

> Another item falling out of the ES4 spec: hashes mapping string to  
> value where the mapping is not polluted by Object.prototype.  A  
> late "save" may be possible, if anyone can suggest syntax.  E.g.,  
> var hash = #{'foo':1, 'bar':2, 'baz':3}; alert('toString' in hash)  
> => false.  Eek, yet another attempt to use #.

Since you can't build a pure hash in Javascript, this would be a  
_highly_ desirable addition.  Naive use of Object for hash has been  
the source of a number of subtle bugs in our code.  One might even be  
so bold as to make Hash the primitive and Object inherit from it?

We would have many uses for Hash in our code base.  I have defined a  
dictionary class that I use for some cases, but often have had to  
trade correctness for performance.

A literal syntax would not be that important if you could have a  
constructor with named arguments.  (Because the constructor's  
`arguments` property would be a Hash?)  It would also be useful to  
have a constructor that constructed a new hash from an existing one.

> (Should these map value to value, rather than string to value?  E4X  
> (ECMA 357) already introduced QName objects as identifiers, so one  
> can't pretend all properties are named by strings, if one believes  
> in E4X.)

value -> value would be a bonus that I would greatly appreciate, but  
then won't you need to define a protocol for extending hash-code  
computation and `===`?

More information about the Es4-discuss mailing list