DIP16: Transparently substitute module with package

F i L witte2008 at gmail.com
Fri Mar 30 12:55:34 PDT 2012


On Friday, 30 March 2012 at 18:15:57 UTC, Brad Anderson wrote:
> On Fri, Mar 30, 2012 at 12:06 PM, Andrej Mitrovic <
> andrej.mitrovich at gmail.com> wrote:
>
>> On 3/30/12, Andrei Alexandrescu 
>> <SeeWebsiteForEmail at erdani.org> wrote:
>> > Destroy!
>>
>> "That means a program that imports std.algorithm may use 
>> "std.sort"
>> for the symbol "std.algorithm.sort"."
>>
>> That's quite interesting. Would that also mean that you could 
>> do:
>> import std.algorithm;  // has indexOf
>> import std.string;  // has indexOf
>> void main() {
>>    string.indexOf("foo", "foo"); -> std.string.indexOf
>> }
>>
>>
> I was actually kind of surprised when I found out this doesn't 
> work.  It
> seems so natural to resolve ambiguity using as little context 
> as necessary.

Ya that was the behavior I expected as well. Would be great if it 
worked like that. Just back trace the reference until the 
ambiguity is resolved.


// -----

Also, I'm probably missing something here, but I never understood 
why importing a package doesn't work like it does in 
Actionscript/Java/others...

import foo.bar.*; // everything
import foo.bar.all; // custom

That makes a lot of sense to me.



More information about the Digitalmars-d mailing list