aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/examples/local.frt
diff options
context:
space:
mode:
Diffstat (limited to 'amforth-6.5/examples/local.frt')
-rw-r--r--amforth-6.5/examples/local.frt64
1 files changed, 0 insertions, 64 deletions
diff --git a/amforth-6.5/examples/local.frt b/amforth-6.5/examples/local.frt
deleted file mode 100644
index 71564a2..0000000
--- a/amforth-6.5/examples/local.frt
+++ /dev/null
@@ -1,64 +0,0 @@
-\ trivial local
-
-\ there is exactly one local called X
-\ it is not initialized upon entry
-\ it works like a local should do:
-\ get the content by calling X, assign
-\ a new value with TO
-
-\ separate local stack
-\ max. call depth 10
-
-\ "2" means "1 cells", if portability is a concern
-
-#10 cells constant l-size
-\ the local stack pointer and the stack itself
-l-size cell+ buffer: lsp
-
-\ initialize l-stackpointer, call it
-\ in e.g. turnkey prior to use!
-: l-init lsp l-size + lsp ! ;
-
-\ general stack access, unsued
-: l@ lsp @ @ ;
-: l! lsp @ ! ;
-: l-free 2 lsp +! ;
-: l-alloc -2 lsp +! ;
-: >l l! l-alloc ;
-: l> l-free l@ ;
-
-: local@ negate lsp @ + @ ;
-: local! negate lsp @ + ! ;
-
-\ define a local by its offset
-\ relative to the local stack pointer
-: local ( offset "name" -- )
- (value) ,
- ['] local@ ,
- ['] local! ,
-;
-
-\ should be smarter, it should
-\ check whether X is used at all
-\ and allocate the local stack
-\ only if needed.
-: : : l-alloc ;
-: ; l-free postpone ; ; immediate
-
-\ globally define a label for the first
-\ local variable. The X is a global name
-\ but has local content. If using more,
-\ add a l-alloc/l-free pair in the : and ;
-\ definitions above.
-
-0 local X
-
-\ test cases
-\ l-init
-\ : test1 to X X . ;
-\ 1 test1
-\ -> 1
-\ : test2 1 test1 to X X . ;
-\ 2 test2
-\ -> 1 2
-\ \ No newline at end of file