change 'this' pointer for structs to reference type

Moritz Warning moritzwarning at web.de
Sun Nov 2 11:26:23 PST 2008


On Sun, 02 Nov 2008 00:01:24 -0700, Walter Bright wrote:

> Andrei suggested this change, and I think it is a great idea. D ought to
> be moving away from pointers for routine work, and this would make a lot
> of sense.
> 
> It would entail some changes to user code, mostly when dealing with the
> opCmp and opEquals member functions. The function signatures for them
> would be changed to opCmp(ref const S).

It's not clear to me what the effect would be on the usage.

struct Foo
{
   int OpIndex(size_t){}
}

Foo foo = new Foo();
foo[42];

Could we do call opIndex now because this of Foo is a reference?
It would be nice.
But it might be "ref Foo foo = new Foo();" because it bites "Foo foo;" 
otherwise.

Or am I off the track?



More information about the Digitalmars-d mailing list