Separating a Hash type from Object

Andrew Dupont andrew at andrewdupont.net
Tue May 1 21:41:28 PDT 2007


Brendan Eich wrote:
> How about a magic namespace:
>
> foo.direct::["toString"]
>
> or some such? Then 'use namespace direct' would result in 
> foo.toString() or an implicit conversion failing if there were a 
> foo.direct::["toString"]. So a magic namespace may be the wrong UI. 
> How about special syntax?
>
> foo#.toString
> foo#["toString"]
>
> and of course
>
> let dict = #{a:1, b:2, c:3};
>
> ?
>
> /be 
I like it. Let me think out loud...

var foo = {};
foo.toString; //-> function() {}
foo#.toString; //-> undefined

foo.toString = "bar";
foo + "" //-> Error
foo#.["toString"]; //-> undefined

foo#.toString = "bar";
foo#.toString; //-> "bar";
delete foo.toString; //-> true
foo#.toString; //-> "bar";

delete foo#.toString;
foo#.toString; //-> undefined


If I'm correct in all these assumptions, then this seems like a good 
solution. I also like PT's "for..in own" syntax for discovering which 
keys are defined this way.

Cheers,
Andrew



More information about the Es4-discuss mailing list