Yaroslav Veremenko <
werewolf...@gmail.com> writes:
>For example yesterday I installed SwiftForth, I read the documentation and =
>it has few pages on source management. The only word that seem to matter to=
> me in this case is INCLUDE. But it doesn't seem to go deep into how to act=
>ually use it. This is the process that I can imagine working, but it is cru=
>de, and prone to numerous mistakes:
>1. Open interpreter, write some code, test it until it works
>2. Hope that SwiftForth doesn't crash and you don't loose all your progress
>3. Scroll up through the history or list the words, and hope I copy paste s=
>tuff that's important to a separate text editor
>4. Close SwiftForth, start it again, wait for evaluation warning to expire,=
> manually type INCLUDE my-updated-file
The usual way I develop code is to write it in an editor (Emacs in my
case) that runs in parallel with a terminal window. When I want to
test and debug the code, I save it in the editor without closing the
editor, and start the Forth system in the terminal window such that it
loads the code and typically also runs it; e.g., with Gforth
gforth program.4th -e "<code> bye"
where <code> exercises the words we are currently interested in. Then
I can just continue editing the code without having to restart the
editor. Sometimes I just load the program and do interactive testing
and examining, but for debugging, I usually do the setup above. It
allows me to just run the test again by typing cursor up and enter
after inserting tracers or other debugging aids in the source code, or
after an attempt to fix the bug.
In SwiftForth you could do the equivalent with
sf "include program.4th <code> bye"
but SwiftForth is less convenient when the code produces an exception,
as it requires the user to answer a prompt.
>SwiftForth doesn't seem to have a command line arguments help in the docume=
>ntation PDF
Many Forth systems, incluing SwiftForth, but not Gforth,
text-interpret the first command-line argument (or all of them).
>nor there seem to be a way to reset the state of a interpreter=
>.
Maybe COLD. Or you could set a marker at the start of the program and
then run it when you want to reset it:
marker reset include program.4th
...
reset
marker reset include program.4th
But note that the marker does not reset any corruption you may have
left in the Forth system, it just forgets 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:
https://forth-standard.org/
EuroForth 2022:
https://euro.theforth.net