wmb@MITCH.ENG.SUN.COM (07/16/90)
> NMORGENSTERN writes: > > : NET CREATE 0 , 0 , 0 , ; > : 3! ( n1 n2 n3 a -- ) 2DUP ! 2+ NIP 2! ; > : 3@ ( a -- n1 n2 n3) DUP 2+ 2@ ROT @ ; > : SET-NET ( net -- ) R@ SP@ ROT RP@ SWAP 3! ; > : FALL ( net -- ) 2+ RP! SWAP >R 4 + SP! ; > > For example: To declare a net: > NET SAFETY1 To set the net > ... SAFETY1 SET-NET ( point A ) FOO FAH .... This is similar to, but slightly weaker than, C's setjmp()/longjmp() . jmp_buf safety1; <==> NET SAFETY1 setjmp(safety1) ~<==> SAFETY1 SET-NET longjmp(safety1); <==> SAFETY1 FALL The reason it is weaker is because setjmp() returns a flag indicating whether it returned normally or returned due to a longjmp(). This feature could be added simply by adding TRUE to the end or SET-NET and FALSE to the end of FALL (or vice versa; either way works). The relative merits of CATCH/THROW vs. setjmp()/longjmp() have already been debated on this newsgroup. Mitch Bradley