@noreturn property

Iain Buclaw ibuclaw at ubuntu.com
Thu Oct 21 17:06:09 PDT 2010


== Quote from Leandro Lucarella (luca at llucax.com.ar)'s article
> bearophile, el 21 de octubre a las 17:35 me escribiste:
> > Nick Sabalausky:
> >
> > > One of the nice things about that is you don't have to provide a "fake"
> > > return type. For instance, with your "@noreturn": "@noreturn int foo()"
> > > would be legal, but wouldn't make any sence. And in a way, even "@noreturn
> > > void foo()" isn't great since a "void" return value suggests that it at
> > > least returns.
> >
> > I suggest to keep things simpler, minimize changes to other parts of
> > D, and avoid creating new keywords for this very minor feature, and
> > allow only the signature:
> > @noreturn void somefunctioname(...)
> >
> > So this is an additive change to D2, and may be added later.
> Exactly, this is just an optimization, that's why for me is fine with
> a pragma. It would be nice to use a pragma that is understood by all the
> compilers (even when all the compilers should not be forced to take
> advantage of it). Same thing for inline and other GCC attributes that
> seems good for optimizations.

I see it as a little more than just an optimisation; also a way to tell the
compiler that the function you are calling should be treated as a halt statement
if found at the end of a function body (as assert(0) is).

Regards
Iain


More information about the Digitalmars-d mailing list