Language Size (was Re: [TLUG]: ECMAScript ("Javascript") Version 4 - FALSE ALARM)

Brendan Eich brendan at
Wed Oct 31 09:56:59 PDT 2007

On Oct 31, 2007, at 3:46 AM, Maciej Stachowiak wrote:

> I notice some seemingly duplicate features that will perhaps become
> more clear on closer reading of the spec. For instance I see all three
> of namespace, package and unit productions in the grammar. With my
> limited imagination it's hard to think of how those could be three
> interestingly different features.

What's the Sesame Street song? "... one of these things is not like  
the other, one of these things just doesn't belong."

You are not alone in wondering about these three -- this has come up  
at past TG1 meetings and we went ahead and implemented to get  
experience. Michael O'Brien has a small-device implementation that  
he's posted about here. He may have useful feedback.

This may help separate namespaces and units:

* A namespace is a qualifier on property name (a string in general in  
ES1-3). It's a prefix to apply to unqualified identifiers used by a  
block in which a 'use namespace N' pragma occurs at the top. There  
are sane rules about ordering and ambiguity errors, covered briefly  
in the overview. As you can see from the RI, namespaces are used  
heavily. One benefit is to avoid incompatible name pollution of  
unqualified identifiers in the standard objects and the global object.

* A program unit is an explicit reflection of the Program  
production's semantics from ES1-3. When you see a program unit body's  
closing brace, the steps in ES3 Chapter 10.2, plus ES4 steps like  
those, kick in. You can nest units, and a server framework can expand  
them server side when they are stated without bodies, but with  
locators that point to the body in question. This preserves accurate  
source coordinates for errors coming from nested units, and avoids  
downloading too many small files. See the proposal for more detail.

These two are genuinely different, orthogonal, and useful things, I  

* Packages are built on namespaces, and unlike program units they are  
open-ended. You can keep adding to a package (someone correct me if  
I'm wrong), by writing

package acme.widgets {

several times in a row. As the overview notes, a package has two  
namespaces, package-public and package-internal. There's an import  
directive for pulling some or all of the public names of a package  
into another scope.


-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Es4-discuss mailing list