Re: VALUE and TO implementation

Liste des GroupesRevenir à cl forth 
Sujet : Re: VALUE and TO implementation
De : ruvim.pinka (at) *nospam* gmail.com (Ruvim)
Groupes : comp.lang.forth
Date : 01. Aug 2024, 01:21:30
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v8ekea$1po8g$1@dont-email.me>
References : 1 2 3 4 5 6 7
User-Agent : Mozilla Thunderbird
On 2024-07-31 21:33, Anton Ertl wrote:
Ruvim <ruvim.pinka@gmail.com> writes:
A testcase:
>
   : apply-compiling(to) ( sd.name -- )
     [: postpone to ;] execute-parsing
   ;
 The standard says (in 6.2.2295):
 |An ambiguous condition exists if any of POSTPONE, [COMPILE], ' or [']
|are applied to TO.
Yes, that is why I added the note below.
  >> NB: "postpone" can be defined in a standard way via "find-name" so that
is apples to "to" [2].
 But FIND-NAME is not in Forth-2012.
Yes. But "find-name" has already been accepted, and, anyway, it can be implemented via "get-order" and "traverse-wordlist".

Maybe those who like this kind of
TO implementation will make a proposal that means that you cannot
POSTPONE TO with a user-defined POSTPONE.
How? Disallow obtaining the name token for "to"? That's a very weak approach.
It seems, it is possible to test whether "to" is parsing, and if not, redefine it to provide a parsing "to" in a standard system.
I came up with the following test:
   0 value _v1 immediate
   0 value _v2
   : test(to)
     1 1
     [ 1 ] to _v1 _v2 [ ( 1 | 1 0 ) ?dup 2drop ]
     ( 1 | 1 0 ) ?dup 2drop
   ;
   test(to) _v2 [if]
     .( ["to" is not a parsing word] )
   [else]
     .( ["to" is a parsing word] )
   [then]
Suddenly, compilation of "test(to)" failed in VfxForth, version
VFX Forth 64 5.43 [build 0199] 2023-11-09 for Linux x64
So, either this "test(to)" or VfxForth is not standard compliant.
I changed "test(to)" to make it compilable in VfxForth:
   : ndrop ( i*x u.i -- ) 0 ?do drop loop ;
   2 value _v1 immediate
   0 value _v2
   : test(to) ( -- )
     depth >r 1
     [ 0 1 ] to _v1 _v2 [ ( 0 | 0 1 | 0 1 2 ) ndrop ]
     ( | 1 | 1 0 ) depth r> - ndrop
   ;
   \ in this point _v1 and _v2 shall be unchanged,
   \ but _v1 is changed in VfxForth
   _v1 2 <> [if]
     .( [error, _v1 is changed during compilation] )
   [then]
   _v2 0 <> [if]
     .( [error, _v2 is changed during compilation] )
   [then]
   \ Check what variable is changed by "test(to)"
   0 to _v1
   0 to _v2
   test(to)
   _v1 [if]
     .( ["to" is a parsing word] )
   [else]
   _v2 [if]
     .( ["to" is not a parsing word] )
   [else] \ neither _v1 nor _v2 is changed
     .( ["to" is implemented incorrectly] )
   [then] [then]
In this test, VfxForth falls into third case, ["to" is implemented incorrectly].
I redefined "to" in VfxForth as following:
   : to ( "ccc<name>" -- ) ( run-time: x -- )
     ' ['] to  ( xt.argument xt.to )
     state @ if compile, compile, else execute execute then
   ; immediate
And it did not change anything in the above tests!
It looks like "compile," in VfxForth still violates the standard, having unspecified detectable side effects.

Note that FIND and SEARCH-WORDLIST are alreading in Forth-94,
and TRAVERSE-WORDLIST is in Forth-2012.
As well as "name>compile" (to define "postpone").
Regarding "find" — it's possible to use "find" to implement "postpone" only if "find" is implemented in such a way that the interpreter loop from a single-xt+immediacy-flag system correctly works.
For example, the following "interpret":
   : tt-xt ( i*x xt -- j*x )
     state @ if compile, else execute then
   ;
   : tt-word ( i*x xt flag.special -- j*x )
     if execute exit then tt-xt
   ;
   : interpret ( i*x -- j*x )
     begin
       bl word find dup if 1 =
         tt-word
       else drop count dup if \ try to recognize a number
         \ ...
         -13 throw
       else 2drop exit then then
     again
   ;
--
Ruvim

