Proposal: "void f() { return 7; }" should be illegal

Michel Fortin michel.fortin at michelf.com
Tue Sep 29 04:47:54 PDT 2009


On 2009-09-29 07:23:54 -0400, bearophile <bearophileHUGS at lycos.com> said:

>> This makes sense for things we definitely want to allow, such as:
>> void foo() { return bar(); }
>> where bar() is another void function.
> 
> If bar() is a void function then "return bar();" looks like a bug. Why 
> do you want to allow such semantically wrong situation?

It's handy in generic code because you don't need to special-case for void:

	R foo(R, A...)(A a)
	{
		return bar(a);
	}

That said, returning something other than void from a void function is 
senseless.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list