setjmp / longjmp

Stewart Gordon via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Apr 26 13:45:41 PDT 2015


On 26/04/2015 06:56, ketmar wrote:
<snip>
> you shouldn't use setjmp/longjmp in D. use exceptions instead. something
> like this:
<snip>

True in the general case.  Still, there must be some reason that trying it in D causes an 
AV (even if I disable the GC).  I remain curious about what that reason is.

Some time ago, just for fun, I wrote an Unlambda to D compiler.  Except that I couldn't 
get the c builtin to work properly.  Exceptions cover typical uses cases, but a subtlety 
of it is that (roughly speaking) the continuation it emits can escape from the function it 
is passed into, and then when the continuation is later invoked it should return the 
program to the point at which c was invoked.  Essentially, it can wind the stack as well 
as unwinding it.  I envisaged that, maybe with the aid of setjmp and some trick to get GC 
to work with it, it could be made to work.

Stewart.

-- 
My email address is valid but not my primary mailbox and not checked regularly.  Please 
keep replies on the 'group where everybody may benefit.


More information about the Digitalmars-d-learn mailing list