Import concerns revisited

Walter Bright newshound at digitalmars.com
Tue Jul 11 01:01:30 PDT 2006


Bill Baxter wrote:
> Just wanted to join in to make 2 quick comments:
> 
> 1) regarding "static import foo.bar"
> 
> People seem to saying the 'static' is rather meaningless as a word in this
> context.  But think of it this way:  "static" the English word means
> "stationary" "showing little changing".  In that sense a static import is an
> import that doesn't change or move the name of the module being imported.
> Although you're *importing* it (bringing it into the current namespace), you're
> not actually *moving* it into the current namespace.  foo.bar.baz remains
> foo.bar.baz, rather than being moved into the current namespace as baz.  So in
> that sense, "static" actually seems to make some sense here, I think.  (not
> saying I like it, though.  "Static" is still overused, and fqn imports should be
> the default and have the simplest syntax, since they're the safest from a SE
> standpoint.)

I thought 'static' would be ideal because it has already had its meaning 
overloaded into oblivion anyway <g>.

> 2) Regarding ways to avoid new keywords 'as' or 'from'
> 
> '=' is another option for avoiding new 'as'/'from' keywords.

Yes, using symbols is probably better than new keywords.


> I think Python's import rules are generally quite sane, and D could do far worse
> than to copy Python's rules wholesale; however, note that Python 2.5 is getting
> a new feature related to importing relative to the current module:
> http://docs.python.org/dev/whatsnew/pep-328.html

Thanks for the reference. Looks like they found that relative imports 
were a mistake, and want to move to absolute imports. D already uses an 
absolute import model, so there's no issue there for us.


> Actually -- back to the avoiding new keywords discussion -- I'm curious why you
> can't just introduce 'as' or 'from' as new keywords that are ONLY keywords in an
> import statement.  Assuming you make the grammatical construct always begin with
> 'import' the production rules for the grammar should still be simple.

The jargon for that is "context sensitive keywords". They prevent things 
like a clean lexical pass, mess up syntax highlighters, and generally 
cause trouble.



More information about the Digitalmars-d mailing list