On Sat, 22 Oct 2011 03:21:09 +0000, Sean Silva wrote:

> I'm struggling with this on 4 fronts:
> 
> 1. What is `this`, when opAssign is called off of the type? (does it
> even make sense to call a member function without an instance?)

Please file a bug on http://d.puremagic.com/issues/

The example doesn't even compile:

Error: cannot implicitly convert expression (this) of type S to S*

> 2. The return value of opAssign is `S*`, so it would seem that `t` is
> assigned a pointer value?

The correct information is:

t=s is defined to be semantically equivalent to:

t.opAssign(s)

which means a signature of just

void opAssign(ref const S rhs) {
    //...
}

> 3. What is `tmp`, just another stack allocated instance of S?

I think it is just an example of something you might do.

> 4. What is the syntax for explicitly calling the destructor? (In C++, it
> is tmp.~S(), but in D would it be tmp.~this() or what?)

You don't. If you want to destroy use, clear(s);

Reply via email to