Separating a Hash type from Object

Brendan Eich brendan at
Wed May 23 06:54:24 PDT 2007

On May 5, 2007, at 11:40 PM, Neil Mix wrote:

> Has this thread dropped again?  That's too bad.  It seems like we
> keep going in this circle:
> 1) we need a base Dictionary class
> 2) in order to be successful, it needs "good UI" and perhaps weak refs
> 3) there's no syntax proposed for this
> 4) it's awfully late for any big changes anyway
> 5) but we need a Dictionary class

Good analysis, and thanks for keeping this pot boiling.

> I take issue with #2.  It's my impression that the veteran JS
> developers on this list have all stated a strong desire for key-safe
> storage, and I believe that they would all agree that a Dictionary
> without syntactic sugar and weak refs is better than nothing at all.
> Do any JS hackers here disagree?

I do. I think users will gravitate to Object because of the  
initialiser syntax. I may be wrong, but it's definitely a trap that  
JS hackers fall into.

So I've been arguing for a week or so, mostly with myself, that we  
have just about enough in the current ES4 proposals to "do almost  
everything", and with a neat syntactic sugar proposal from Lars, I  
think we're done. Here's the scoop:

1. Start by satisfying the thirst for object initialiser syntax: let  
dict = {a:1, b:2, ...}.

2. To avoid collisions with prototype properties, use a private/ 
unique namespace:

     private namespace u;
     let dict = {u::a: 1, u::b: 2, ...};

3. Since the repeated u:: defeats the purpose of (1), allow a default  
namespace to be specified for all unqualified property names in the  

     private namespace u;
     let dict = u::{a:1, b:2, ...};

4. Key-safe membership testing: dict.u::[key] or 'use namespace u;  



More information about the Es4-discuss mailing list