extracting namespace from a property
maian330 at gmail.com
Mon Feb 5 19:05:08 PST 2007
Brendan Eich wrote:
> intrinsic static function invoke(ns : Namespace, id : string) : Name
> new Name(ns, id);
invoke is called when Name is called as a function, right? I've seen
this used before in Enumerator - just want to make sure.
> An enumerating for-in loop or comprehension must reflect an
> enumerable property name as a Name instance if the property was
> defined with an explicit or default namespace other than public.
> Otherwise, with no or a public namespace, enumerating for-in reflects
> the name as a string per ES1-3 and existing JS implementations.
Although this helps, it would still be a hassle to have to check whether
an enumerated property n is a Name or String. I can't do n.identifier if
n is a String.
How about this: Each enumerated property n is always an instance of
Name. If n doesn't have a qualifier, n.qualifier would be null, while
n.identifier would be n's id. Thus, to get a property's id, n.identifier
would work regardless of whether n has a qualifier. typeof(Name) would
be "string". Name's prototype would be a String, so name instanceof
String is true. These two requirements should be enough to satisfy ES3
> The only detailing that remains is what Name.prototype.toString
> should do. Current thinking is something like "[namespace public
> n]::m" for the example in the Problem Statement. Comments welcome.
First, if n.qualifier is null or undefined, toString() should just
return n.identifier. Second, it doesn't really matter to me how
n.qualifier would be represented in toString().
More information about the Es4-discuss