On Monday, 2011-10-03 at 19:17 , David Herman wrote:

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


Assuming that's about Ruby like 
[symbols](http://www.ruby-doc.org/core-1.9.2/Symbol.html) or Clojure like 
[keywords](http://clojure.org/data_structures#toc8). While they are not much 
different from strings I really miss them in JS. Also I think clojure uses them 
in a very interesting way:


(use 'clojure.contrib.shell-out :as shell :reload) 

or even more intensive 

(ns com.my-company.clojure.examples.my-utils (:import java.util.Date) (:use 
[clojure.contrib.def :only (defvar-)]) (:require [clojure.contrib.shell-out :as 
shell]))

Problem with strings is that it's not always obvious weather it's intended 
argument to the function or a flag.  
 
> - 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 (mailto:a...@rauschma.de)
> > twitter.com/rauschma (http://twitter.com/rauschma)
> > 
> > home: rauschma.de (http://rauschma.de)
> > blog: 2ality.com (http://2ality.com)
> > 
> > 
> > 
> > _______________________________________________
> > es-discuss mailing list
> > es-discuss@mozilla.org (mailto:es-discuss@mozilla.org)
> > https://mail.mozilla.org/listinfo/es-discuss
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org (mailto: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