digitalmars.D - lazy void vs int delegate() as overloads - bug or illegal use of
- "Johan =?UTF-8?B?w5ZzdGxpbmci?= <johan.f.ostling gmail.com> (23/23) Nov 22 2014 Hi,
- anonymous (6/7) Nov 22 2014 I think it's a bug that the compiler accepts a lazy void
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?
Nov 22 2014
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.
Nov 22 2014