On 25 July 2015 at 18:48, Walter Bright via Digitalmars-d <[email protected]> wrote: > 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.
This! I've felt this way with phobos in particular for ages. I've argued this exact case before, and it's been rejected. I much prefer static if inside functions rather than pollute the namespace (and docs) with a bunch of overloads. Also, these symbols with lots of constraints can get really long!
