return in void functions

Yigal Chripun yigal100 at gmail.com
Wed Mar 4 23:27:38 PST 2009


Walter Bright wrote:
> 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.

D is becoming more functional and the functional way is to use a unit 
type. why not turn D's void from C style keyword to a unit type?



More information about the Digitalmars-d mailing list