On 2008-11-26, Xah Lee <[EMAIL PROTECTED]> wrote:
> comp.lang.lisp,comp.lang.functional,comp.lang.perl.misc,comp.lang.python,comp.lang.java.programmer
>
> 2008-11-25
>
> Recently, Steve Yegge implemented Javascript in Emacs lisp, and
> compared the 2 languages.
>
> http://steve-yegge.blogspot.com/
> http://code.google.com/p/ejacs/
>
> One of his point is about emacs lisp's lack of namespace.
>
> Btw, there's a question i have about namespace that always puzzled me.
>
> In many languages, they don't have namespace and is often a well known
> sour point for the lang. For example, Scheme has this problem up till
> R6RS last year.

Scheme hasn't officially supported breaking a program into multiple files until
R6RS. If the language is defined in terms of one translation unit, it doesn't
make sense to have a namespace feature.

> PHP didn't have namespace for the past decade till
> about this year. Javascript, which i only have working expertise,
> didn't have namespace as he mentioned in his blog.

Javascript programs are scanned at the character level by the browser as part
of loading a page.  So there are severe practical limitations on how large
Javascript programs can be.

Namespaces are useful only in very large programs.

> Elisp doesn't have
> name space and it is a well known major issue.

C doesn't have namespaces, and yet you have projects like the Linux kernel
which get by without this.

Given that the Linux kernel can do without namespaces, it's easy to see how
Javascript and Elisp can survive without it.

> Of languages that do have namespace that i have at least working
> expertise: Mathematica, Perl, Python, Java. Knowing these langs
> sufficiently well, i do not see anything special about namespace. The
> _essence_ of namespace is that a char is choosen as a separator, and
> the compiler just use this char to split/connect identifiers.

The essence of a true namespace or package system or whatever is that you can
establish situations in which you use the unqualified names.

You can emulate namespaces by adding prefixes to identifiers, which is
how people get by in C.

In C, you can even get the functionality of short names using the preprocessor.

I have done this before (but only once). In a widely-used public header file, I
prefixed all of the names of struct members (because struct members are not
immune to clashes: they clash with preprocessor symbols!)

  struct foo {
    int foo_category;
    time_t foo_timestamp;
    /* ... */
  }

Inside the implementation module, I made macros for myself:

  #define category foo_category
  #define timestamp foo_timestamp

In this way, I didn't have to edit any of the code in order to move the struct
members into the namespace. Expressions like ``pf->category'' continued to work
as before.

> Although i have close to zero knowledge about compiler or parser, but
> from a math point of view and my own 18 years of programing
> experience, i cannot fathom what could possibly be difficult of
> introducing or implementing a namespace mechanism into a language.

The same things that make it difficult to add anything to a language, namely
the stupid way in which languages are designed to get in the way of extension.

What would it take to add namespaces to C, for instance?

If you have any proposal for a new C feature, the ISO C people encourage you to
develop a proof-of-concept, which means: hack it into an existing
implementation to demonstrate that it's feasible.

If you need new syntax, hacking it into an implementation means hacking it into
the parser. Everyone who wants to experiment with your feature needs to get
your compiler patches (for GCC for instance) and rebuild the compiler.

The process is painful enough that it's only worth doing if it solves something
that is perceived as being a critical issue.

> do not understand, why so many languages that lacks so much needed
> namespace for so long? If it is a social problem, i don't imagine they
> would last so long. It must be some technical issue?

I recently read about a very useful theory which explains why technologies
succeed or fail. 

See: 
http://arcfn.com/2008/07/why-your-favorite-programming-language-is-unpopular.html

The perceived crisis which namespaces solve is not sigificant enough relative
to the pain of adoption.  No, wrong, let's restate that. Programmers do use
namespaces even when there is no language feature. It's not about adoption of
namespaces, but adoption of proper support for namespaces.  Not using
namespaces is a crisis in a software project, but (at least in the perception
held by many programmers) that crisis is adequately mitigated by using a naming
convention.  Proper namespaces only address the small remaining vestiges
of the original crisis.

Thus: the perceived crisis which is solved by properly incorporating namespaces
into a programming language (rather than living with a prefix-based emulation)
is not significant enough relative to the perceived pain of adopting proper
namespaces into the programming language. 

However, proper namespaces, if available, are easier to use than prefixed
identifiers, and not diffcult to adopt. So if someone has gone to the trouble
of making them available in the programming language, then they do get used.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to