2019-01-23 02:50:05 +01:00
|
|
|
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 ;
|
2020-02-11 20:30:14 +01:00
|
|
|
|
2019-01-23 02:50:05 +01:00
|
|
|
: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
|
|
|
|
```
|