[OpenBIOS] Local variable support

Segher Boessenkool segher at kernel.crashing.org
Sat Aug 25 15:32:01 CEST 2012

> Actually after I little research, this isn't the right approach  
> after all - apparently the variables are stored on the return  
> stack: http://www.softsynth.com/pforth/pf_ref.php#Local%20Variables% 
> 20{%20foo%20--}.

Putting locals on the return stack is only one implementation
strategy: many more are possible.  Apple's OF uses a separate
stack (well, sort-of a stack, anyway) for it.  If you plan to
use locals a lot (very very bad plan in Forth code, IMNSHO), a
separate stack is most likely the cheapest way to do it (in code
space, code time, developer time, and developer sanity).  One
reason to use locals a lot is when you compile e.g. C code to
FCode; it is almost never convenient to use locals in well-designed
Forth code.

The advantages of putting the locals on an existing stack all
boil down to it being an existing stack: you do not have to set
up a stack for it, to size that stack, to handle it in CATCH/THROW,


More information about the OpenBIOS mailing list