Ruvim schrieb am Mittwoch, 5. Oktober 2022 um 14:45:20 UTC+2:
On 2022-10-05 16:17, Gerry Jackson wrote:
On 04/10/2022 22:53, Ruvim wrote:What are well understood are the interpretation semantics and
On 2022-10-04 01:10, Gerry Jackson wrote:
On 29/09/2022 11:20, Krishna Myneni wrote:
On 9/29/22 02:24, minf...@arcor.de wrote:
I was only wondering if your idea could be extended to +TO.
Yes, it can; however, if you need to use +TO my advice would be to >>>>>> not use a VALUE (or FVALUE or other extended VALUE) but go back to >>>>>> VARIABLEs. One can use of +! , F+! (not currently standard, but
necessary), etc. with corresponding variables. A drawback of TO and >>>>>> extensions such as +TO is that various Forth operations such as '
(tick), ['], POSTPONE, etc. on them results in an ambiguous
condition in standard Forth.
If I define +TO as (using standard Forth):
: +to ( n "name" -- )
parse-name 2>r ( -- n ) ( R: -- ca u )
2r@ s" + to " 2r@
<# holds holds holds 2r> #> evaluate
; immediate
which given
+to x
on a value x evaluates
x + to x
' ['] and POSTPONE can be applied to +TO. It may need special
compilation semantics for some cases but that's beside the point.
Having an opaque implementation for "+to", Tick should not be applied
to "+to" in a standard program while execution semantics are not
specified for "+to" in the documentation.
Sorry, I thought the semantics of +TO was well understood so
documentation was unnecessary in a c.l.f discussion
compilation semantics for "+to", but not execution semantics.
If the phrase:
' +to
returns an xt, this xt identifies some execution semantics. And these
execution semantics may vary, if you don't specify it in a
documentation/standard/etc. (NB: I consider a case of opaque
implementations).
To make this work something like a fully compliant "postpone" should be
"postpone" may be applied to "+to" in any case. But the behavior of
the containing definition in interpretation state is ambiguous if the
system provides not fully compliant "postpone".
A test case:
: compiling(+to) postpone +to ;
0 value x
: test-x 10 [ compiling(+to) x ] x ;
x . test-x . \ should print "0 10"
If this test fails, the system /effectively/ imposes an environmental
restriction: a program should not start performing compilation
semantics in interpretation state.
Yes my system and others failed test-x. To make this work something like >>> a compile only word [+TO] needs to be defined
defined.
See: https://github.com/ForthHub/discussion/discussions/105
As long as the Forth-2012 Test Suite is passed successfully,
a system's POSTPONE implementation is good enough.
If not, a reference implementation should be added here: https://forth-standard.org/standard/implement
On 2022-10-05 17:12, minf...@arcor.de wrote:
Ruvim schrieb am Mittwoch, 5. Oktober 2022 um 14:45:20 UTC+2:
On 2022-10-05 16:17, Gerry Jackson wrote:
On 04/10/2022 22:53, Ruvim wrote:What are well understood are the interpretation semantics and
On 2022-10-04 01:10, Gerry Jackson wrote:
On 29/09/2022 11:20, Krishna Myneni wrote:
On 9/29/22 02:24, minf...@arcor.de wrote:
I was only wondering if your idea could be extended to +TO.
Yes, it can; however, if you need to use +TO my advice would be to >>>>>> not use a VALUE (or FVALUE or other extended VALUE) but go back to >>>>>> VARIABLEs. One can use of +! , F+! (not currently standard, but
necessary), etc. with corresponding variables. A drawback of TO and >>>>>> extensions such as +TO is that various Forth operations such as ' >>>>>> (tick), ['], POSTPONE, etc. on them results in an ambiguous
condition in standard Forth.
If I define +TO as (using standard Forth):
: +to ( n "name" -- )
parse-name 2>r ( -- n ) ( R: -- ca u )
2r@ s" + to " 2r@
<# holds holds holds 2r> #> evaluate
; immediate
which given
+to x
on a value x evaluates
x + to x
' ['] and POSTPONE can be applied to +TO. It may need special
compilation semantics for some cases but that's beside the point.
Having an opaque implementation for "+to", Tick should not be applied >>>> to "+to" in a standard program while execution semantics are not
specified for "+to" in the documentation.
Sorry, I thought the semantics of +TO was well understood so
documentation was unnecessary in a c.l.f discussion
compilation semantics for "+to", but not execution semantics.
If the phrase:
' +to
returns an xt, this xt identifies some execution semantics. And these
execution semantics may vary, if you don't specify it in a
documentation/standard/etc. (NB: I consider a case of opaque
implementations).
To make this work something like a fully compliant "postpone" should be
"postpone" may be applied to "+to" in any case. But the behavior of
the containing definition in interpretation state is ambiguous if the >>>> system provides not fully compliant "postpone".
A test case:
: compiling(+to) postpone +to ;
0 value x
: test-x 10 [ compiling(+to) x ] x ;
x . test-x . \ should print "0 10"
If this test fails, the system /effectively/ imposes an environmental >>>> restriction: a program should not start performing compilation
semantics in interpretation state.
Yes my system and others failed test-x. To make this work something like >>> a compile only word [+TO] needs to be defined
defined.
See: https://github.com/ForthHub/discussion/discussions/105
As long as the Forth-2012 Test Suite is passed successfully,The Test Suit doesn't cover all the cases.
a system's POSTPONE implementation is good enough.
I created a new test case. At the moment, no one pointed out a mistake
in my reasoning, or shown that this test is incorrect.
https://github.com/ForthHub/discussion/discussions/103
Anyway, it's OK to stick with the mentioned environmental restriction,
if it's good enough for you.
Ruvim <ruvim.pinka@gmail.com> writes:
On 2022-09-29 21:43, Anton Ertl wrote:
Zbig <zbigniew2011@gmail.com> writes:
So state-smart words are bad
They are evil! [ertl98]
In this regard the paper shows that it's incorrect to implement an
ordinary word as an immediate word. So, it's not just evil, it's a mistake.
There are several aspects why state-smart words are worse than many
other mistakes:
1) They work as intended much of the time, and only behave wrongly in
corner cases.
2) This seduces some people to try to argue (by language lawyering or
by declaring the standar to be buggy) that not the state-smart words,
but the corner case is a mistake; i.e., indemnify the implementation
by blaming the programmer.
3) In your case it's even worse, because AFAICS you try to declare not
just the corner case usage, but also all widely used systems as buggy
through language-lawyering.
But concerning 's"' (and other combined words) the paper only says (in
the section 3, on page 3):
| This definition behaves correctly as long as it
| is only processed by the text interpreter,
| but it fails with ', postpone, etc.,
| as discussed in Section 2.
This reasoning is wrong:
1. actually, it does not fail with ' (Tick);
2. if it fails with "postpone", then a problem is in "postpone", and
the problem should be corrected in "postpone".
I explained [1] why it doesn't fail with Tick:
It's obvious that in the general case, performing execution semantics in
compilation state may be inequivalent to performing these execution
semantics in interpretation state.
Apart from the difference in the contents of STATE, there must not be
a difference between the behaviour.
S" is not specified as a STATE-dependent word,
so for it there should be no difference.
(¹)And we don't have any ground to say
that they should be equivalent in the case of the s" word, since the
execution semantics for s" are not specified by the standard.
Possibly, but ' arguably should produce an execution token for the interpretation semantics of a word.
Arguments for that position:
1) 6.1.0070 ' says:
|When interpreting, ' xyz EXECUTE is equivalent to xyz.
So when interpreting,
' S" execute bla"
is equivalent to
S" bla" >
2) "4.1.2 Ambiguous conditions" explicitly disallows
|attempting to obtain the execution token, (e.g., with 6.1.0070 ',
|6.1.1550 FIND, etc. of a definition with undefined interpretation |semantics;
but not of words without execution semantics.
On 2022-10-08 15:39, Anton Ertl wrote:
3) In your case it's even worse, because AFAICS you try to declare not
just the corner case usage, but also all widely used systems as buggy
through language-lawyering.
I expressed my position many times concerning "postpone" (and probably
never called widely used systems as buggy in this regard).
The well known popular implementation for "postpone" effectively imposes
an environmental restriction on programs — namely, a program is not
allowed to perform compilation semantics in interpretation state (in
general case).
But concerning 's"' (and other combined words) the paper only says (in
the section 3, on page 3):
| This definition behaves correctly as long as it
| is only processed by the text interpreter,
| but it fails with ', postpone, etc.,
| as discussed in Section 2.
This reasoning is wrong:
1. actually, it does not fail with ' (Tick);
2. if it fails with "postpone", then a problem is in "postpone", and
the problem should be corrected in "postpone".
I explained [1] why it doesn't fail with Tick:
It's obvious that in the general case, performing execution semantics in >>> compilation state may be inequivalent to performing these execution
semantics in interpretation state.
Apart from the difference in the contents of STATE, there must not be
a difference between the behaviour.
I don't quite understand what do you mean by this.
S" is not specified as a STATE-dependent word,
so for it there should be no difference.
This argument is not quite clear and seems to be wrong.
">r", "to", "evaluate", "[", "]" are not specified as STATE-dependent
words too, — does it mean that there should be no difference? No.
(¹)And we don't have any ground to say
that they should be equivalent in the case of the s" word, since the
execution semantics for s" are not specified by the standard.
Possibly, but ' arguably should produce an execution token for the
interpretation semantics of a word.
"... for the interpretation semantics" — it's too loose wording. It
isn't a verifiable proposition.
Probably you want to say that executing in interpretation state the
execution token that Tick returns for a word shall perform the
interpretation semantics for this word. (²)
Arguments for that position:
1) 6.1.0070 ' says:
|When interpreting, ' xyz EXECUTE is equivalent to xyz.
So when interpreting,
' S" execute bla"
is equivalent to
S" bla"
If you think, Forth-94 TC meant STATE-independent execution semantics
for 's"', then they failed to specify it that way.
Concerning ambiguous conditions — in Forth-2012 an ambiguous condition >exists if Tick is applied to any word without specified execution
semantics, but 's"' and 's\"'. Probably, it's just an omission.
Ruvim <ruvim.pinka@gmail.com> writes:
On 2022-10-08 15:39, Anton Ertl wrote:
3) In your case it's even worse, because AFAICS you try to declare not
just the corner case usage, but also all widely used systems as buggy
through language-lawyering.
I expressed my position many times concerning "postpone" (and probably
never called widely used systems as buggy in this regard).
You made statements about how you think a standard system must behave
that no system complies with, in particular with respect to test cases
like:
: [.state] state @ . ; immediate
: .state postpone [.state] ;
.state \ prints 0
AFAIK your position is that this must print -1. No system I have
tested behaves that way.
Ruvim <ruvim.pinka@gmail.com> writes:[...]
On 2022-10-08 15:39, Anton Ertl wrote:
3) In your case it's even worse, because AFAICS you try to declare not
just the corner case usage, but also all widely used systems as buggy
through language-lawyering.
I expressed my position many times concerning "postpone" (and probably
never called widely used systems as buggy in this regard).
The well known popular implementation for "postpone" effectively imposes
an environmental restriction on programs — namely, a program is not
allowed to perform compilation semantics in interpretation state (in
general case).
That's just weasel-wording for claiming that it's non-standard. And
given that the systems do not document such an environmental
restriction, they would just not be standard-compliant, if your claim
was true.
Ruvim <ruvim.pinka@gmail.com> writes:(1)
On 2022-10-09 08:19, Anton Ertl wrote:
Gerry Jackson <do-not-use@swldwa.uk> writes:
On 04/10/2022 22:53, Ruvim wrote:...
On 2022-10-04 01:10, Gerry Jackson wrote:
: +to ( n "name" -- )
parse-name 2>r ( -- n ) ( R: -- ca u )
2r@ s" + to " 2r@
<# holds holds holds 2r> #> evaluate
; immediate
' ['] and POSTPONE can be applied to +TO. It may need special
compilation semantics for some cases but that's beside the point.
Forgot to comment on this earlier, but this posting shows why you may
want to document POSTPONE +TO as ambiguous (and also all the other cases). >>>
...: compiling(+to) postpone +to ;
0 value x
: test-x 10 [ compiling(+to) x ] x ;
x . test-x . \ should print "0 10"
Yes my system and others failed test-x.
That's because +TO is state-smart (with the state dependence coming
from EVALUATE).
NB: if the system provides a full-compliant implementation for
"postpone" then this "+to" is not state-smart [1]
[1] Anton Ertl, Re: WL-TOOLS and ?IMMEDIATE, 2019-09-21Z
news://2019Sep21.164152@mips.complang.tuwien.ac.at
https://groups.google.com/g/comp.lang.forth/c/wYqHc5hqVjQ/m/CSVN_agwBAAJ
| So if POSTPONE eliminates this STATE-dependence,
| the word is not STATE-smart.
Note the context of this statement: A POSTPONE that special-cases a
word where the implementation looks state-smart and actually appends a state-dumb behaviour to the current definition.
I.e., a POSTPONE that does something like
: postpone
parse-name find-name dup [ s" +to" find-name ] literal = if
... \ append some state-dumb behaviour to the current definition
then
\ deal with other words
name>compile swap postpone literal compile, ;
When you throw some user-defined STATE-smart word at it, POSTPONE will produce a STATE-smart result, as every system I have tested does, and
which is standard behaviour IMO.
Ruvim <ruvim.pinka@gmail.com> writes:
On 2022-10-08 15:39, Anton Ertl wrote:
On 2022-10-01 17:27Z, Ruvim wrote:
But concerning 's"' (and other combined words) the paper only says (in >>>> the section 3, on page 3):
| This definition behaves correctly as long as it
| is only processed by the text interpreter,
| but it fails with ', postpone, etc.,
| as discussed in Section 2.
This reasoning is wrong:
1. actually, it does not fail with ' (Tick);
2. if it fails with "postpone", then a problem is in "postpone", and >>>> the problem should be corrected in "postpone".
I explained [1] why it doesn't fail with Tick:
It's obvious that in the general case, performing execution semantics in >>>> compilation state may be inequivalent to performing these execution
semantics in interpretation state.
Apart from the difference in the contents of STATE, there must not be
a difference between the behaviour.
I don't quite understand what do you mean by this.
Consider:
: .state state @ . ;
: ]execute[ ] execute postpone [ ;
' .state ]execute[ \ print -1
' .state execute \ print 0
So code that reads STATE often behaves somewhat differently depending
on the contents of STATE, as shown above.
That's like any other global state, e.g.:
: .base-1 base @ 1- . ;
: hex-execute base @ >r hex execute r> base ! ;
: dec-execute base @ >r decimal execute r> base ! ;
' .base-1 hex-execute \ prints f
' .base-1 dec-execute \ prints 9
S" is not specified as a STATE-dependent word,
so for it there should be no difference.
Ruvim <ruvim.pinka@gmail.com> writes:
On 2022-10-08 15:39, Anton Ertl wrote:
On 2022-10-01 17:27Z, Ruvim wrote:
But concerning 's"' (and other combined words) the paper only says (in >>>> the section 3, on page 3):
| This definition behaves correctly as long as it
| is only processed by the text interpreter,
| but it fails with ', postpone, etc.,
| as discussed in Section 2.
This reasoning is wrong:
1. actually, it does not fail with ' (Tick);
2. if it fails with "postpone", then a problem is in "postpone", and >>>> the problem should be corrected in "postpone".
I explained [1] why it doesn't fail with Tick:
It's obvious that in the general case, performing execution semantics in >>>> compilation state may be inequivalent to performing these execution
semantics in interpretation state.
(¹)And we don't have any ground to say
that they should be equivalent in the case of the s" word, since the
execution semantics for s" are not specified by the standard.
Possibly, but ' arguably should produce an execution token for the
interpretation semantics of a word.
"... for the interpretation semantics" — it's too loose wording. It
isn't a verifiable proposition.
' s" execute bla" type \ prints "bla"
and
: ]execute[ ] execute postpone [ ;
' s" ]execute[ bla" type \ prints "bla"
works as intended on Gforth, iForth, VFX64, but not on SwiftForth.
Probably you want to say that executing in interpretation state the
execution token that Tick returns for a word shall perform the
interpretation semantics for this word. (²)
No. I want to say that EXECUTEing the xt returned by tick performs
the interpretation semantics of the word.
Arguments for that position:
1) 6.1.0070 ' says:
|When interpreting, ' xyz EXECUTE is equivalent to xyz.
So when interpreting,
' S" execute bla"
is equivalent to
S" bla"
BTW, what's not verifiable here?
Yes. But, as mentioned above, if you want to have your STATE-smart S"
and S\" become standard, make a proposal that allows such an
implementation.
- anton
Ruvim <ruvim.pinka@gmail.com> writes:[...]
On 2022-10-08 15:39, Anton Ertl wrote:
On 2022-10-01 17:27Z, Ruvim wrote:
But concerning 's"' (and other combined words) the paper only says (in >>>> the section 3, on page 3):
| This definition behaves correctly as long as it
| is only processed by the text interpreter,
| but it fails with ', postpone, etc.,
| as discussed in Section 2.
This reasoning is wrong:
1. actually, it does not fail with ' (Tick);
2. if it fails with "postpone", then a problem is in "postpone", and >>>> the problem should be corrected in "postpone".
I explained [1] why it doesn't fail with Tick:
It's obvious that in the general case, performing execution semantics in >>>> compilation state may be inequivalent to performing these execution
semantics in interpretation state.
(¹)And we don't have any ground to say
that they should be equivalent in the case of the s" word, since the
execution semantics for s" are not specified by the standard.
Possibly, but ' arguably should produce an execution token for the
interpretation semantics of a word.
"... for the interpretation semantics" — it's too loose wording. It
isn't a verifiable proposition.
' s" execute bla" type \ prints "bla"
and
: ]execute[ ] execute postpone [ ;
' s" ]execute[ bla" type \ prints "bla"
If you think, Forth-94 TC meant STATE-independent execution semantics
for 's"', then they failed to specify it that way.
I actually think that they wanted to allow STATE-smart implementation
of S", but they failed to specify it that way.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 53:33:22 |
Calls: | 6,712 |
Files: | 12,243 |
Messages: | 5,355,268 |