[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gforth] my vsum function is suspiciously non-local

From: Anton Ertl
Subject: Re: [gforth] my vsum function is suspiciously non-local
Date: Sun, 7 Mar 2010 21:50:41 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

On Sun, Mar 07, 2010 at 03:31:15PM -0500, Josh Grams wrote:
> Note also that global variables aren't frowned upon in Forth as they are
> in other languages.  Certainly you need to be aware of when they are a
> problem (and vsum is probably one of these places).

It also depends on the approach to programming.  If you are Chuck
Moore, or someone from that school, you keep the whole application in
your head, and ruthlessly eliminate as much complexity (and
requirements) as is necessary to do that, and don't reuse code, only
concepts, then global variables are much less of a problem than for
other people.

OTOH, if you have more conventional goals in mind, like writing an
extendible program or a reusable component, and let application
complexity grow as far as your programming approach and customer
budget lets it, then global variables become a significant burden,
because they make a program much harder to understand and maintain.

> But the general philosophy is that since everything is a word, it's fine
> to use a global variable to begin with.  If and when you need something
> more sophisticated, replace the variable with a more sophisticated word.

Yes, that helps, and I have done that when extending a program in new
directions, but the result is still messy.

BTW, these kinds of general discussions are not very Gforth-specific
and would see a wider audience in comp.lang.forth.

- anton

reply via email to

[Prev in Thread] Current Thread [Next in Thread]