Identifier resolution, the great implementation defined mess.

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 21 16:37:31 PDT 2014


On Sunday, 21 September 2014 at 20:05:57 UTC, Walter Bright wrote:
> On 9/20/2014 10:29 PM, deadalnix wrote:
>> DMD does very bizarre things. I think I should write a DIP, 
>> but time is always
>> running low...
>>
>> Free goodie: when you import, all symbol are resolved via the 
>> expected import
>> resolution mechanism. All ? No, the root package is imported 
>> in the local scope.
>>
>> foo(int a) {
>>   import a.b.c;
>>   // a is now a package and not the parameter a anymore.
>> }
>
> What's bizarre about it? You declared a package symbol 'a' in 
> the local scope with the import declaration.
>

Because this is not consistent with module level import and that 
is not consistent with how local shadowing works.

IMO you should fallback to import if local lookup failed.


More information about the Digitalmars-d mailing list