Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!uunet!willett!ForthNet From: ForthNet@willett.UUCP (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: Advanced Beginners Message-ID: <582.UUL1.3#5129@willett.UUCP> Date: 1 Mar 90 02:02:35 GMT Organization: Latest link in the ForthNet chain. (Pgh, PA) Lines: 30 Date: 02-27-90 (10:02) Number: 1609 (Echo) To: IAN GREEN Refer#: 1608 From: STEVE PALINCSAR Read: NO Subj: ADVANCED BEGINNERS Status: PUBLIC MESSAGE You can't use an undefined word. Since you're talking about variables here, and since they are forth words, they need to be defined. If you tried to use an undefined word, the outer interpreter would simply give you an error message. OTOH, you don't "allocate space on the stack." You put numbers on the stack, and the stack itself takes care of management of the memory. Actually, the code example given (with N 1 DO ) wouldn't work with a variable (since you must use @ to get the value of the variable) but would instead set up a loop that looped from 1 to 1 less than the numeric value of the address of the variable N, which isn't what you wanted to do at all! OTOH some forths have a data structure called a VAR which instead of returning its address on the stack when it is invoked instead returns the value stored at that address. Forth constants also return the value instead of the address. It's also useful to know that you aren't dealing with variables in a loop. The actual values for the starting and ending points of the loop _as numbers_ must be on the parameter stack, since DO wants two arguments; and DO puts those two values on the return stack. Similarly, I (which gets at the current index of the inner loop) and J (which gets at the current index of the outer loop) are not variables either, but instead are words which copy the current index value from the Rstack. ----- This message came from GEnie via willett through a semi-automated process. Report problems to: 'uunet!willett!dwp' or 'willett!dwp@gateway.sei.cmu.edu'