Namespaces in ECMA

Alexandre Bergel Alexandre.Bergel at hpi.uni-potsdam.de
Sun Jul 15 05:02:29 PDT 2007


Hello,

Few questions about Namespaces are buzzing me. Please, if you are the  
right person to address those questions, feel free to forward this  
email.

The notion of namespace of ECMA 4 is very interesting. I spent some  
time in reading the new javascript description [1]. I try to  
understand whether a "stack of namespace" is present or not at  
runtime. Let's assume the following code:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
namespace V2;

class Component {
   function paint () {print("Component paint")}
   function update () {this.paint()}
   V2 function paint () {print("Component paint V2")}
}

use namespace V2
var c = new Component();
c.update(); // Does it print V2 or not ?
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

update() is defined in the default namespace, therefore I imagine  
that the default implementation of paint() is invoked. "V2" should  
not be displayed, however, would you mind to confirm ?

I tried to execute this code on the interpreter es4 for Macosx (intel  
version on http://www.ecmascript-lang.org/download.php), but the "use  
namespace" clause is not accepted. For example, the following code  
cannot be parsed:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
namespace N1
namespace N2
N1 var x : int = 10
N2 var x : String = "hello"
use namespace N1
print(x)  // print 10
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Is there a chance to get a fixed interpreter ?

Best regards,
Alexandre

[1] http://developer.mozilla.org/es4/spec/chapter_12_namespaces.html


-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.






More information about the Es4-discuss mailing list