File:  [gforth] / gforth / compat / exception.fs
Revision 1.1: download - view: text, annotated - select for diffs
Wed Apr 29 17:09:47 1998 UTC (24 years, 5 months ago) by anton
Branches: MAIN
CVS tags: v0-7-0, v0-6-2, v0-6-1, v0-6-0, v0-5-0, v0-4-0, HEAD
tables are in the image again
added assert.fs defer.fs exception.fs vocabulary.fs to the compat directory

    1: \ exception
    2: 
    3: \ This file is in the public domain. NO WARRANTY.
    4: 
    5: \ this implementation tries to be as close to the following proposal
    6: \ as possible (we cannot guarantee unusedness nor are we allowed to
    7: \ use values in the range -4095..-256).
    8: 
    9: \ EXCEPTION ( c-addr u -- n ) exception
   10: 
   11: \ n is a previously unused THROW value in the range
   12: \ {-4095...-256}. Consecutive calls to EXCEPTION return consecutive
   13: \ decreasing numbers.
   14: 
   15: \ The system may use the string denoted by c-addr u when reporting
   16: \ that exception (if it is not caught).
   17: 
   18: \ Typical Use
   19: 
   20: \ s" Out of GC-managed memory" EXCEPTION CONSTANT gc-out-of-memory
   21: \ ...
   22: \ ... gc-out-of-memory THROW ...
   23: 
   24: \ The program uses the following words
   25: \ from CORE :
   26: \ Variable ! : 2drop @ +! ; 
   27: \ from BLOCK-EXT :
   28: \ \ 
   29: \ from FILE :
   30: \ ( 
   31: 
   32: variable next-exception -10753 next-exception !
   33: 
   34: : exception ( c-addr u -- n )
   35:     2drop
   36:     next-exception @
   37:     -1 next-exception +! ;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>