Robert Epprecht wrote:
> In Gforth I use (I hope that's still OK?):
> : xt>string ( xt -- addr length )   look IF name>string THEN ;

Should work, but

: xt>string ( xt -- addr length )
 >name ?dup-if
   name>string 
 endif ;

is preferred.

> But then it suddenly does not work on one of my VARIABLEs
> after having worked well on many others before...
> [ ... time passes ...  Ah, I see: ]
> 
> It seems that LOOK returns FALSE for names longer than 29 chars.
> 
> 
> So I think I must shorten my word names,
> or will you change LOOK ?

That's just a buglet that you can fix with the patch below.  How long
do you want the names?  I have just tested, and even with unlimited
length (except by Forthstart) I did not get false positives.  However,
this would slow down >NAME (when there is no match), and on some
platforms there might be more false positives (in particular, on
platforms where some valid addresses are near $80000000).

Hmm, maybe we should remember the longest defined name somewhere and
use that for determining how far we should go.

Anyway, for now you can change the value 41 below to the desired name
length+9.

- anton

Here's the patch:
Index: kernel/int.fs
===================================================================
RCS file: /usr/local/lib/cvs-repository/src-master/gforth/kernel/int.fs,v
retrieving revision 1.95
diff -u -r1.95 int.fs
--- int.fs      2003/02/01 14:28:08     1.95
+++ int.fs      2003/02/04 22:33:33
@@ -388,7 +388,7 @@
 
 : >head-noprim ( cfa -- nt ) \ gforth  to-head-noprim
     \ also heuristic; finds only names with up to 32 chars
-    $25 cell do ( cfa )
+    dup forthstart - 41 min cell max cell ?do ( cfa )
        dup i - dup @ [ alias-mask lcount-mask or ] literal
        [ 1 bits/char 3 - lshift 1 - 1 bits/char 1 - lshift or
        -1 cells allot bigendian [IF]   c, -1 1 cells 1- times


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to