Rant after trying Rust a bit
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jul 25 01:48:42 PDT 2015
On 7/24/2015 11:10 PM, Jonathan M Davis wrote:
> So, maybe we should look at something along those lines rather than
> proliferating the top-level function overloading like we're doing now.
Consider the following pattern, which I see often in Phobos:
void foo(T)(T t) if (A) { ... }
void foo(T)(T t) if (!A && B) { ... }
from a documentation (i.e. user) perspective. Now consider:
void foo(T)(T t) if (A || B)
{
static if (A) { ... }
else static if (B) { ... }
else static assert(0);
}
Makes a lot more sense to the user, who just sees one function that needs A or
B, and doesn't see the internal logic.
More information about the Digitalmars-d
mailing list