November 22, 2014 lazy void vs int delegate() as overloads - bug or illegal use of overloading? | ||||
|---|---|---|---|---|
| ||||
Hi,
I'm trying to do a version of this:
import std.stdio;
void main()
{
execute(writeln("Hello, world"));
execute({return 5;});
}
void execute(int delegate() f)
{
writeln("f is delegate, returning ", f());
}
void execute(lazy void f)
{
writeln("f is lazy void");
f();
}
which causes the compiler to respond: Error: void does not have a default initializer.
I've narrowed it down to the fact that the function "execute" is overloaded - if I give them different names, it works fine.
My question is, is this a bug or is it an intentionally disabled way of overloading the functions?
| ||||
November 22, 2014 Re: lazy void vs int delegate() as overloads - bug or illegal use of overloading? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Johan Östling | On Saturday, 22 November 2014 at 15:16:42 UTC, Johan Östling
wrote:
> void execute(lazy void f)
I think it's a bug that the compiler accepts a lazy void
parameter. It errors out on a non-lazy void parameter with
"cannot have parameter of type void". lazy shouldn't somehow
enable void parameters.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply