aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/common/lib/anew.frt
diff options
context:
space:
mode:
Diffstat (limited to 'amforth-6.5/common/lib/anew.frt')
-rw-r--r--amforth-6.5/common/lib/anew.frt27
1 files changed, 27 insertions, 0 deletions
diff --git a/amforth-6.5/common/lib/anew.frt b/amforth-6.5/common/lib/anew.frt
new file mode 100644
index 0000000..a7e9330
--- /dev/null
+++ b/amforth-6.5/common/lib/anew.frt
@@ -0,0 +1,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 ;
+