On 14-05-2012 14:13, Alex Rønne Petersen wrote:
On 14-05-2012 13:53, bearophile wrote:
Alex Rønne Petersen:
In writing unwinding mechanisms for my VM, I find myself actually
needing some sort of @noreturn function attribute that would tell the
compiler that the function does not return,
Maybe Walter will listen you more if you show an example of where/why
you would use @noreturn.
Bye,
bearophile
As a very simple example, consider an intrinsic in a virtual machine:
extern (C) int do_some_work(VMContext ctx, int value)
{
if (value != 42)
ctx.engine.raiseException("Bad value!");
/* no can do; assert(false) needed here */
return value;
}
Note that raiseException() unwinds the native stack. It is @noreturn.
Even more trivial examples... longjmp and abort. ;)
--
- Alex