[Issue 15899] Tuple.toString not recognized as a function with isSomeFunction

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Apr 8 16:20:48 PDT 2016


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

ag0aep6g at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g at gmail.com

--- Comment #1 from ag0aep6g at gmail.com ---
std.typecons.Tuple.toString is not a function. It's a template. And the
documentation says so [1]. So I think it's expected that isSomeFunction [2]
returns false, as it's only supposed to accept functions, function pointers,
and delegates.

I'm not sure why toString is a template, though. It's wrapped twice in
zero-parameters templates, with no comment as to why. There may have been bugs
or language limitations in the past that made this necessary. But now, Tuple
being a template should be enough to trigger attribute inference for its
methods, and templates and non-templates should be able to coexist in an
overload set.

So it may be possible to just remove the `template toString()` and the extra
empty parentheses from `string toString()()`. Then isSomeFunction would return
true for Tuple.toString.


[1] http://dlang.org/phobos/std_typecons.html#.Tuple.toString
[2] http://dlang.org/phobos/std_traits.html#isSomeFunction

--


More information about the Digitalmars-d-bugs mailing list