Import concerns revisited

Kirk McDonald kirklin.mcdonald at gmail.com
Sun Jul 9 13:21:23 PDT 2006


Sean Kelly wrote:
> Kirk McDonald wrote:
>> 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.
> 
> Why is that?  Wouldn't the old import syntax still be available?  Or are 
> you concerned about the addition of 'from', 'with', or 'as' as keywords?

No, I am saying I prefer pure fully-qualified imports, the way Python 
does it. I'm saying it would have been better if D had done this originally:

module foo;
int bar = 20;

module mymodule;
import foo;

writefln(bar); // ERROR!
writefln(foo.bar); // Okay

The point of FQN imports is that you cannot introduce a name into the 
current namespace without explicitly saying (at least once) where it 
came from.

But this would obviously break existing code if it were changed now. 
Therefore, a new, different form of "import" is required to mean FQN 
import. I suggested "static import," with the reaction we have seen.

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



More information about the Digitalmars-d mailing list