aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/common/lib/in.frt
diff options
context:
space:
mode:
Diffstat (limited to 'amforth-6.5/common/lib/in.frt')
-rw-r--r--amforth-6.5/common/lib/in.frt36
1 files changed, 36 insertions, 0 deletions
diff --git a/amforth-6.5/common/lib/in.frt b/amforth-6.5/common/lib/in.frt
new file mode 100644
index 0000000..b2af5f3
--- /dev/null
+++ b/amforth-6.5/common/lib/in.frt
@@ -0,0 +1,36 @@
+\ invented at the Euro Forth 2016 to
+\ define a word in a vocabulary different
+\ to CURRENT
+
+\ #require also.frt
+\ #require previous.frt
+\ #require definitions.frt
+
+
+: in ( "voc" "defining-word" -- )
+ get-current >r also ' execute
+ definitions previous ' execute r> set-current
+;
+
+\ use as follows, require vocabulary.frt first
+\ vocabulary gui
+\ in gui : foo ( .. -- .. ) ... ;
+\ in gui variable bar
+\ in gui defer baz
+\ show what's in gui
+\ also gui words previous
+\ remeber: gui is a vocabulary, not a wordlist
+\
+\ Alternative implementation uses wordlist id's
+\ instead of vocabularies. All the #require
+\ lines can be omitted.
+\
+\ : IN ( wid "action" -- )
+\ get-current >r set-current ' execute r> set-current ;
+\
+\ use it like
+\ wordlist constant gui
+\ ... same as above
+\ show the content of gui
+\ gui show-wordlist
+\