change 'this' pointer for structs to reference type
Steven Schveighoffer
schveiguy at yahoo.com
Tue Nov 4 05:58:10 PST 2008
"Denis Koroskin" wrote
> On Sun, 02 Nov 2008 21:59:50 +0300, Frits van Bommel
> <fvbommel at remwovexcapss.nl> wrote:
>
>> Walter Bright wrote:
>>> Frits van Bommel wrote:
>>>> I think "typeof(this) == S*" is the current situation. What they're
>>>> suggesting is "typeof(this) == ref S".
>>> Not exactly, ref is not a type constructor. typeof(this)==S
>>
>> As long as it's still a reference, that's close enough for 'this' :).
>
> Will the following code:
> typeof(this) foo = new typeof(this);
>
> work as expected?
This wouldn't work in today's compiler or tomorrow's.
What this translates to in today's compiler is:
S* foo = new S*;
new S* should return an S**, so this should fail.
with the proposed change you get:
S foo = new S;
new S should return an S*, so this should fail.
It is only classes which would work with the given code, and that won't
change.
-Steve
More information about the Digitalmars-d
mailing list