Behaviour of alias this changed

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Tue May 8 10:12:32 PDT 2012


My guess is - it's a bug, because alias this is supposed to be always
less prioritized, then actual members.

On Tue, May 8, 2012 at 9:11 PM, H. S. Teoh <hsteoh at quickfur.ath.cx> wrote:
> I have some code along these lines:
>
>        struct S {
>                short[4] data;
>                alias this data;
>
>                string toString() { ... }
>        }
>        ...
>        S s;
>        writeln(to!string(s));
>
> In dmd 2.059 (I believe) and earlier, this calls S.toString(). However,
> in git dmd, this calls data.toString() instead.
>
> I'm just curious about the rationale for this change, and whether
> there's a way to override the toString() call so that it always calls
> S.toString()?
>
>
> T
>
> --
> To err is human; to forgive is not our policy. -- Samuel Adler



-- 
Bye,
Gor Gyolchanyan.


More information about the Digitalmars-d mailing list