Date Sujet#  Auteur
25 Jul 24 * Operator overloading?78minforth
25 Jul 24 +- Re: Operator overloading?1dxf
25 Jul 24 +* Re: Operator overloading?18Michael Raitza
25 Jul 24 i`* Re: Operator overloading?17minforth
25 Jul 24 i +* Re: Operator overloading?5mhx
25 Jul 24 i i`* Re: Operator overloading?4minforth
26 Jul 24 i i `* Re: Operator overloading?3minforth
26 Jul 24 i i  `* Re: Operator overloading?2mhx
26 Jul 24 i i   `- Re: Operator overloading?1minforth
25 Jul 24 i `* Re: Operator overloading?11Anton Ertl
25 Jul 24 i  +* Re: Operator overloading?2minforth
30 Jul 24 i  i`- Re: Operator overloading?1Ruvim
27 Jul 24 i  `* Re: Operator overloading?8minforth
27 Jul 24 i   `* Re: Operator overloading?7Anton Ertl
27 Jul 24 i    +* Re: Operator overloading?4minforth
30 Jul 24 i    i+- quotations and closures (was: Operator overloading?)1Ruvim
1 Aug 24 i    i`* Re: Operator overloading?2Anton Ertl
1 Aug 24 i    i `- Re: Operator overloading?1minforth
27 Jul 24 i    `* Re: Operator overloading?2albert
29 Jul 24 i     `- Re: Operator overloading?1minforth
26 Jul 24 +- Re: Operator overloading?1Jan Coombs
30 Jul 24 `* Re: Operator overloading?57Stephen Pelc
30 Jul 24  +* Re: Operator overloading?3minforth
30 Jul 24  i+- Re: Operator overloading?1Stephen Pelc
1 Aug 24  i`- Re: Operator overloading?1Anton Ertl
31 Jul 24  `* Re: Operator overloading?53albert
31 Jul 24   `* Re: Operator overloading?52Gerry Jackson
31 Jul 24    +* Re: Operator overloading?50mhx
31 Jul 24    i+* Re: Operator overloading?3minforth
31 Jul 24    ii`* Re: Operator overloading?2mhx
31 Jul 24    ii `- Re: Operator overloading?1mhx
31 Jul 24    i+* VALUE and TO implementation (was: Operator overloading?)45Ruvim
31 Jul 24    ii+* Re: VALUE and TO implementation (was: Operator overloading?)41Anton Ertl
1 Aug 24    iii`* Re: VALUE and TO implementation40Ruvim
1 Aug 24    iii `* Re: VALUE and TO implementation39Anton Ertl
2 Aug 24    iii  `* Re: VALUE and TO implementation38Ruvim
3 Aug 24    iii   +* Re: VALUE and TO implementation35minforth
3 Aug 24    iii   i+* Re: VALUE and TO implementation33Ruvim
3 Aug 24    iii   ii`* Re: VALUE and TO implementation32minforth
4 Aug 24    iii   ii `* Re: VALUE and TO implementation31Ruvim
4 Aug 24    iii   ii  `* Re: VALUE and TO implementation30mhx
4 Aug 24    iii   ii   +* Re: VALUE and TO implementation4Paul Rubin
4 Aug 24    iii   ii   i+* Re: VALUE and TO implementation2mhx
4 Aug 24    iii   ii   ii`- Re: VALUE and TO implementation1Ruvim
4 Aug 24    iii   ii   i`- Re: VALUE and TO implementation1Ruvim
4 Aug 24    iii   ii   +- Re: VALUE and TO implementation1Anton Ertl
4 Aug 24    iii   ii   +* Alternative for long parsing words (was: VALUE and TO implementation)9Ruvim
5 Aug 24    iii   ii   i`* Re: Alternative for long parsing words (was: VALUE and TO implementation)8albert
5 Aug 24    iii   ii   i `* Re: Alternative for long parsing words7Ruvim
5 Aug 24    iii   ii   i  +* Re: Alternative for long parsing words5Anton Ertl
6 Aug 24    iii   ii   i  i+* Re: Alternative for long parsing words2Ruvim
6 Aug 24    iii   ii   i  ii`- Re: Alternative for long parsing words1mhx
6 Aug 24    iii   ii   i  i`* Re: Alternative for long parsing words2Ruvim
9 Aug 24    iii   ii   i  i `- Re: Alternative for long parsing words1Ruvim
6 Aug 24    iii   ii   i  `- Re: Alternative for long parsing words1albert
5 Aug 24    iii   ii   +- Re: VALUE and TO implementation1Stephen Pelc
5 Aug 24    iii   ii   `* Re: VALUE and TO implementation14dxf
5 Aug 24    iii   ii    `* Re: VALUE and TO implementation13mhx
5 Aug 24    iii   ii     +* Re: VALUE and TO implementation10dxf
5 Aug 24    iii   ii     i`* Re: VALUE and TO implementation9Ruvim
6 Aug 24    iii   ii     i `* Re: VALUE and TO implementation8dxf
7 Aug 24    iii   ii     i  `* Re: VALUE and TO implementation7dxf
7 Aug 24    iii   ii     i   +* Re: VALUE and TO implementation3Anton Ertl
7 Aug 24    iii   ii     i   i+- Re: VALUE and TO implementation1dxf
7 Aug 24    iii   ii     i   i`- Interpretation semantics (was: VALUE and TO implementation)1Ruvim
7 Aug 24    iii   ii     i   `* Re: VALUE and TO implementation3albert
7 Aug 24    iii   ii     i    `* Re: VALUE and TO implementation2Paul Rubin
8 Aug 24    iii   ii     i     `- Re: VALUE and TO implementation1albert
5 Aug 24    iii   ii     `* Re: VALUE and TO implementation2Anton Ertl
6 Aug 24    iii   ii      `- Re: VALUE and TO implementation1albert
3 Aug 24    iii   i`- Re: VALUE and TO implementation1Anton Ertl
3 Aug 24    iii   `* Re: VALUE and TO implementation2mhx
4 Aug 24    iii    `- Re: VALUE and TO implementation1Ruvim
1 Aug 24    ii+* Re: VALUE and TO implementation2minforth
2 Aug 24    iii`- Re: VALUE and TO implementation1albert
1 Aug 24    ii`- Re: VALUE and TO implementation1Ruvim
31 Jul 24    i`- Re: Operator overloading?1Gerry Jackson
31 Jul 24    `- Re: Operator overloading?1Anton Ertl

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal