Quick Forth Question
dwight.elvey at amd.com
Tue Jan 24 15:08:19 CST 2006
>From: ard at p850ug1.demon.co.uk
>> That's odd.
>> Usually ." Hello, world." words on all forths.
>Watch out. In some Forths, ." can only be used inside a colon definition,
>not in the imput like (you get some very odd effects, possibly even a
>crash if you try). I used to know the reason for this, something about it
>needing to allocate space for the string.
>At least one Forth used " rather than ." too.
>> Keep in mind you do need the space between ." and the first letter of
>> the string, since ." is a word (a "parsing" word since it reads ahead in
>> the stream till the ending ")
>But there does not need to be a space before the closing quote (if there
>is one, it will be output as part of the string)
As an example, : HI ." HELLO WORLD" ;
should echo when you enter the word HI.
>> Might help. Sometimes you can also type WORDS at the command prompt and
>> see all the words.
Tony mentions VLIST but I've also seen WORDS or LIST used for
this function as well.
As for filenames, this is something that each implementation
does differently. If you can get a VLIST, we can most likely
figure out what is going on.
Some simple test.
100 CONSTANT FRED ( should create the constant FRED )
FRED . ( should print 100 )
200 VARIABLE SAM ( should create the variable SAM but
depending on implementation it may or
may not initialize the value to 100 )
SAM @ . ( should display the value 200 )
300 SAM ! ( should store 300 to SAM )
SAM ? ( if implemented should display the value in SAM )
SAM . ( displays the address of SAM )
Anyway, try to get a complete list of words with something like
VLIST. It'll pick up things like single character words like
! or . that would otherwise be hard to find.
As was mentioned, even though it may only store 4 characters
of a word, most times it also stores the length so even though
VARI doesn't work VARIABLE should work ( even VARIXXXX would
do the same ).
I like Forth but I think the truncated names are a pain.
It would be better to have the first 3 letters and a hash
of the word as a last byte. I guess for a memory constrained
system, one has trade-offs.
More information about the cctech