4 ms·
FORTH variation #1,000,001: I took John Walkers' AtLast as a core, and extended it in several directions, some I believe quite significant. My use case for FORT
by dwarman 10y ago
FORTH variation #1,000,001: I took John Walkers' AtLast as a core, and extended it in several directions, some I believe quite significant. My use case for FORTH has been as a live debugger that lets me interact with a running Real Time system, an environment where breakpoints are not very useful (except in crashes) because they only allow for post-mortem examination, but a RT system needs to be watched while it is runnung to more quickly discern pathologies.
Extensions that saved me the most agony:
1: Use of stack frame comments to actually define local variables and enforce the in - out stack transform. While at this I also added the comment string to the word definition in an additional help link. Thus:
[:] do_it ( in1 in2 -- out : return in1 * in2 * 2 )
local lv
: lv_helper 2 * ;
in1 @ in2 @ * lv_helper out !
[;]
> help do_it
in1 in2 -- out : return in1 * in2
> 3 6 do_it .
36
>
Note the [:] and [;] redefs for compiler words, had to do this to accommodate nesting, locals, stack frames, while not compromising regular FORTH.
all variables are local in scope to the containing word. Defining variables inside ditto. Had words for listing contents of these too.
I later extended this to include nested word definitions, dynamically allocated variables, and stack frames that will unwind these on execution error. Gone were stack frame size errors, a missed dup or drop no longer fatal, indeed dup and drop not really necessary any more.
2: Structured data debugging aides: a few words and a C header parser allowed me to dump or modify readable contaents of application structs, and to call into application functions.
3: along the same lines of nested definitions, I was able to associate sub-dictionaries with graphical views along their heirarchy. This was a later addition, applied to VNOS. Lots of little things became manageable with this paradigm. In particular, allowed me to do a scoped local console (as a debug object instantated in a View), and to insert message overrides into the VNOS messaging mechanism, effectively adding what turned out to be a really powerful scripting system. Done as an object too - current version includes Perl 5 and Lua (almost ready).
And yes, concurrency is a concern, and being sure not to call non-re-entrant (errant:) functions, but hey, ypu'd likely be surprised at how good a pattern recognizer ther Human Brain is here.
Over-all, I think I used this system with a good half-dozen different CPU architectures and their OS's, also in the high level VNOS GUI (originally put my FORTH into it for debugging purposes, but that was rapidly out-grown).