Import proposals (Discuss)

Regan Heath regan at netwin.co.nz
Sun Jul 9 21:45:44 PDT 2006


On Mon, 10 Jul 2006 03:43:07 +0000 (UTC), Tyro <Tyro_member at pathlink.com>  
wrote:
> In article <optcgd2ruo23k2f5 at nrage>, Regan Heath says...
>>
>> More random musings.. if we have a syntax that reads:
>>
>> import std.stdio as foo;
>>
>> which imports the symbols in std.stdio into a namespace called 'foo',
>> preventing access as just "writefln" requiring "foo.writefln" then what
>> happens in a case like this:
>>
>> --[a.d]--
>> import std.stdio;
>> template foo { writefln("Hello World"); }
>>
>> --[b.d]--
>> import std.stdio as foo;
>>
>> void main() {
>>   mixin foo;
>> }
>>
>> ?
>>
>> Regan
>
>
> Well, as far as I can see you should get an error telling you that foo  
> is not a
> template. Now if you meant for the first line in [b.d] to read:
>
> import a as foo;
>
> Then I think we have a different issue. But since the programmer when  
> through
> the trouble of importing into a named scope, this should be a no braner.  
> In
> order to access the foo template , he needs to code explicitly.
>
> :--[b.d]--
> :import a as foo;
> :
> :void main() {
> :   mixin foo;     // Error, foo is not a template
> :   mixin foo.foo; // Ok
> :}

Ooops, my bad example, what I meant was:

--[a.d]--
import std.stdio;
template foo { writefln("Hello World"); }

--[b.d]--
import std.stdio as bar;
import a;

void main() {
   mixin foo;
}

I accidently called the template and import named scope the same thing.

Regan



More information about the Digitalmars-d mailing list