File:  [gforth] / gforth / compat / defer.fs
Revision 1.2: download - view: text, annotated - select for diffs
Sun Nov 28 20:20:37 2004 UTC (19 years, 4 months ago) by anton
Branches: MAIN
CVS tags: v0-7-0, HEAD
implemented deferred words proposal (and adapted documentation accordingly).

    1: \ deferred words and perform
    2: 
    3: \ This file is in the public domain. NO WARRANTY.
    4: 
    5: : perform ( ? addr -- ? )
    6:     @ execute ;
    7: 
    8: : defer ( "name" -- )
    9:     create ['] abort , \ you should not rely on initialization with noop
   10: does> ( ? -- ? )
   11:     perform ;
   12: 
   13: : defer@ ( xt1 -- xt2 )
   14:   >body @ ;
   15: 
   16: : defer! ( xt2 xt1 -- )
   17:   >body ! ;
   18: 
   19: : <is> ( xt "name" -- )
   20:     ' defer! ;
   21: 
   22: : [is] ( compilation: "name" -- ; run-time: xt -- )
   23:     postpone ['] postpone defer! ; immediate
   24: 
   25: : is
   26:   state @ if
   27:     postpone [is]
   28:   else
   29:     <is>
   30:   then ; immediate
   31: 
   32: : action-of
   33:  state @ if
   34:    POSTPONE ['] POSTPONE defer@
   35:  else
   36:    ' defer@
   37: then ; immediate
   38:     
   39: 

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