retroforth/example/marker.retro
crc 9e03717deb normalize names for examples (with a couple of exceptions), closes #38
FossilOrigin-Name: 088675e452ed86a712563c8b2597fe4d47da59bdea0e40becdd1e028a84c47b0
2021-01-24 01:13:04 +00:00

28 lines
487 B
Forth

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
```