gforth
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gforth] ORDER bug


From: Bernd Paysan
Subject: Re: [gforth] ORDER bug
Date: Thu, 17 Nov 2011 19:07:23 +0100
User-agent: KMail/4.7.2 (Linux/3.1.0-1.1-desktop; KDE/4.7.2; x86_64; ; )

Am Donnerstag, 17. November 2011, 17:11:28 schrieb Anton Ertl:
> I have now tested where the two versions produce different results
> (which is either a false positive or a false negative for one of the
> versions).  Program below.  On my system running this as follows
> produces the following results:
> 
> [~/gforth:76417] gforth xxx.fs -e "test bye" |grep "new accepts as head"|wc
> -l 781
> [~/gforth:76418] gforth xxx.fs -e "test bye" |grep "old accepts as head"|wc
> -l 4546
> 
> So both versions differ by a lot, and given that the old version does
> not produce false negatives, the new version obviously produces at
> least 781 false positives.  That's a lot, given that there are only
> 2987 names in the hash table.
> 
> Also, the new test recognizes 3634 names in the dictionary; the
> difference from the hash table population is only 647.  The difference
> from the 781 number above can be explained by 134 false negatives from
> the new version, and/or by false negatives from the old version.

This here should be better, this checks if the cfa points into the code for 
primitives or is a code word.  It also give special treatment to aliases (when 
the alias-mask bit is cleared), and checks if the name consists of printable 
characters only.

: new-head? ( addr -- f )
\G heuristic check whether addr is a name token; may deliver false
\G positives; addr must be a valid address
    dup dup aligned <>
    if
        drop false exit \ heads are aligned
    then
    dup cell+ @ alias-mask and 0= >r
    name>string dup $20 $1 within if
        rdrop 2drop false exit \ realistically the name is short
    then
    cfaligned 2dup bounds ?do \ should be a printable string
        i c@ bl < if
            2drop unloop rdrop false exit
        then
    loop
    + r> if \ check for valid aliases
        @ dup forthstart here within
        over ['] noop ['] lit-execute 1+ within or
        over dup aligned = and
        0= if
            drop false exit
        then
    then \ check for cfa - must be code field or primitive
    dup @ tuck 2 cells - = swap
    docol:  ['] lit-execute @ 1+ within or ;

Since it must be now safe to print out the names found, we can do the 
following:

: wordsnew
    here forthstart do
        i new-head? if i .name cr then
    loop ;

This should be a pretty strict test, and at least it won't do any harm to do a 
.name on it, even if it still is a false positive.

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]