Is @property implementable?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Mar 4 07:23:48 PST 2011


On 3/4/11 2:55 AM, spir wrote:
> Unfortunately, this is not possible for structs (the 'alias this' hack
> is not subtyping (*), it's plain delegation instead).

Subtyping means many things to many people. 'alias this' is "coercive 
subtyping" by a commonly-accepted definition.

> The absence of
> struct subtyping is a big drawback. Why is it so? (**)

What would be the sketch of an alternative design?

> Denis
>
> (*) There is no common supertype, so one cannot have a func or
> collection accept both the original type and one or more customized
> types. And indeed there is no method dispatch.

If a type A uses alias this to subtype type B, the relationship is A <: 
B. Indeed there is no method dispatch, but such is not needed to discuss 
subtyping.

> (**) Some OO languages have struct-like types (stack-allocated,
> value-semantics) *with* subtyping. See eg Oberon for a wonderful example.

If you could point a link to such a treatment that doesn't require 
absorbing most of Oberon, that would be great. Thanks!


Andrei


More information about the Digitalmars-d mailing list