In article <2024Mar10.193700@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
minforth@gmx.net (minforth) writes:
However,
: foo 123 >r :noname r> postpone literal postpone ; ;
foo execute . \ prints 123
is guaranteed to work in Forth-94 (ISO Forth) and Forth-2012.
I thought that
"
123 >r : noname r> postpone literal postpone ;
noname . \ prints 123
"
is not guaranteed to work in Forth-94 (ISO Forth).
Why is this different?
minforth@gmx.net (minforth) writes:
Although I find it obvious and not worth the hassle, the specification >>should be amended so that "a program shall not use the return stack to
pass data between outer and inner functions, i.e. from an enclosing word
to its inner quotation(s) of any nesting depth, or from a quotation to
its outer enclosing word regardless of its nesting depth".
If you think so, make a proposal. In the rest of the standard, the >compilation semantics of control-flow words communicate through the >control-flow stack, which usually is the data stack. I see no reason
to make an exception for [: ... ;].
This is the most expected way because analogously
123 >r :noname r> lit, ;
is also not guaranteed to work in ISO Forth.
However,
: foo 123 >r :noname r> postpone literal postpone ; ;
foo execute . \ prints 123
is guaranteed to work in Forth-94 (ISO Forth) and Forth-2012.
- anton
On 2024-03-07 20:18, minforth wrote:
Ruvim wrote:
The accepted proposal for quotations [1] specifies only compilation
semantics for the words "[:" and ";]".
The expected interpretation semantics for "[: ... ;]" are ...
Expected by whom?
By me and many other people.
Some Forth systems are actually implement these interpretation semantics (some of them for the case when the current definition is absent only).
I'd rather prefer some error message on a stray [: or ;] (principle of
least surprise)
According to the principle of least surprising, interpreting a
definition name should be equivalent to interpreting of the definition
body.
And if they are not equivalent — it should be for some clear and convincing reason. For example, `exit` can be used only in a definition body.
Let's take the definition:
: foo [: 123 . ;] execute ;
There is no a convincing reason why the following lines should not be observationally equivalent:
foo
[: 123 . ;] execute
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 916 |
Nodes: | 10 (1 / 9) |
Uptime: | 50:53:30 |
Calls: | 12,172 |
Calls today: | 2 |
Files: | 186,522 |
Messages: | 2,234,732 |