www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Tango and setjmp.

reply zz <zz zz.com> writes:
Will tango also implement setjmp for D.

Very many lib's in C out there (including ours use TRY CATCH macros with 
setjmp and longjmp for exception handling in C.

And does anyone know of a simple way to wrap up such libraries so that 
D's exception could be used instead?

Zz
Jan 18 2007
next sibling parent Daniel Keep <daniel.keep+lists gmail.com> writes:
zz wrote:
 Will tango also implement setjmp for D.
 
 Very many lib's in C out there (including ours use TRY CATCH macros with 
 setjmp and longjmp for exception handling in C.
 
 And does anyone know of a simple way to wrap up such libraries so that 
 D's exception could be used instead?
 
 Zz

You might want to take a look at StackThreads. (http://assertfalse.com/projects.shtml). I'm not sure if it uses setjmp and longjump, but I know *something*'s going on in there. As for Tango: no idea :) -- Daniel
Jan 18 2007
prev sibling parent Sean Kelly <sean f4.ca> writes:
zz wrote:
 Will tango also implement setjmp for D.

In a manner of speaking. DMC's setjmp implementation currently doesn't work with DMD so I've decided to only make it available for Posix. Also, setjmp is generally just a bad idea because it can bypass stack unrolling so its use is somewhat discouraged.
 And does anyone know of a simple way to wrap up such libraries so that 
 D's exception could be used instead?

Any time you actually want to transfer execution up the stack you should throw an exception instead. Tango uses setjmp only as a failover option for stack threads. Sean
Jan 19 2007