home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.whtech.com
/
ftp.whtech.com.tar
/
ftp.whtech.com
/
Geneve
/
9640news
/
CAT17
/
RLFRTH.ARK
< prev
next >
Wrap
Text File
|
2006-10-19
|
3KB
|
120 lines
?
.FI;LM 0;RM 79;IN +0
I just downloaded John Carver's file
FORTH$ (GEnie 661) with the FORTH
string stuff. It looks great to me;
thanks, John, for this and all the
other files you've given us.
I've been idly toying with doing
something like BASIC does for string
assignment, and reading FORTH$ fired up
my imagination again. I want to get
away from having to predetermine the
length of a string variable, so I'd do
things a little differently than does
John Burkett.
First, let's rename WLITERAL to be
called ", as it is on the Macintosh
FORTH. Then introduce the defining
word $TRING, to be used as follows:
.LM +10;RM -10
$TRING A$ ( A$ is now a string
variable)
$TRING B$ $TRING C$ ( So are B$ and
C$)
.LM -10;RM +10
We will need the string store and
fetch words $! and $@@. Then we could
write stuff like:
.LM +10;RM -10
" This is a string." A$ $! ( A$ now
contains that phrase)
B$ $@@ ( ...addr) ( the stack now
contains the address of the length byte
of a copy of the string that is stored
in B$)
A$ $@@ C$ $! ( C$ contains a copy of
A$)
A$ $@@ COUNT TYPE ( type out whatever's
in A$)
.LM -10;RM +10
With this we could forget about
preassigning lengths of strings (just
like BASIC) and do the equivalent of
BASICs A$=A$&&B$&&RPT$(.....
My idea is to use a memory manager to
help out. Any variable that wants to
use MANAGER must first report in to
it and get a token, which it must keep.
This token is sort of like a credit
card or a key to the Playboy Club -
don't lose it!
To request the manager to store your
data you would place on the stack the
token, the address of the data, and the
number of bytes to be stored.
Then you would call
the store-manager, which would remember
your data for you.
To fetch back your data, you would
place its token and a memory address on
the stack, and call the fetch-manager.
The manager would get the data from
wherever it is keeping it and give you
a copy at the place you specified.
The idea is that the memory manager
will be able to manage its own private
storage (maybe it would use a RELATIVE
disk file, maybe GRAM, RAMDISK, or
VDP?) It would have to be able to
collect garbage, just as BASIC does.
(Does anyone know how BASIC does
that?)
FORGET would have to be changed a
little, so that tokens belonging to a
word that is being forgotten could be
handed back to the manager, which would
then release their memory. ABORT would
call the manager to release all
tokens.
This manager could be used for other
than string storage, of course, but
strings seem to be the most obvious
use.
A declaration of a word as a string
would mean that a token would be
requested for it; invoking it would
place its token on the stack.
Any
Comments?
Nelson Byrne
28th Dec, 1986
)UUUUUUUUUU
HELP!
HOW DO I STOP?
?
FNCN 4 NO DO
Download complete. Turn off Capture File.