Local variables

39 views
Skip to first unread message

The Beez

unread,
Dec 13, 2024, 8:57:31 AM12/13/24
to 4tH-compiler
Hi 4tH-ers!

We've had various forms of local variables in the repository for years, including GLOCAL.4TH. While researching a "Back & Forth" video I wondered how far you can push this concept, using the preprocessor. So, I developed three variants:

LOCALS.4PP, this one allows for local variables, using the most popular words, { }, you need to initialize variables by hand;

XLOCALS.4PP, like LOCALS.4PP - but it also supports "|", so local variables are automatically initialized;

ALOCALS.4PP, like XLOCALS.4PP, but (almost) Forth-200x compliant in the form {: :}. Local variables also behave like VALUES, instead of VARIABLES.

The only quirky thing is that routines using this syntax need to be terminated with a double semicolon (;;) instead of a single one (;). I think that's a very small price to pay.

You know how I feel about local variables, so there is little chance I'll use this myself - except when porting. But if you do not agree with me, we got support now.

Hans Bezemer


Reply all
Reply to author
Forward
0 new messages