More operators inside `is(...)` expressions

Adam D. Ruppe destructionator at gmail.com
Mon Aug 24 12:34:13 UTC 2020


On Monday, 24 August 2020 at 12:28:27 UTC, Stefan Koch wrote:
> 2) Adding a special syntax for what I perceive to be an 
> uncommon case

This is a very common case because void is frequently special 
cased. You cannot have a local variable of type void meaning any 
time you want to work with a generic function return value, you 
can't just be like `T ret = call(); return ret;`, you must check 
if T != void before doing that.

What I usually do though is static if(is(T == void)) call(); else 
{ ret = call(); /* process ret */ return ret; } but it is 
obnoxious to duplicate that call every time still.

Lots of Phobos things also return void as the special case of 
"not found".

What I'd love is if we didn't have to special case void all the 
time... but we do, making some variant of this specific check 
pretty common.


More information about the Digitalmars-d mailing list