delegating constructors and "this = ..."

jpf spam at example.com
Tue Feb 9 08:08:46 PST 2010


On 08.02.2010 20:45, BCS wrote:
> Hello JPF,
> 
>> Thanks for your help, I think I now understand what's going on.
>> 'this' is a mutable local reference in the constructor but the
>> constructor automatically returns the local 'this'. This explains why
>> the first case works while the second doesn't. This would also mean I
>> could do "this = this(ptr);" in the second constructor and it indeed
>> does work; With the above change the whole testcase works as expected.
> 
> Odd....
> 
>> I now just have to decide whether I'll use the "implementation specific
>> but nice syntax" way or a static function instead of public
>> constructors.
> 
> don't use implementation specific code. I suggest you file a
> bug/clarification request. If that is the way things are supposed to
> work, it should be officially sanctioned. If not, it should be removed.
> 
> -- 
> <IXOYE><
> 
> 
thanks again.
I filed a documentation bug here:
http://d.puremagic.com/issues/show_bug.cgi?id=3787
Turns out there actually is a similar compiler bug:
http://d.puremagic.com/issues/show_bug.cgi?id=780
that was already reported 2006 but it seems it didn't get much attention.



More information about the Digitalmars-d mailing list