Search code examples
forthgforth

Save and restart a forth 'image'


I'm new to forth. I've played with gforth briefly. And I'm interesting in forth 'images'.

I have this use-case: I want to...

  1. Interactively define words
  2. Save the forth image
  3. Quit the system
  4. Restart the forth image
  5. See the previously defined words

Is this possible? Could you explain how? Thank you.

(I've been playing around with gforthmi, savesystem, gforth -i. And I've looked at blocks and use. I have no real idea what I'm doing.)


Solution

  • TL;DR The workflow described in the question is not possible in Gforth out of the box.

    According to the documentation, Gforth usually requires a relocatable image, but such image cannot be created in interactive session. The word savesystem allows to create a non-relocatable image only.

    A possible approach is to log an interactive session into a file, and then use this log file to compose a conventional Forth source file that is included in the next session.

    Something like:

    tee session.log | gforth
    # or
    rlwrap tee session.log | gforth