aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/common/lib/anew.frt
blob: a7e93306a811b305e7246fd117e46c9e0afc0ae1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
\ POSSIBLY  ( "name" -- )
\   Execute _name_ if it exists; otherwise, do nothing.
\   Useful implementation factor of `ANEW`.

\ ANEW  ( "name" -- )
\   Compiler directive used in the form: `ANEW _name_`.
\   If the word _name_ already exists, it and all
\   subsequent words are forgotten from the current
\   dictionary, and then a `MARKER` word _name_ is
\   created that does nothing. This is usually placed
\   at the start of a file. When the code is reloaded,
\   any prior version is automatically pruned from the
\   dictionary.
\
\   Executing _name_ will also cause it to be forgotten,
\   since it is a `MARKER` word.
\
\   Useful implementation factor of `EMPTY`.

\ meta comment for amforth-shell.
\ #require marker.frt

: possibly  ( "name" -- )
   parse-name find-xt if execute  then ;

: anew  ( "name" -- )  >in @  possibly  >in !  marker ;