Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!ucbvax!MITCH.ENG.SUN.COM!wmb From: wmb@MITCH.ENG.SUN.COM Newsgroups: comp.lang.forth Subject: setjmp/longjmp Message-ID: <9007040422.AA28752@ucbvax.Berkeley.EDU> Date: 4 Jul 90 02:40:32 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: wmb%MITCH.ENG.SUN.COM@SCFVM.GSFC.NASA.GOV Organization: The Internet Lines: 15 You can implement setjmp/longjmp semantics in terms of CATCH/THROW. You just have ensure that every CATCH compares the return value against the set of error codes that it is expecting. This is no more trouble (in fact it is less troble) than what you have to do to implement CATCH/THROW in terms of setjmp/longjmp (with is to maintain a separate stack of jmp_bufs, and to add code to pop that stack when the dynamic scope of a particular setjmp has expired). Without that extra code, and the attendant programming discipline to use it properly, setjmp suffers from the "dangling pointer problem". If a routine which has called setjmp exits without cleaning up after itself (i.e. popping this additional jmp_buf stack), a longjmp can "jump to outer space". Mitch