A couple reactions:

- strings are already interned in current engines for symbol-like performance; 
there's no need to introduce symbols into the language

- private names are overkill for most uses of enums; just use string literals

- in SpiderMonkey I think you get better performance if your switch cases use 
known constants; for example:

    const RED = "red", GREEN = "green", BLUE = "blue";
    ...
    switch (color) {
      case RED: ...
      case GREEN: ...
      case BLUE: ...
    }

- with modules, you would be able to define these consts and share them 
modularly (currently in SpiderMonkey the only way to share these definitions 
across modules as consts is either to make them global or to share an eval-able 
string that each module can locally eval as a const declaration -- blech)

Dave

On Sep 30, 2011, at 7:13 PM, Axel Rauschmayer 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.
> 
> -- 
> Dr. Axel Rauschmayer
> 
> a...@rauschma.de
> twitter.com/rauschma
> 
> home: rauschma.de
> blog: 2ality.com
> 
> 
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to