Can we just have struct inheritence already?

Mike Franklin slavo5150 at yahoo.com
Mon Jun 10 02:12:55 UTC 2019


On Sunday, 9 June 2019 at 19:47:26 UTC, Andrei Alexandrescu wrote:

> Sadly it was meant as a generalized "is-a". Implementation 
> botched that, I'm afraid, beyond repair. We'd be better off 
> deprecating it and allowing some simple form of subtyping for 
> structs.

I like the `alias this` feature quite a lot, but it does have a 
kludgy feeling to it when you get some experience with it.  For 
example, overload rules (or lack thereof).

I don't think of it so much as an "is-a" relationship, but more 
as a kind of mixin (for lack of a better word) where you mix the 
public interface of an aggregate's field with the public 
interface of the aggregate itself.   Though, now that I think of 
it, I wonder if that can be achieved with metaprogramming 
instead.  In that case, I'd probably prefer the metaprogramming 
technique.

I'm curious, though, so I welcome more elaboration on the 
shortcomings of the implementation.

Mike




More information about the Digitalmars-d mailing list