Re: Win32Forth defect in (LOCAL)?
  Home FAQ Contact Sign in
comp.lang.forth only
 
Advanced search
POPULAR GROUPS

more...

 Up
Re: Win32Forth defect in (LOCAL)?         

Group: comp.lang.forth · Group Profile
Author: Stephan Becher
Date: Sep 1, 2008 23:46

> "Alex McDonald" rivadpm.com> schrieb im Newsbeitrag
> news:0939f2ce-9f21-4b5d-b99b-3b14665e2e9f@56g2000hsm.googlegroups.com...
> On Aug 23, 3:52 pm, "Stephan Becher" > 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
no comments
diggit! del.icio.us! reddit!