[...]
>> But concerning the Standard, — it doesn't specify what is a STATE-smart
>> word, and what is a correct way to postpone it.
>
> It specifies the execution semantics of all user-defined words, and
> specifies that the interpretation semantics are the same, and, for
> immediate words (STATE-smart words are immediate), that the
> compilation semantics is also the same. And it specifies that
> POSTPONE appends the compilation semantics (=execution semantics for
> STATE-smart words) to the current definition.
>
Well, after removing the vague "STATE-smart" term and parenthesis, you say:
| It specifies the execution semantics of all user-defined
| words, and specifies that the interpretation semantics
| are the same, and, for immediate words, that the
| compilation semantics is also the same.
| And it specifies that POSTPONE appends the compilation
| semantics to the current definition.
I.e., that for *any* immediate word IS = ES and CS = ES,
that means IS = CS.
Let's refer to the original wording and definitions.
As I already wrote [5], if we substitute definitions of "interpretation
semantics" and "compilation semantics" in place the terms themselves, we
get:
in 2.1:
| immediate word:
| A Forth word whose { behavior when its name is encountered
| by the text interpreter *in compilation state* } is to perform its
| execution semantics.
in
3.4.3.2:
| Unless otherwise specified in an "Interpretation:" section of the
| glossary entry, { the behavior of a Forth definition when its name
| is encountered by the text interpreter *in interpretation state* }
| is its execution semantics.
In the first case it means that execution semantics are performed in
compilation state.
In the seconds case it means that execution semantics are performed in
interpretation state.
And it's obvious that the behavior that these execution semantics show
in interpretation state may be *unequal* to the behavior in compilation
state (when everything else arguments being equal).
So, how to compose the specification for such an immediate word (that
have the different behavior in the different state)?
One approach is:
if interpreting do this, if compiling do that.
(i.e., to specify only execution semantics).
Another approach is to call one behavior "interpretation semantics" and
another behavior "compilation semantics" and specify them separately and
more simply (without conditional ifs):
Interpretation: do this.
Compilation: do that.
An additional feature of this approach is that now the word can be
implemented in the different way. If we don't say that it's an immediate
word, and don't specify execution semantics, then the word is not
obligated to be immediate and even to have execution semantics.
But if we allow another implementations, we cannot get execution
semantics (xt) in a portable way anymore. So we should disallow taking
execution token for such words.
Good. But can we describe via the different interpretation semantics
and compilation semantics a word that should be namely an immediate
word? Yes, we can: we should just add a note that it's an immediate
word. Does it mean that for this word IS = CS ? — No. They are different.
NB: the standard specifies a word to be an immediate word only in the
cases when IS = CS. But a user may define an immediate word for which IS
<> CS, i.e. that has STATE-dependent execution semantics.
For the words having CS <> IS and CS <> default, the standard doesn't
required to be immediate words, but it *allows* them to be immediate words.
It seems, the only reason to say that CS = ES = IS for any immediate
word is to prove that a better implementation of POSTPONE (when argument
is an immediate word) is non-compliant. It doesn't have other consequences.
But, taking into account Q99-027 [3], and some other grounds, both
implementations are compliant: the better implementation, as well as the
simple implementation (aka common practice).
[...]
> Do you want to say that the common practice of implementing POSTPONE
> is wrong, and that the only accurate implementation of POSTPONE is yours?
No. I want to say that both are allowed by the standard at the moment.
> In that case that standard would have failed to standardize common
> practice.
POSTPONE is a new word that was introduced in Forth-94. Common practice
concerning POSTPONE was absent before Forth-94. So it's incorrect to say
that it have failed in this regard.
> It makes more sense to
> adopt an interpretation of the standard that aligns more with common
> practice. You can now point to SwiftForth (STATE-smart S") for a
> deviation of my interpretation from some existing practice, but if you
> look at the number of systems and programs that would have to be
> changed, the my interpretation is much closer to common practice than
> yours.
I would not suggest to make non-standard the popular implementation of
POSTPONE. So no need to change systems.
Also, no programs would have to be changed. If a program performs, in
interpretation state, the compilation semantics appended by POSTPONE,
then it has an environmental dependency.
If a program relies on STATE-dependent immediate words, my
implementation of POSTPONE just more convenient in use. Since the code
like the following:
: foo ]] if user-defined-macro then [[ ;
: bar [ ... foo ] ;
does not depend on STATE, and works as expected.
[5] Semantics rethinking, 2019-08-04
news:qi6con$1bdk$
1...@gioia.aioe.org
https://groups.google.com/forum/message/raw?msg=comp.lang.forth/vrq2f2XXy1Q/tiuq7hJTFgAJ
--
Ruvim