Re: MODULEand USE versus Argument Passing
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Wed, 29 Jun 2005 14:28:25 -0700
E. Robert Tisdale wrote:
(snip)
Global variables are *always* a bad idea. Never pass function arguments through modules or common storage.
There is an old saying that goes something like "All generalizations are bad, including this one."
I would agree that global variables are often overused.
There are cases where the whole program revolves around certain
variables, usually arrays. In those cases, it sometimes makes
sense. COMMON, though, requires compile time dimensions which isn't
so convenient in many cases. In C one would use a global pointer variable. I am not sure that Fortran allows either pointers or
ALLOCATABLE data in COMMON, but it might.
The general rule that the code should be written so that it is easiest to understand still applied. Sometimes that means global variables.
-- glen
.
- Follow-Ups:
- Re: MODULEand USE versus Argument Passing
- From: James Giles
- Re: MODULEand USE versus Argument Passing
- References:
- MODULEand USE versus Argument Passing
- From: Herman D . Knoble
- Re: MODULEand USE versus Argument Passing
- From: E. Robert Tisdale
- MODULEand USE versus Argument Passing
- Prev by Date: backslash-issues
- Next by Date: Re: MODULEand USE versus Argument Passing
- Previous by thread: Re: MODULEand USE versus Argument Passing
- Next by thread: Re: MODULEand USE versus Argument Passing
- Index(es):
Relevant Pages
|