Namespaces as Sugar (was: complexity tax)

Brendan Eich brendan at mozilla.org
Tue May 27 00:48:29 PDT 2008


On May 26, 2008, at 10:19 PM, Brendan Eich wrote:

> I then thought to allow as how it's not shared by ES3.1, but I really
> don't know. ES3.1 has no notion of namespace. This spun-out thread
> "Namespaces as Sugar" might be a proposal aimed at 3.1 that's meant to
> show no need for ES4's namespace semantics, but it does not address
> the "unqualified import" use-case, which requires new semantics in
> ES4 not in ES3 or ES3.1. We need to agree or disagree that this use-
> case matters enough to justify the extra semantics.

I'm still not sure why namespaces keep coming up for ES3.1. This  
started in April 2007, with an idea to treat obj["ns::prop"] as the  
same as obj.ns::prop in ES4 -- this makes obj.ns::prop not just a  
syntactic shorthand, and it reinterprets ES1-3 property names  
incompatibly. See the minutes I cited earlier in this thread.

There was a strong "no new syntax" principle in effect for 3.1 at the  
time. Soon enough this idea evolved to allow that some new syntax  
might be a good thing, so maybe obj.ns::prop and some kind of first- 
class namespace (denoted ns in the example) could be added. Users  
targeting all browsers would have to use obj["ns::prop"], but when  
ES3-only browsers dropped from servers' user-agent radar, scripts on  
those servers could start using obj.ns::prop.

Now it seems you are exploring desugaring part, but not all, of ES4  
namespaces to ES3 semantics, with a little sugar and some convention  
(or other) for property naming, but no first-class namespace object,  
so no internal namespaces -- rather, injection attacks -- and no  
unqualified import.

Exploring is fine, don't let me discourage you. I don't mean to  
complain. But I hope there's no mission creep going on for ES3.1 that  
would try to add primitives (the fewest possible) for every new  
facility in ES4 not in ES3.1. That is a good way to delay 3.1 and 4,  
and multiple design by committee (if not square it, per Metcalfe's Law).

Keep 3.1 small. That's my motto, and Doug's too I'm sure. Sound right?

/be



More information about the Es4-discuss mailing list