Import concerns revisited

Walter Bright newshound at digitalmars.com
Tue Jul 11 00:52:26 PDT 2006


Lionello Lunesu wrote:
> Walter Bright wrote:
>> John Reimer wrote:
>>> If you can find something
>>> equivalent to from/as (which you most certainly haven't), without 
>>> adopting new
>>> syntax, maybe we'll bite... but so far, I think using 'with' (or 
>>> from) and 'as'
>>> is an excellent contender.
>>
>> I'll repeat myself here, too <g>. The 'static import' combined with 
>> 'alias' has
>>
>>     *exactly the same semantics*
>>
>> as 'with' 'as'. The only difference between the proposals is if there 
>> are two statements or one. There is no difference in power or effect. 
>> There is nothing that one can do that the other cannot.
> 
> 
> Not true. With the static import + alias you'll have two different ways 
> to refer to the imported symbol(s), and no restriction as to which one 
> is used.

True, but I thought that was unimportant. It's not that you're likely to 
type in very.long.qualified.name by accident.

> With "as"/"from"/":"/whatever you'll have only 1 way.

Not necessarily. Read on...

> If you see "bar.foo", there's only 1 thing it can mean.

That's true regardless of whether there exists a different path to the 
symbol or not.

Like directory names in a filesystem, there can be an arbitrarily large 
number of paths to reference symbols at module scope:

--- module A ---
import module B;

--- module B ---
void foo();

--- module C ---
import A;
import B;

B.foo();
A.B.foo();



More information about the Digitalmars-d mailing list