Feature Request: make void a value type

Jarrett Billingsley kb3ctd2 at yahoo.com
Mon Dec 3 13:35:23 PST 2007


"downs" <default_357-line at yahoo.de> wrote in message 
news:fj1das$150r$1 at digitalmars.com...
> Jarrett Billingsley wrote:
>> "downs" <default_357-line at yahoo.de> wrote in message
>> news:fj1cc2$13c3$1 at digitalmars.com...
>>> Proposal: to allow us to treat void as a value type.
>>> What this would allow:
>>> * simplifying templates that differ between return type, i.e. static if
>>> (is(ReturnType!(C)==void)) param(); else return param();
>>
>> This is already possible.  Return statements with expressions in 
>> functions
>> that return void will be evaluated and their results thrown away.
>>
> [snip example]
>
> Yes, but what I want is actually being able to _return an expression that 
> *evaluates to void*_. Not the same.
> --downs

You need to try things!

void f()
{
    writefln("f!");
}

void g()
{
    return f();
}

void main()
{
    g();
}

Works just fine. 





More information about the Digitalmars-d mailing list