What would be the consequence of implementing interfaces as fat pointers ?
Walter Bright
newshound2 at digitalmars.com
Mon Mar 31 22:53:20 PDT 2014
On 3/31/2014 10:02 PM, Manu wrote:
> It's a really common pattern, it's obviously very useful, but it's surprising to
> me that people think that it's like, 'cool'.
> I get why it's done, and it's cool that D can do this (I use it a lot in my
> code), but I don't feel it's particularly elegant.
'alias this' is inelegant (sorry Andrei) but it was designed for precisely this
purpose - being able to use a struct to wrap any other type, and forward to and
override behaviors of that type. Nobody has found a better way.
Fortunately, the inelegance can be encapsulated within that type, and the user
of the type need not be even aware of it.
Remember my halffloat implementation? It relied on 'alias this' to work. Just
try doing that in C++ <g>.
More information about the Digitalmars-d
mailing list