return in void functions

Nick Sabalausky a at a.a
Wed Mar 4 21:22:44 PST 2009


"Walter Bright" <newshound1 at digitalmars.com> wrote in message 
news:gomvoo$1m3b$3 at digitalmars.com...
> BCS wrote:
>> IIRC D allows "return exp;" in a void function because it avoids special 
>> cases in template code.
>>
>> ReturnTypeOf!(AFn, T) fn(T)(T t)
>> {
>>    return AFn(t,t); // AFn might return void
>> }
>
> Yes, that's exactly why.

There has to be a better way to handle that.  Making "void foo(){return 1;}" 
valid code with no warning is just plain sloppy. (In fact, I've been bitten 
by that before.) 





More information about the Digitalmars-d mailing list