Addition of a global namespace function?
Mark A. Ziesemer
online at mark.ziesemer.com
Fri Dec 4 08:26:57 PST 2009
On Fri, Dec 4, 2009 at 7:20 AM, Irakli Gozalishvili <rfobic at gmail.com> wrote:
> After looking at your posts, I do have a feeling that what you actually
> trying to solve is not a namespacing but modules scope encapsulation.
> Besides they way you're proposing to solve this is not really suits well for
> the interpreted language. I would recommend you to look into commonjs,
> (http://commonjs.org/, http://wiki.commonjs.org/wiki/Modules/) I think it
> solves the problem nicely without extending language itself. One more
> interesting to look at http://www.cmlenz.net/archives/2009/12/namespaces
If you or someone can show me an example of CommonJS modules being
used in a web page, it would be very beneficial to myself and many -
and may very well invalidate my entire proposal. However, I would
first need a chance to review a full, concrete example - just as
everyone has been reviewing my proposal here.
One point of my proposal that I'm unsure has received proper attention
is that the type of namespacing I mentioned is already being used
actively and increasingly online today - including in well-known
experts, such as Yahoo! UI (YUI) and jQuery. Even www.mozilla.org is
already namespacing their JS code in "org.mozilla".
Defining the exact method of the namespacing was not even meant to be
part of my proposal. For example, "jQuery.*" vs. "com.jquery.*".
However, they would all be supported by the proposed namespace
Without repeating all of my previous replies and the original
proposal, I still think that such a namespace function would be a
great benefit, even more than the other additions that have been made
extension. Maybe there is a better name for the function to use than
"namespace", in case there is concern that "namespace" should
potentially be reserved for use as a keyword or another purpose in the
Another option to consider: Without necessarily proposing such a
"namespace" function for inclusion into the base language, would there
be a way to define / standardize that if a given named-function exists
(whether it be "namespace", "createNS", etc.), that the API must be
something similar to what has been described here? My proposal to
have this standardized was so that "developer A" and "developer B"
didn't both start to add "namespace" to their next greatest script
library, where they are named the same but work differently / accept
different arguments, etc.
Mark A. Ziesemer
More information about the es-discuss