Will alias this work for classes too?

Sean Kelly sean at f4.ca
Thu Sep 13 08:26:58 PDT 2007


Janice Caron wrote:
> On 9/13/07, Jascha Wetzel <"[firstname]"@mainia.de> wrote:
>> that would be a different syntax for regular MI and is therefore
>> probably not going to happen.
> 
> "alias this" is already slated in in the Walter Andrei document.
> Walter apparently /wants/ "alias this", and it looks like it will work
> as I outlined - at least for structs. Classes? I don't know. That's
> why I asked.

If I had to guess, I'd say "alias this" will basically perform a mix-in 
of the data.  So I don't see any reason why it couldn't work for classes.

> It's not real multiple inheritance. Nobody should pretend it is. But
> it does "fake it" to a certain extent..

See this link for an example of mixin multiple inheritance:

http://www.invisibleduck.org/~sean/code/io/stream.d

It's not an approach I'd want to use regularly, but it can come in handy 
for eliminating code duplication in some instances.


Sean



More information about the Digitalmars-d mailing list