Why packages and namespaces?

Peter Michaux petermichaux at gmail.com
Mon Jan 28 00:04:44 PST 2008

Thanks for reposting Brendan's explaination. I did look around but
didn't find it.

On Jan 27, 2008 11:45 PM, liorean <liorean at gmail.com> wrote:
> I think Brendan had a nice explanation of that some time back:
> On 10/08/2007, Brendan Eich <brendan at mozilla.org> wrote:
> > There's more work to do, including rationalizing and minimizing
> > concepts including units and packages.  A couple of notes:
> >
> > A package is a named pair of namespaces (public and internal), some
> > rules for using those namespaces within the package body, and some
> > special forms for importing names from the package's public namespace.


Here is a concrete problem. I tried this in the reference implementation...

package org {
  public var ecmascript = {a: 1};

package org.ecmascript {
  public var a = 2;

org.ecmascript.a   // 2

How do I access the "org.ecmascript.a" that has value 1?

How does the programmer writing the org package know that his "a" will
be clobbered by the "a" in the  org.ecmascript package? Isn't the
point of packages to avoid this type of problem?


More information about the Es4-discuss mailing list