On 04/14/14 19:51, Andrej Mitrovic wrote: > On Monday, 14 April 2014 at 17:48:31 UTC, Adam D. Ruppe wrote: >> On Monday, 14 April 2014 at 17:45:52 UTC, Ryan Voots wrote: >>> src/yage/core/misc.d(164): Error: e2ir: cannot cast this of type S to type >>> void* >> >> >> Try taking the address of this before casting it. So more like >> >> cast(void*)&this >> >> >> IIRC in D1 this was a pointer, whereas in D2 this is a reference. You can't >> cast a reference to pointer directly. > > That's not true. > > And I think the issue in his diagnostic is that he used it with a struct. You > can't cast 'this' of a struct to a pointer (you'd have to use &this), but you > can cast a class reference to a pointer.
It *is* true. Classes are /reference types/, not references to classes. [There's no such thing as a "class payload" in D. Also, you can have a D-ref to a D-class.] D doesn't have "true" references, just a storage-class based hack, that only supports a small subset of ref functionality. But these pseudo-refs still act as the objects they point to. artur