[OpenBIOS] [PATCH] Adds local variable support to OpenBIOS.

Segher Boessenkool segher at kernel.crashing.org
Tue Aug 28 08:50:06 CEST 2012

>>> And don't use CamelCase.
>> Is this some official naming convention, or your own taste?
> In general (at least in the 1275 world), Forth is case-insensitive.

Almost all Forth systems, and all the modern ones, yes.

> The rare cases where it is made case sensitive (there are a couple  
> in Sun's Openboot - see dropins.src) make use of mixed case very  
> painful. The general standard is that methods and variables are  
> lower case, defined constants and structure offsets are upper case.  
> In some code, even they are lower case.
> Mixed-case is generally confined to comments.

Some people write e.g. "Constant".  There is nothing wrong
with that.  But you should write "a-long-name" and not
"ALongName" or "alongname".  It's much more readable.

FWIW, I write CONSTANT and REPEAT etc. so that the defining
words and structure words really stand out when you read the
code, making the structure more obvious.  Not everyone likes
that, and that is of course fine :-)

>>> Factor this?  You shouldn't ever use a variable that is used as a  
>>> temp
>>> inside a word.
>> I'm not sure why you suggest this. It is just such a pain having  
>> to deal with the stack.
> Because using a global variable gets you in trouble in recursion or  
> when the same code is called at alarm level.

It's also a red flag warning for not properly structured code.
Global vars can be useful for passing state between words, but
from a word to itself?  It must be doing way too much.

[SNIP lots of good stuff]


More information about the OpenBIOS mailing list