@noreturn?
Alex Rønne Petersen
xtzgzorex at gmail.com
Mon May 14 05:13:51 PDT 2012
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.
--
- Alex
More information about the Digitalmars-d
mailing list