Behaviour of alias this changed
Ali Çehreli
acehreli at yahoo.com
Tue May 8 10:15:00 PDT 2012
On 05/08/2012 10:11 AM, H. S. Teoh 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
>
Just a guess: It could be related to const-correctness improvements. Try
defining S.toString() as const.
Ali
--
D Programming Language Tutorial: http://ddili.org/ders/d.en/index.html
More information about the Digitalmars-d
mailing list