@noreturn property

Rainer Deyke rainerd at eldwood.com
Thu Oct 21 19:44:03 PDT 2010


On 10/21/2010 11:37, Iain Buclaw wrote:
> Not sure what you mean when you say that void has only one possible value. To me,
> 'void' for a function means something that does not return any value (or result).
> Are you perhaps confusing it with to, lets say an 'int' function that is marked as
> noreturn?

A 'void' function returns, therefore it conceptually returns a value.
For generic programming, it is useful to treat 'void' as a type like any
other, except that it only has one possible value (and therefore encodes
no information and requires no storage).  If this is not implemented in
D at the moment, it should be.

auto callFunction(F)(F f) {
  return f();
}

void f() {
}

callFunction(&f);


-- 
Rainer Deyke - rainerd at eldwood.com


More information about the Digitalmars-d mailing list