On Sep 30, 2011, at 7:33 PM, Dean Landolt wrote:

> 
> 
> On Fri, Sep 30, 2011 at 10:13 PM, Axel Rauschmayer <[email protected]> wrote:
> One language feature from JavaScript that I miss are enums. Would it make 
> sense to have something similar for ECMAScript, e.g. via 
> Lisp-style/Smalltalk-style symbols plus type inference? If yes, has this been 
> discussed already? I feel strange when I simulate symbols with strings.
> 
> 
> ISTM private name objects make a pretty nice stand-in for symbols.

function Enum(...names) {
     let e =  Object.create();
     names.forEach(function(n) {e[n] = Name.create()});
    return Object.freeze(e);
}

...

const colors = Enum('red,'blue','green',yellow',orange','purple');
backgournd = colors.red;
foreground = colors.blue;
...


Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to