\ jim 2007-04-21
\ Here's a simpler DOER/MAKE implementation which is
\ just vectored execution with a little sugar.  Each
\ MAKE action must be a separate word.

\ Syntax 1: You have to tick each ACTION.

: nop ;
: doer create ['] nop , does> @ execute ;
: make ' >body ! ;

doer typ
s" hello" typ .s 2drop
' 2drop make typ
s" hello" typ .s
' type make typ
s" hello" typ .s
' + make typ
s" hello" 2dup typ .s drop 2drop

\ Another syntax -- don't have to tick the action word yourself,
\ but it's not postfix.

: make ' ' swap >body ! ;

make typ 2drop
s" hello" typ .s
make typ type
s" hello" typ .s
make typ +
s" hello" 2dup typ .s drop 2drop

\ Finally, the [make] syntax works inside definitions.

: [make]  ' '  postpone literal  postpone literal
    postpone >body  postpone ! ; immediate

: invisible  [make] typ 2drop ;
: visible  [make] typ type ;
invisible s" hello" typ .s
visible s" hello" typ .s
