Go to the first, previous, next, last section, table of contents.


ANS Forth locals

The ANS Forth locals wordset does not define a syntax for locals, but words that make it possible to define various syntaxes. One of the possible syntaxes is a subset of the syntax we used in the Gforth locals wordset, i.e.:

{ local1 local2 ... -- comment }

or

{ local1 local2 ... }

The order of the locals corresponds to the order in a stack comment. The restrictions are:

Locals defined in this way behave like VALUEs (See section Simple Defining Words). I.e., they are initialized from the stack. Using their name produces their value. Their value can be changed using TO.

Since this syntax is supported by Gforth directly, you need not do anything to use it. If you want to port a program using this syntax to another ANS Forth system, use `compat/anslocal.fs' to implement the syntax on the other system.

Note that a syntax shown in the standard, section A.13 looks similar, but is quite different in having the order of locals reversed. Beware!

The ANS Forth locals wordset itself consists of the following word

(local)       addr u --         local       ``paren-local-paren''

The ANS Forth locals extension wordset defines a syntax, but it is so awful that we strongly recommend not to use it. We have implemented this syntax to make porting to Gforth easy, but do not document it here. The problem with this syntax is that the locals are defined in an order reversed with respect to the standard stack comment notation, making programs harder to read, and easier to misread and miswrite. The only merit of this syntax is that it is easy to implement using the ANS Forth locals wordset.


Go to the first, previous, next, last section, table of contents.