what's so difficult about namespace?

Glenn Linderman v+python at g.nevcal.com
Wed Nov 26 02:28:53 EST 2008


On approximately 11/25/2008 11:01 PM, came the following characters from 
the keyboard of Gene:
> On Nov 26, 1:29 am, Xah Lee <xah... at gmail.com> wrote:
>   
>> comp.lang.lisp,comp.lang.functional,comp.lang.perl.misc,comp.lang.python,co­mp.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. 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. Elisp doesn't have
>> name space and it is a well known major issue.
>>
>> 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.
>> 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. I
>> 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?
>>
>> Could any compiler expert give some explanation?
>>
>> Thanks.
>>
>>   Xah
>>http://xahlee.org/
>>
>>>>     
>
> When multiple existing systems are combined, namespaces provide a
> quick way to prevent name clashes.

While the above is true, and is a benefit of name spaces, it appears the 
OP understands that issue, and is asking why languages without 
namespaces don't add them.

Speaking as someone who has written a few small compiler 
implementations, I'll just point out that when doing a particular 
implementation, there are often times more interesting or pressing needs 
to be achieved by the implementation.

Many languages have other scoping techniques that limit the need for 
global names, thus sidestepping the need for explicit namespaces, by 
reducing their benefits.

Some operating systems have limited the allowable length of global 
(linkable) names, especially in the early days of a computing platform 
(be it the early days of mainframes, minicomputers, or microcomputers 
[now called personal computers, and more powerful than many of the early 
mainframes]), which led to corresponding limits in the languages 
available on such systems.

And, absent namespaces, the user  is not left totally without 
alternative.  Many languages place no or large limits on identifier 
length, so namespace can be simulated by using "module prefixes".  When 
it is known that namespaces are not available, large scale systems 
written in those languages usually have a coding standard that suggests 
using a prefix on all global names for each separable unit of the 
program.  The team of programmers for each separable program unit, then, 
is free to innovate with names within the subset of all possible names 
having the assigned, negotiated, or claimed prefix for their global 
names.  Non-global names are usually not required to have the prefix, as 
scoping rules limit the visibility of those names, although, depending 
on the language, it may be decided that certain non-global names still 
use the prefix for some sort of consistency.

Languages that have limited length variable names (some versions of 
Basic are restricted to single character names; some versions of other 
languages have limited variables names to other lengths -- thinking 
back, 3, 6, 8, and 31 come to mind -- either in total length or 
significant length) are harder mediums in which to develop large-scale 
projects.  Newer versions of languages containing most of the 
length-limited-names tend to increase the allowable length, and/or 
introduce namespaces, or modules (which oftentimes produces multiple 
namespaces as a side-effect).

Multi-purpose languages today are mostly designed to cross-platform, 
have modular compilation facilities necessitating linking of global 
names, and recognize the needs of separate compilation, linking, and 
name collisions, and provide some mechanism for avoiding name 
collisions, either namespaces, or modules that provide namespaces.  Most 
operating systems and linkers provide for long names.  Life is good.  
There are still throwbacks, and still small applications, and still 
languages that don't offer such facilities.

-- 
Glenn -- http://nevcal.com/
===========================
A protocol is complete when there is nothing left to remove.
-- Stuart Cheshire, Apple Computer, regarding Zero Configuration Networking




More information about the Python-list mailing list