Goofy code means opportunities in language design

Avrina avrina12309412342 at gmail.com
Thu Sep 17 15:27:09 UTC 2020


On Thursday, 17 September 2020 at 14:10:58 UTC, Andrei 
Alexandrescu wrote:
> Oh boy. That's a really awkward way to say, "do slicing exactly 
> like source does". Should be something like:
>
>     static if (hasSlicing!R)
>     {
>         static if (hasMember!(R, "opDollar"))
>             alias opDollar = source.opDollar;
>         alias opSlice = source.opSlice;
>     }

This does something different. It returns the source range, and 
not the encapsulating range (Cache in this case).

> Even better, as it seems common to say "forward if this other 
> guy implements it:
>
>     try alias opDollar = source.opDollar;
>     try alias opSlice = source.opSlice;

Same problem as above. Also don't like "try" here, though it may 
fit with the english definition, it doesn't fit with D's use with 
exceptions. Don't want a situation like `static` with C.


More information about the Digitalmars-d mailing list