import concerns
Dave
Dave_member at pathlink.com
Sat Jul 8 12:15:26 PDT 2006
Andrei Khropov wrote:
> Walter Bright wrote:
>
>> There's another way - have a different kind of import declaration, say,
>> precede it with static:
>>
>> static import foo;
>>
>> which will make the symbols in foo available, but only if they are explicitly
>> qualified. Then one could access bar in foo by either:
>>
>> foo.bar();
>>
>> or:
>>
>> alias foo.bar bar;
>> bar();
>>
>> but not:
>>
>> bar(); // error, undefined symbol
>>
>> The advantage of this is it is a bit more flexible and more consistent with
>> the way the rest of D lookups work.
>
> That's what I was talking about in
> http://www.digitalmars.com/d/archives/digitalmars/D/39348.html
>
> Finally got a feedback from Walter :-)
>
> Looking forward to see this in future releases.
>
> "as" would be nice too but it's just syntactic sugar for fqn import + alias.
>
Yes, but the syntactic sugar in this case might be a lot of bang for the
buck if it's easy to implement along with allowing specific symbols to
be imported. 'as' is much easier for newbies to D to grasp, turns 2
lines of code into one *and* makes it easier for maintainers to spot as
they scan the imports (because aliases can and will be buried anywhere).
More information about the D.gnu
mailing list