[Issue 12578] Allow local function overloading

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Apr 15 05:38:06 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12578

Philpax <phillip at philliplarkson.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |phillip at philliplarkson.com

--- Comment #6 from Philpax <phillip at philliplarkson.com> ---
My use-case for this was implementing a toString function for different types
in my view template (i.e. embedded D in a display layout) code. Without it, I
had to name each variant of the function something unique, which led to
function names like toStringSerializeNode(serializeNode) and
toStringDeserializeNode(deserializeNode) before I switched to the suggested
static struct solution.

As was mentioned, this would also be helpful in unit tests and other areas in
which helper functions for multiple types would be convenient. I personally
believe it's incongruous to not support overloading in local scope; D treats
local functions similarly to global functions in all the cases I've
encountered, but this seems like one case where the behaviour doesn't match up.

--


More information about the Digitalmars-d-bugs mailing list