what's so difficult about namespace?
Xah Lee
xahlee at gmail.com
Wed Nov 26 11:55:17 EST 2008
Xah Lee wrote:
> i cannot fathom what could possibly be difficult of
> introducing or implementing a namespace mechanism into a language.
Joshua Cranmer wrote:
>> Namespaces go to the very core of a language, name resolution.
>> Retroactively adding such a feature is extremely difficult because there
>> is a strong chance of accidentally breaking existing code.
Xah Lee wrote:
> > could you give some technical detail on this?
>
> > i don't know compiler so am probably being foolish here... but i
> > suppose ultimately name resolution and storage at heart is something
> > like a hashtable... namely,
>
> > put ‹identifier 1› table
> > put ‹identifier 2› table
>
> > and lookup is just
>
> > retrieve ‹identifier› table
>
> > and now suppose we introduced namespace, so i imagine the compiler
> > simply just concat namespace component befor put, and split before
> > retrieve?
Steve Holden wrote:
> And therein lies the danger of imagination.
> Typically the namespace components are looked up one by one, so for
>
> this.that.theother
>
> first "this" will be looked up and (hopefully) yield an object with a
> namespace, which will then be searched for "that", yielding another
> object with a namespace in which "theother" can be looked up. That's
> certainly how it works in Python:
yes, but Steve, what is your point?
The question is, what is the technical difficulty, if any, of
introducing namespace into a existing language.
You pointed out that identifier lookup at least from the perspective
of language user is somewhat like a tree walking processing. However,
that does not answer the main question.
Xah
∑ http://xahlee.org/
☄
More information about the Python-list
mailing list