Rant after trying Rust a bit

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 25 02:34:29 PDT 2015


On 7/25/2015 2:14 AM, Jonathan M Davis wrote:
> I do think that it can make sense to put very similar overloads in a single
> function with static if branches like you're suggesting, but I do think that
> it's a bit of a maintenance issue to do it for completely distinct overloads -
> especially if there are several of them rather than just a couple. But it's
> still possible to combine their template constraints at a higher level and have
> overloaded functions rather than simply using static ifs.

I also sometimes see:

    void foo(T)(T t) if (A && B) { ... }
    void foo(T)(T t) if (A && !B) { ... }

The user should never have to see the B constraint in the documentation. This 
should be handled internally with static if.


More information about the Digitalmars-d mailing list