On 2019-10-01 20:05, Anton Ertl wrote:
> Ruvim <
ruvim...@gmail.com> writes:
>> On 2019-09-21 17:41, Anton Ertl wrote:
>>> Ruvim <
ruvim...@gmail.com> writes:
>>>> On 2019-09-19 19:55, Anton Ertl wrote:
>>
>> [...]
>>>>> Yes for TO, no for IF. If POSTPONE special-cases IF to work around
>>>>> the STATE-smartness, IF is no longer STATE-smart, but something else.
>>>>
>>>> Well, let's define "STATE-smart" as following:
>>>>
>>>> A definition is *STATE-smart* if its execution semantics
>>>> depends on STATE.
>>>>
>>>> From this point of view STATE-smartness nothing to do with POSTPONE.
>>>
>>> This definition is incomplete. STATE-smart words are immediate,
>>
>> If STATE-smartness already implicates immediacy, why do you mention
>> "immediate" separately?
>
> Some people have used "STATE-smart" for STATE-dependent words that are
> not immediate. So I usually mention "immediate" to make the immediacy
> clear.
I see. And you make them independent as a funny side effect.
>> Could you define your "STATE-smart" term?
>
> Here's a description: A STATE-smart word is an immediate word with
> STATE-dependent execution semantics used to approximate
> dual-semantics.
Can a STATE-dependent immediate word be used for another purpose?
(i.e. not to "approximate dual-semantics")
What the words are "dual-semantics"? Are they those five well known
standard words only or something else?
> The approximation works as intended when the word is
> text-interpreted, but breaks down when it is ticked and the EXECUTEd
> in compile state, or POSTPONEd, and the containing word is then
> performed in interpret state.
Is this breaking is essential part of a STATE-smart word?
What if such behavior is not breaking but is intended one?
Actually this description of "STATE-smart word" looks too arbitrary.
It resembles me "No true Scotsman" fallacy [1].
The /true/ STATE-smart word works not as intended when it is POSTPONEd,
but if it works as intended, then POSTPONE works incorrectly, or the
word is not /true/ STATE-smart word. And you can also arbitrary choose
what is intended.
In any case, it does not matter. See (2) below.
>> 1. The specification and the reference implementation for SYNONYM don't
>> support your interpretation.
>
> The implementation section of SYNONYM says that the implementation of
> SYNONYM requires knowledge of the host implementation. The provided
> definition is broken (for the reasons outlined above), and in some
> sense, this is not a problem, because the reference implementation is
> not normative. Of course, in the real world it is a problem, because
> people are misled by broken reference implementations.
In important premise of a reader is that the reference implementations
are correct and consistent even if they are specific for some system only.
The broken definitions have no place in the standard. If a definition in
a reference implementation becomes known as broken, it should be excluded.
But in the case of SYNONYM the reference implementation does not violate
the specification and it is not broken.
>> In the same time the execution semantics of '0EQ' are unequal to the
>> execution semantics of '0='.
>>
>> : [E] EXECUTE ; IMMEDIATE
>> 0 ' 0= ] [E] [ . \ prints -1
>> 0 ' 0EQ ] [E] [ . \ prints 0 (or even throw exception)
>> \ NB: with the reference implementation of SYNONYM
>>
>> Therefore, the execution semantics for "0EQ" are unequal to the
>> interpretation semantics for "0EQ" (that are equal to the int. sem. of
>> '0=').
>
> So you provide a demonstration of the breakage of the reference
> implementation of SYNONYM.
It is not breakage of the reference implementation. Since such
implementation is allowed by the specification.
The specification does not require to have equal execution semantics.
Perhaps it is a hole in the specification or just a lack of a
declaration for the corresponding ambiguous condition, but it is not a
problem in the reference implementation.
Perhaps you can show a breakage using your interpretation of
"compilation semantics" and "interpretation semantics" terms, but there
is no any breakage if we use the notion from the standard term definitions.
>> 2. A similar conclusion can be shown for 'TO' (or 'S"') word.
>> 'TO' is allowed to be implemented as a STATE-dependent immediate word.
>> In the same time the compilation semantics for 'TO' are not equal to the
>> interpretation semantics for 'TO'. But they are equal (in such
>> implementation) by your interpretation of the corresponding terms.
>
> TO has an ambiguous condition that prevents a standard program from
> determining the difference between a proper dual-semantics
> implementation and a STATE-smart implementation. This ambiguous
> condition allows to implement TO as a STATE-smart word. That does not
> mean that STATE-smart words are proper implementations of
> dual-semantics words in general (and for S", they are not).
Well, perhaps your are right using your definition for "STATE-smart
word" (that is too vague for me).
So, take a note, in the citation above I talk about STATE-dependency and
immediacy (in the standard notion) only — they seem clear enough.
Yes, the ambiguous condition prevents the standard program from
determining that, but why don't to use a non standard program to check
'TO'? We know that in the case of POSTPONE the corresponding ambiguous
condition is just a concession to some Forth system implementations.
OTOH, at the moment a standard program can still check 'S"' word.
(2) I can just claim that the standard words with undefined execution
semantics (including 'TO', 'S"', 'IF') may and can be implemented as
STATE-dependent immediate word: i.e. FIND returns ( xt 1 ) for them and
this result of FIND does not depend on STATE. And value 1 means
immediacy in the standard notion. And POSTPONE and [COMPILE] can be be
implemented in such a way to work correctly for them.
Moreover, a special choice of wording is used in some specifications in
the standard to allow such implementation. It is the next argument.
3.
Let's take for shortness:
ES — execution semantics
IS — interpretation semantics
CS — compilation semantics
In the glossary entries for all those five "dual-semantics" words the
standard specifies IS and CS, but ES remain unspecified.
By your interpretation the ES are equal to the IS for these words. To
explicitly express this idea, ES could be specified instead of IS.
E.g. for 'S"' word:
*Execution*:
( "ccc<quote>" -- c-addr u )
Parse ccc delimited by " (double quote). Store the resulting string
in a transient buffer c-addr u.
Compilation:
( "ccc<quote>" -- )
Parse ccc delimited by " (double quote). Append the run-time semantics
given below to the current definition.
Run-time:
( -- c-addr u )
Return c-addr and u that describe a string consisting of the
characters ccc.
And the IS become just the default case (by 3.4.3.2).
NB: this approach is used for the words like EXIT — when ES are given
and CS are defined as the default case (by 3.4.3.3).
But this approach in the specifications wording excludes implementation
(2) for these words. Since in such case ES can't be STATE-dependent.
(but, as it is obvious for me, TC X3J14 felt to not exclude such
implementations).
So, the chosen wording (i.e. specifying IS and CS but not ES) allows
implementation (2) for these words, it is a correct implementation
choice, and the IS are unequal to the ES for them in such case (namely,
the IS are STATE-independent but the ES are STATE-dependent).
But this contradicts with your interpretation that the IS are equal to
the ES for these words.
>>> So if POSTPONE eliminates this STATE-dependence, the word is
>>> not STATE-smart.
>>
>> Why does a word property depend on how POSTPONE is implemented?
>
> I am sure you are adept enough at this kind of stuff to finish the
> reductio ad absurdum yourself, but for your pleasure, let me formulate
> it more clearly.
>
> STATE-smart words have STATE-dependent compilation semantics. We can
> detect it by putting the compilation semantics in a word X with
> POSTPONE, and then performing X in interpret STATE. If we write a
> STATE-smart word, and it does not behave as a STATE-smart word when
> POSTPONEd, the implementation of POSTPONE is incorrect.
Actually we cannot detect it via POSTPONE when the correct
implementation of POSTPONE is a controversial point.
[1]
https://en.wikipedia.org/wiki/No_true_Scotsman
--
Ruvim