DIP66 - Multiple alias this

Meta via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 28 16:12:20 PDT 2014


On Tuesday, 28 October 2014 at 22:55:24 UTC, IgorStepanov wrote:
> You may see isFloatingPoint declaration in traits.d:
> enum bool isFloatingPoint(T) = is(FloatingPointTypeOf!T) && 
> !isAggregateType!T;
>
> This template explicitly says that T shouldn't be an aggregate 
> type. Thus
> std.math.isNaN(X)(X x) if (isFloatingPoint!X)
> shouldn't accept a struct.

Although alias this is supposed to denote subtyping, here is a 
violation of the Liskov Substitution Principle; although S is a 
subtype of float, there are some cases where it's invalid to 
substitute an S for a float. This seems like a problem with alias 
this to me. As S is aliased to float, typeof(s.val) should be 
passed to isFloatingPoint if passing S fails.


More information about the Digitalmars-d mailing list