Namespaces in ECMA

Alexandre Bergel Alexandre.Bergel at
Sun Jul 15 05:02:29 PDT 2007


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

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, 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 Bergel

More information about the Es4-discuss mailing list