import concerns (was Re: Historical language survey)

Sean Kelly sean at f4.ca
Sat Jul 8 00:01:35 PDT 2006


Walter Bright wrote:
> kris wrote:
>>
>> module main;
>>
>> import a;
>> import b as other;
>>
>> void main()
>> {
>>     foo();       // a.foo
>>     other.foo()  // b.foo;
>> }
>>
>> In this trivial example, you could do the same with an alias. However, 
>> an alias would /potentially/ be needed for every symbol within module 
>> b, whereas the "as" handles all of that cleanly. Consider the effort 
>> to manually alias each symbol from each imported modules that may 
>> potentially change over time? Import "as" does it cleanly instead.
> 
> What I don't like about that proposal is the same reason you didn't like 
> the warning proposal above - you'd be forced to fully qualify all 
> references to names within b.

And that's why I suggested it could be syntactic sugar for an alias 
declaration instead, thus making the qualifier optional.  That said, 
it's worth noting that "other" as a user-chosen alias will likely be far 
shorter than the package/module name they represent.  I would much 
rather say "sql.connection" than "some.guys.fancy.sql.connection."

>> However, I think this next option is preferable:
>>
>>> What can also be done is extend the import declaration to allow the 
>>> .'s to continue so that specific symbols can be imported.
>>
>> Now that would be great. I believe selective-importing (as an option) 
>> would be a boon in a number of ways ~ and would resolve this issue 
>> quite elegantly.
> 
> I like this one better, too.

Same here.


Sean



More information about the Digitalmars-d mailing list