Alex McDonald <
al...@rivadpm.com> writes:
>2. Are there to be further discussions on the 2 cell auto-magic POSTPONE
>action, or does Stephen Pelc's comment "We cannot predict how
>recognisers will be used, so attempting to automate the POSTPONE actions
>is doomed to failure" stand?
Reference?
In any case, I described the necessity for various actions in
<
2020May2...@mips.complang.tuwien.ac.at> (referring to RfC-D
actions) in an answer to a posting by you.
|If you just want to recognize literals, you need just one action: The
|time-shifting action like POSTPONE LITERAL (that's coming out of
|RECTYPE>POST); you don't do anything to the literal (that the
|recognizer left, e.g., on the data stack) interpretively, you
|time-shift it once for compilation, and you time-shift it twice for
|postponing. SwiftForth has a recognizer-like extension mechanism that
|provides a single xt: that for the time-shifting action.
|
|If you want a recognizer for normal words, or, e.g., for TO
|replacement syntax ->X, you als need a run-time action; for normal
|words the run-time action is EXECUTE, for ->X, where X is a VALUE, it
|is "!". I.e., after time-shifting the xt (for a word recognizer) or
|address (for a ->X recognizer) 0-2 times, you perform the run-time
|action (also appropriately time-shifted). In the proposal we have a
|one-time-shifted run-time action in the form of RECTYPE>COMP (for
|literals the result is the same action as the time-shifting action).
|
|If you want a recognizer that can also handle immediate and combined
|words, these two actions are insufficient. For a combined word, the
|interpretation semantics is not systematically related to the
|compilation semantics, so it needs a separate action. And that's what
|RECTYPE>INT provides. For literals it is noop, for ->X it's the
|run-time action without time-shift (i.e., "!" for a VALUE), for words
|(both normal and combined) it's performing the interpretation
|semantics (i.e., for an nt-based word recognizer the action consists
|essentially of NAME>INTERPRET EXECUTE); for combined words the
|RECTYPE>COMP action performs the compilation semantics.
If you have any trouble understanding that, please ask.
So yes, you need three actions. The only question is whether
postponing is performed by 1) time-shifting the data followed by
time-shifting the compilation action (RFC-D), or whether 2) you
combine these in one action (IIRC RFC-C). Option 1 is a little harder
to understand, but requires less code for many rectypes, and I think
it is also less error-prone because of that. Here are some rectype
definitions that I find in Gforth's code (i.e., an option-1 system):
' noop ' fliteral ' fliteral rectype: rectype-float
' getenv ' env$, ' slit, rectype: rectype-env
' noop ' slit, dup rectype: rectype-string
' (to) ' (to), ' post-to, rectype: rectype-to
' >system ' system, ' slit, rectype: rectype-eval
' no.extensions dup dup rectype: rectype-null
' noop ' lit, dup rectype: rectype-num
' noop ' 2lit, dup rectype: rectype-dnum
:noname name?int execute-;s ;
' name-compsem
' lit,
rectype: rectype-name ( takes nt, i.e. result of find-name and find-name-in )
:noname drop execute ;
:noname 0> IF execute ELSE compile, THEN ;
' 2lit,
rectype: rectype-word ( takes xt +/-1, i.e. result of find and search-wordlist )
:noname ( object xt -- ) swap >o execute o> ; ' >oo> ' lit,
rectype: rectype-moof2
' interpret-notfound1 ' compiler-notfound1 ' postpone-notfound1
rectype: rectype-notfound
Consider how these would change for an Option 2 system.
- 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 2020:
https://euro.theforth.net/2020