From 67d25d837ac55f28a366c0a3b262e439a6e75fc3 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 19 Aug 2017 12:15:28 +0200 Subject: Add AmForth --- amforth-6.5/examples/scope.frt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 amforth-6.5/examples/scope.frt (limited to 'amforth-6.5/examples/scope.frt') diff --git a/amforth-6.5/examples/scope.frt b/amforth-6.5/examples/scope.frt new file mode 100644 index 0000000..d6a5d31 --- /dev/null +++ b/amforth-6.5/examples/scope.frt @@ -0,0 +1,21 @@ +\ The following example shows how to create a library of words under a special +\ wordlist (can_lib). This example also shows how to chain scope calls safely. + +wordlist constant can_lib + +get-order 1+ can_lib swap set-order \ can_lib would be searched first + +: can_scope ( addr len -- addr' len' wid ) + 2dup + 4 > if \ name length check + s" can_" tuck icompare if \ name prefix check + 4 /string \ drop prefix from created word + can_lib exit + then + else + drop + then + [ ' wlscope defer@ ] literal execute +; + +' can_scope is wlscope -- cgit v1.2.3