import concerns (was Re: Historical language survey)
Kirk McDonald
kirklin.mcdonald at gmail.com
Sat Jul 8 18:59:37 PDT 2006
Sean Kelly wrote:
> Walter Bright wrote:
>
>> Kris wrote:
>>
>>> Er, that really doesn't work at all. Please ignore what I said a few
>>> minutes ago
>>> regarding this option (I really should get some sleep instead).
>>> The problem here is that, for the proposed static imports, everything
>>> must be
>>> fully-qualified with the /original import name/, and that's just
>>> plain awful for
>>> long import names. The "import as" allows one to give it a nice short
>>> name
>>> instead.
>>
>>
>> Alias also works fine for making substitutes for long, awkward names:
>>
>> import x.y.mod;
>> alias x.y.mod t;
>>
>> x.y.mod.foo(); // works
>> t.foo(); // also works
>
>
> Yup. 'as' would just be a convenience and potentially add a slight bit
> of clarity. Though I'll admit to sort of liking Kris' alternate
> interpretation where the alias prefix isn't optional.
>
>>> And, I still think the selective-import is the superior solution anyway.
>>
>>
>> Semantically, it isn't any different. It would even be implemented
>> internally using the 'alias' machinery.
>
>
> module A;
>
> void foo() {}
> void bar() {}
>
> module B;
>
> void bar() {}
>
> module main;
>
> import A.foo;
> import B.bar;
>
> foo();
> bar(); // unambiguous
>
> So not strictly the same, unless the proposal also involved always using
> a namespace qualifier?
I posted this proposal earlier, but I like it so much I'll repeat myself:
import B with bar;
bar(); // unambiguous
The point is you can list multiple names from the module without
repeating the module name:
import MyModule with foo, baz;
And "with" is already a keyword.
--
Kirk McDonald
Pyd: Wrapping Python with D
http://dsource.org/projects/pyd/wiki
More information about the Digitalmars-d
mailing list