Why does stringof not like functions with arguments?

Biotronic via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 9 02:02:33 PDT 2017


On Wednesday, 9 August 2017 at 01:39:07 UTC, Jason Brady wrote:
> Why does the following code error out with:
>
> app.d(12,10): Error: function app.FunctionWithArguments (uint 
> i) is not callable using argument types ()

Like Olivier said, stringof expects a valid expression. There are 
a few other options:

module foo;
import std.traits;
pragma(msg, bar(3).stringof);           // prints "bar(3)"
pragma(msg, (&bar).stringof);           // "& bar"
pragma(msg, fullyQualifiedName!bar);    // "foo.bar"
pragma(msg, __traits(identifier, bar)); // "bar"
void bar(int n) {}


More information about the Digitalmars-d-learn mailing list