Why does stringof not like functions with arguments?

Olivier FAURE via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 9 01:37:10 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 ()
>
> Code:
>
> import std.stdio;
>
> void FunctionWithoutArguments() {
> }
>
> void FunctionWithArguments(uint i) {
> }
>
> void main()
> {
> 	writeln(FunctionWithoutArguments.stringof);
> 	writeln(FunctionWithArguments.stringof);
> }

I'm not sure how `stringof` actually works, but it expects a 
valid expression as its prefix.

`FunctionWithoutArguments` is a valid expression (optional 
parentheses), but `FunctionWithArguments` is not.


More information about the Digitalmars-d-learn mailing list