| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| While trying to validate my new ANS Forth implemention of StrongForth on Win32Forth, I stumbled over an issue with (LOCAL). The generated code didn't work, and I finally found out that even the sample definition of LOCALS| from appendix A15 of the ANS Forth spec doesn't work correctly: Win32Forth: a Forth for Windows 95/98/ME/NT/2K/XP Version: 6.12.00 Build: 2 Compiled: Samstag, August 23 2008, 4:18 Platform: Windows XP, 821k bytes free 2,885 Words in Application dictionary 2,332 Words in System dictionary 5,217 Words total in dictionaries 20,312 Windows Constants available Current directory: C:\Programme\Win32Forth\extsrc\wincon\winconcpp Loading Win32For.CFG Loading Win32ForUser.CFG Program path is: C:\Programme\Win32Forth\Win32For.EXE Forth path is: C:\Programme\Win32Forth\ Application path is: System Editor is: Win32Forth IDE WARNING OFF SYS-WARNING-OFF ok : EXAMPLE ( n -- n n**2 n**3 ) LOCALS| N | N DUP N * DUP N * ; ok 5 EXAMPLE . . . 125 25 5 ok : LOCALS| ( "name...name |" -- ) BEGIN BL WORD COUNT OVER C@ [CHAR] | - OVER 1 - OR WHILE (LOCAL) REPEAT 2DROP 0 0 (LOCAL) ; ok IMMEDIATE ok : EXAMPLE ( n -- n n**2 n**3 ) LOCALS| N | N DUP N * DUP N * ; ok 5 EXAMPLE . . . 0 0 0 ^ Error(-4): . stack underflow 4 5 EXAMPLE . . . 64 16 4 ok ..S empty ok It seems the runtime code of this redefined version of LOCALS| swallows one cell from the stack. Is this a known defect? Regards, Stephan |
|
#2
| |||
| |||
| On Aug 23, 3:52*pm, "Stephan Becher" <stephan.remove-this.bec...@t- online.de> wrote: > While trying to validate my new ANS Forth implemention of StrongForth on > Win32Forth, I stumbled over an issue with (LOCAL). The generated code didn't > work, and I finally found out that even the sample definition of LOCALS| > from appendix A15 of the ANS Forth spec doesn't work correctly: > > Win32Forth: a Forth for Windows 95/98/ME/NT/2K/XP > Version: 6.12.00 Build: 2 > Compiled: Samstag, August 23 2008, 4:18 > Platform: Windows XP, 821k bytes free > *2,885 Words in Application dictionary > *2,332 Words in System dictionary > *5,217 Words total in dictionaries > 20,312 Windows Constants available > Current directory: C:\Programme\Win32Forth\extsrc\wincon\winconcpp > Loading Win32For.CFG > Loading Win32ForUser.CFG > > Program path is: * * C:\Programme\Win32Forth\Win32For.EXE > Forth path is: * * * C:\Programme\Win32Forth\ > Application path is: > > System Editor is: * *Win32Forth IDE > > WARNING OFF SYS-WARNING-OFF *ok > : EXAMPLE *( n -- n n**2 n**3 ) > * * LOCALS| N | * N *DUP N * *DUP N * ; *ok > 5 EXAMPLE . . . 125 25 5 *ok > : LOCALS| *( "name...name |" -- ) > * * BEGIN > * * * BL WORD * COUNT OVER C@ > * * * [CHAR] | - OVER 1 - OR > * * WHILE > * * * (LOCAL) > * * REPEAT 2DROP * 0 0 (LOCAL) > ; *ok > IMMEDIATE *ok > : EXAMPLE *( n -- n n**2 n**3 ) > * * LOCALS| N | * N *DUP N * *DUP N * ; *ok > 5 EXAMPLE . . . 0 0 0 > * * * * * * * ^ > Error(-4): . stack underflow > 4 5 EXAMPLE . . . 64 16 4 *ok > .S *empty *ok > > It seems the runtime code of this redefined version of LOCALS| swallows one > cell from the stack. Is this a known defect? > > Regards, > Stephan Yes, it looks like a bug. However, it's probably not going to get fixed for some time I suspect, as (LOCALS) isn't used in user code. : LOCALS| ( -- ) \ ANS standard locals LOCALS-INIT FALSE TO LOCDIR \ reversed stack order BEGIN BLNEXTWORD 2DUP S" |" STR= INVERT WHILE (LOCAL) \ declare a local REPEAT 2DROP PARMS, \ compile runtime code (equiv of 0 0 (LOCAL)) ; IMMEDIATE There's a bit of jiggery pokery goes on in the standard definition of LOCALS| as you can see. -- Regards Alex McDonald |
|
#3
| |||
| |||
| > "Alex McDonald" <blog@rivadpm.com> schrieb im Newsbeitrag > news:0939f2ce-9f21-4b5d-b99b-3b14665e2e9f@56g2000hsm.googlegroups.com... > On Aug 23, 3:52 pm, "Stephan Becher" <stephan.remove-this.bec...@t- > online.de> wrote: > > While trying to validate my new ANS Forth implemention of StrongForth on > > Win32Forth, I stumbled over an issue with (LOCAL). The generated code > > didn't > > work, and I finally found out that even the sample definition of LOCALS| > > from appendix A15 of the ANS Forth spec doesn't work correctly: > > > > Win32Forth: a Forth for Windows 95/98/ME/NT/2K/XP > > Version: 6.12.00 Build: 2 > > Compiled: Samstag, August 23 2008, 4:18 > > Platform: Windows XP, 821k bytes free > > 2,885 Words in Application dictionary > > 2,332 Words in System dictionary > > 5,217 Words total in dictionaries > > 20,312 Windows Constants available > > Current directory: C:\Programme\Win32Forth\extsrc\wincon\winconcpp > > Loading Win32For.CFG > > Loading Win32ForUser.CFG > > > > Program path is: C:\Programme\Win32Forth\Win32For.EXE > > Forth path is: C:\Programme\Win32Forth\ > > Application path is: > > > > System Editor is: Win32Forth IDE > > > > WARNING OFF SYS-WARNING-OFF ok > > : EXAMPLE ( n -- n n**2 n**3 ) > > LOCALS| N | N DUP N * DUP N * ; ok > > 5 EXAMPLE . . . 125 25 5 ok > > : LOCALS| ( "name...name |" -- ) > > BEGIN > > BL WORD COUNT OVER C@ > > [CHAR] | - OVER 1 - OR > > WHILE > > (LOCAL) > > REPEAT 2DROP 0 0 (LOCAL) > > ; ok > > IMMEDIATE ok > > : EXAMPLE ( n -- n n**2 n**3 ) > > LOCALS| N | N DUP N * DUP N * ; ok > > 5 EXAMPLE . . . 0 0 0 > > ^ > > Error(-4): . stack underflow > > 4 5 EXAMPLE . . . 64 16 4 ok > > .S empty ok > > > > It seems the runtime code of this redefined version of LOCALS| swallows > > one > > cell from the stack. Is this a known defect? > > > > Regards, > > Stephan > > Yes, it looks like a bug. However, it's probably not going to get > fixed for some time I suspect, as (LOCALS) isn't used in user code. > > ... On the other hand, if someone wishes to implement and use an alternative word for LOCALS|, he or she has to rely on (LOCAL) to work as specified. Here's an example: \ LOCALS( ... ) is an alternative to LOCALS| ... | that accepts \ the local names in the "correct" order. For example, \ ... ( n1 n2 n3 -- ) LOCALS( A B C ) ... assigns n1 to A, n2 to \ B and n3 to C. : (LOCALS) PARSE-WORD 2DUP S" )" COMPARE IF RECURSE (LOCAL) ELSE 2DROP THEN ; : LOCALS( (LOCALS) 0 0 (LOCAL) ; IMMEDIATE The actual problem I have with Win32Forth is that my implementation of StrongForth in ANS Forth is system code. It uses the host system's version of (LOCAL) in order to implement StrongForth's type-save version of LOCALS| that allows arbitrarily mixing single-cell, double-cell and floating-point locals. So far, I successfully validated StrongForth on GForth and SwiftForth, but as long as (LOCAL) remains broken, it will definitely not run on Win32Forth. Regards, Stephan |
|
#4
| |||
| |||
| On Sep 1, 9:57*pm, Alex McDonald <b...@rivadpm.com> wrote: > On Aug 23, 3:52*pm, "Stephan Becher" <stephan.remove-this.bec...@t- > > > > Yes, it looks like a bug. However, it's probably not going to get > fixed for some time I suspect, as (LOCALS) isn't used in user code. > Actually it's already been fixed in the win32forth CVS. > : LOCALS| * * * ( -- ) * * * * * * * * * * * * \ ANS standard locals > * * * * LOCALS-INIT > * * * * FALSE TO LOCDIR * * * * * * * * * * * *\ reversed stack order > * * * * BEGIN BLNEXTWORD > * * * * * * * 2DUP S" |" STR= INVERT > * * * * WHILE > * * * * * * * * (LOCAL) * * * * * * * * * * * *\ declare a local > * * * * REPEAT *2DROP > * * * * PARMS, * * * * * * * * * * * * * * * * \ compile runtime code > (equiv of 0 0 (LOCAL)) > * * * * ; IMMEDIATE > > There's a bit of jiggery pokery goes on in the standard definition of > LOCALS| as you can see. > it just needed the first two lines moving to (LOCAL) and made conditional on only being executed for the first local. The original (LOCAL) is now {LOCAL} since it's used (with different initialisation) by {. > -- > Regards > Alex McDonald George Hubert |
|
#5
| |||
| |||
| The next definition is LOCALS|...| based : : reverse-params| ( -- ) 0 BEGIN >IN @ TOKEN S" )" COMPARE WHILE SWAP 1+ REPEAT DROP >IN @ >R 0 ?DO >IN ! TOKEN PAD APPEND S" " PAD APPEND LOOP S" |" PAD APPEND R> >IN ! ; : LOCALS( ( -- ) S" LOCALS| " PAD PLACE reverse-params| PAD COUNT EVALUATE ; immediate "Stephan Becher" <stephan.remove-this.becher@t-online.de> a écrit dans le message de news: g8p874$7n1$00$1@news.t-online.com... > While trying to validate my new ANS Forth implemention of StrongForth > on Win32Forth, I stumbled over an issue with (LOCAL). The generated > code didn't work, and I finally found out that even the sample > definition of LOCALS| from appendix A15 of the ANS Forth spec doesn't > work correctly: |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.