Import concerns revisited

Kirk McDonald kirklin.mcdonald at gmail.com
Sun Jul 9 12:21:05 PDT 2006


Sean Kelly wrote:
> I can tell you right now that I don't like the way "static import" 
> looks, and I'm not terribly happy that I would need to continue 
> maintaining a separate "alias" line for each import.  And that won't 
> change with experience.  Might I ask why "static import" was chosen as 
> the syntax for this feature?

I'm afraid that it was my suggestion originally:
http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/39407

> Prepending "static" to "import" doesn't 
> convey any meaning to me as a user about what's actually happening, so I 
> can only conclude that this syntax was chosen because it's easy to 
> implement and doesn't add any new keywords to the language?  

That was in fact why I suggested it. Reaction to it has been so negative 
that I'm wishing I'd thought of something else. :-)

> I don't 
> suppose any subset of Kris' suggestions could be implemented for 
> comparison?  Or perhaps GDC would make a more appropriate testing ground 
> for user-driven feature requests?  You've suggested we try out "static 
> import" for a while, but that hardly puts Kris' proposal on equal 
> footing for comparison.  And I personally don't want to feel I'm 
> settling for "static import" simply because it was the only option we 
> were offered.

I actually feel the best solution is full-on Python-style imports, with 
"from" and "as", and "import" meaning FQN import. The only thing I think 
is stopping it is the introduction of two new keywords and the fact that 
this change in semantics would totally break essentially all existing 
code. By suggesting "static import" it leaves the old meaning for 
import, which does not break quite as much code. Alternatively, we could 
introduce some other new keyword like "qualified" to make "qualified 
import", though this isn't really that nice *either*.

Another suggestion for a way to represent FQN import that someone had 
was an "fqnimport" keyword (quite unlikely to be used in any existing code).

-- 
Kirk McDonald
Pyd: Wrapping Python with D
http://dsource.org/projects/pyd/wiki



More information about the Digitalmars-d mailing list