Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

wordlist

20 views
Skip to first unread message

Doug Hoffman

unread,
Feb 5, 2010, 10:00:54 AM2/5/10
to
Is there an ANS compatible way to have wordlists survive (persist) a
dictionary image save?

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

David N. Williams

unread,
Feb 5, 2010, 11:04:17 AM2/5/10
to

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

Anton Ertl

unread,
Feb 5, 2010, 11:01:28 AM2/5/10
to
Doug Hoffman <glid...@gmail.com> writes:
>Is there an ANS compatible way to have wordlists survive (persist) a
>dictionary image save?

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/

Doug Hoffman

unread,
Feb 5, 2010, 11:30:36 AM2/5/10
to
On Feb 5, 11:04 am, "David N. Williams" <willi...@umich.edu> wrote:
> On 2/5/10 10:00 AM, Doug Hoffman wrote:
>  > Is there an ANS compatible way to have wordlists survive (persist) a
>  > dictionary image save?
>  >
>  > 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.

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

Bruce McFarling

unread,
Feb 5, 2010, 1:59:19 PM2/5/10
to

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?

George Hubert

unread,
Feb 5, 2010, 2:24:00 PM2/5/10
to

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

David N. Williams

unread,
Feb 5, 2010, 2:38:21 PM2/5/10
to

The error is not from compiling but from executing test. I
seem to have misunderstood what you were doing. :-(

-- David

Albert van der Horst

unread,
Feb 5, 2010, 2:48:55 PM2/5/10
to
In article <2010Feb...@mips.complang.tuwien.ac.at>,

Anton Ertl <an...@mips.complang.tuwien.ac.at> wrote:
>Doug Hoffman <glid...@gmail.com> writes:
>>Is there an ANS compatible way to have wordlists survive (persist) a
>>dictionary image save?
>
>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.

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

Coos Haak

unread,
Feb 5, 2010, 3:06:43 PM2/5/10
to
Op Fri, 5 Feb 2010 07:00:54 -0800 (PST) schreef Doug Hoffman:

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

Doug Hoffman

unread,
Feb 6, 2010, 4:04:15 AM2/6/10
to
After a bit of digging it appears that Carbon MacForth has a mechanism
for saving and restoring wordlists such that they can persist after a
dictionary image save. Not surprising. Ward has covered most all of
the bases, as usual. Macintosh resources are used along with some
MacForth relative chains. VALUEs are retained through an image save
as with most any Forth (I presume), but since the value contains a
handle to heap memory it is not valid afterwards.

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

0 new messages