dual with statement

monarch_dodra via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 24 13:19:02 PDT 2014


On Thursday, 24 July 2014 at 17:19:36 UTC, Jay Norwood wrote:
> Anyway, a problem I ran into was if two structures had the same 
> member names, for example struct ar.r and ar.psm in this case 
> below.   In this case, there was no way for the compiler to 
> determine from which structure to get the member.

 From what I can observe, the compiler resolves the ambiguity by 
chosing the first match in terms of scope. Eg, there's shadowing. 
 From my previous code:



with (t)
{
     writeln(k); //prints t.k
     with(s)
     {
         writeln(k); //prints s.k: it is now shadowing t.k


More information about the Digitalmars-d-learn mailing list