lazy void vs int delegate() as overloads - bug or illegal use of overloading?

via Digitalmars-d digitalmars-d at puremagic.com
Sat Nov 22 07:16:41 PST 2014


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?


More information about the Digitalmars-d mailing list