mirror of
https://git.sr.ht/~crc_/retroforth
synced 2024-11-16 19:48:56 +01:00
96ae77edbb
FossilOrigin-Name: 20149d1819aa93a0fd469c5ad05031d065bf168a2d47a5c94bd233c71f427a41
28 lines
487 B
Text
28 lines
487 B
Text
Marker provides a way to quickly reset the dictionary and heap
|
|
to the state it was in prior to the creation of the marker.
|
|
|
|
## The Code
|
|
|
|
~~~
|
|
:class:marker (a-)
|
|
compiling? [ compile:lit &class:marker compile:call ]
|
|
[ fetch-next !Dictionary fetch !Heap ] choose ;
|
|
|
|
:marker (s-) [ @Heap @Dictionary ] dip d:create , , &class:marker reclass ;
|
|
~~~
|
|
|
|
## A Test Case
|
|
|
|
```
|
|
:a #1 #2 #3 ;
|
|
:b a + + ;
|
|
:c b n:put nl ;
|
|
c
|
|
'd marker
|
|
:a #4 #5 #6 ;
|
|
:b a + + ;
|
|
:c b n:put nl ;
|
|
c
|
|
d
|
|
c
|
|
```
|