To be specific, when I perform the following sequence I get an error.
The Forth used is Carbon MacForth which I believe is (fully?) ANS
compatible. I don't mind if some "housekeeping" before and/or after
saving the image needs to be done to make it work, but I have no idea
how to do it, ANSly or otherwise. I am only interested in an ANS
solution.
Thanks in advance.
-Doug
\ *** begin code sequence
0 value myWL
wordlist to myWL
\ save dictionary image now, quit, and then relaunch with new image
myWL set-current
: test ; \ error or crash
As the above code stands, you should get an error even if you
invoke TEST before quitting, because it's not in the search
order. If I understand correctly what you mean by "save a
dictionary image, ...", there's no standard way to do that, so
there's no guarantee that the search order would be preserved.
The specs for ABORT and QUIT, on the other hand, are precise
about what they do, which does not include resetting the
search-order; so it should be preserved across ABORT and QUIT.
Seems to me after relaunch you need to invoke
[UNDEFINED] >ORDER [IF]
: >ORDER ( wid -- ) ( order: -- wid )
>r get-order r> swap 1+ set-order ;
[THEN]
myWL >ORDER
-- David
Dictionary image saving is not standardized, so you have no guarantees
from the standard that anything survives that, nor can you do anything
that would give you such a guarantee.
So you have to look at what the systems you are interested in do,
e.g.: When you create an image in Gforth, AFAIK all wordlists persist
across the save and image load without any special incantations
necessary from the program.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2009: http://www.euroforth.org/ef09/
I do not get an error if I compile TEST before quitting.
> If I understand correctly what you mean by "save a
> dictionary image, ...", there's no standard way to do that, so
> there's no guarantee that the search order would be preserved.
>
> The specs for ABORT and QUIT, on the other hand, are precise
> about what they do, which does not include resetting the
> search-order; so it should be preserved across ABORT and QUIT.
>
> Seems to me after relaunch you need to invoke
>
> [UNDEFINED] >ORDER [IF]
> : >ORDER ( wid -- ) ( order: -- wid )
> >r get-order r> swap 1+ set-order ;
> [THEN]
>
> myWL >ORDER
OK. I have now tried the following but get the same results:
0 value myWL
wordlist to myWL
: >ORDER ( wid -- ) ( order: -- wid )
>r get-order r> swap 1+ set-order ;
\ save dictionary image now, quit, and then relaunch with new image
myWL >ORDER
: test ; \ crash upon attempt to compile
In both attempts the error has been I could not even compile TEST, and
so could not even attempt to execute it.
I believe Anton has answered my question. Thank you. And thanks to
Anton.
-Doug
What is saved when that implementation saves a dictionary image? That
is,
===========================
0 value myWL
wordlist to myWL
CR .( myWL before the save ) myWL .
\ save dictionary image now, quit, and then relaunch with new image
CR .( myWL after the save ) myWL .
myWL set-current
: test ; \ error or crash
=========================
Is myWL the same value before and after the image save?
Try
\ *** begin code sequence
wordlist constant myWL
\ save dictionary image now, quit, and then relaunch with new image
myWL set-current
: test ;
If it works then values must be reset in saved images, so can't
be used for wordlists.
George Hubert
The error is not from compiling but from executing test. I
seem to have misunderstood what you were doing. :-(
-- David
It is not controversial that wordlists that are loaded must
persist. That is one of the reasons for SAVE-SYSTEM.
A different issue is whether the search order should be
restored to the exact same situation as while executing
SAVE-SYSTEM.
In ciforth a saved system performs COLD, setting the base
to DECIMAL, and setting the search order to ONLY FORTH,
clearing the stacks, honouring options, etc.
I never thought that unreasonable, but what do other people
think?
If SAVE-SYSTEM means: "go on where you left off"
then stacks and even thread status must be preserved.
>- anton
Groetjes Albert
--
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
Could it be that VALUE in your system is defined like USERs, that get
a default value (e.g. zero) at startup?
Have you tried
wordlist constant myWL
--
Coos
CHForth, 16 bit DOS applications
http://home.hccnet.nl/j.j.haak/forth.html
Regardless, none of this is ANS compatible and so my original question
has already been answered by David and Anton. Thanks to all for the
ideas.
-Doug