What would be the consequence of implementing interfaces as fat pointers ?
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Tue Apr 1 13:41:44 PDT 2014
On 01/04/14 07:53, Walter Bright wrote:
> '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.
There are currently some unfortunate problems with it. Unless I've missed a
recent fix, the examples in TDPL pp.230-233 don't work as they should, because
of problems with protection attributes. :-(
> 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>.
It's fantastic that we can do this, but I have to say, having spent over a year
exploring different reference-type solutions for a successor to std.random, it
was striking how nice and simple it felt to just use classes.
More information about the Digitalmars-d
mailing list