home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.fortran
- Path: sparky!uunet!rational.com!voltaire!davidm
- From: davidm@voltaire.Rational.COM (David Moore)
- Subject: Re: Whats the difference between STATIC variables and SAVE variables?
- Message-ID: <davidm.721420889@voltaire>
- Sender: news@rational.com
- Organization: Rational
- References: <1992Nov7.161830.7705@netcom.com> <davidm.721341404@voltaire> <BxHG3I.M8r@ux1.cso.uiuc.edu>
- Date: Tue, 10 Nov 1992 18:41:29 GMT
- Lines: 36
-
- ercolessi@uimrl3.mrl.uiuc.edu (furio ercolessi) writes:
-
- >In article <davidm.721341404@voltaire>, davidm@voltaire.Rational.COM (David Moore) writes:
- >|>I have seen programs which assume that parameters passed once will remain
- >|>bound on subsequent calls to entry statements which lack those parameters.
- >|>For example, this is sometimes used to allocate memory dynamically. When you
- >|>find such a program, locate the original card deck, drop from the top of a tall
-
- >if you use SAVE, what's wrong with this technique ?
- >you can do poor man's "packages". i find them very useful when you
- >have data that you do not want to expose to the whole world, and you want
- >to act on them in many ways. example:
-
- > call histogram_initialize(n,xmin,xmax)
- > ...
- > do i=...
- > ...
- > call histogram_accumulate(x(i))
- > ...
- > enddo
- > call histogram_output
- >
- >and the histogram array (SAVEd, of course) is local to the 'histogram' package,
- >which is a single routine with three entry points.
- >I have this in a lot of programs and find it useful.
-
- The point is that the actual-formal binding goes away; you can make copies of
- the values in SAVE variables; this is fine, but if you tried to use "n",
- "xmin" and "xmax" in histogram_accumulate or _output, on most compilers, they
- will no longer be bound. Any program that does assume they remain bound is
- not only non-conforming, but it relies on parameters being passed in a
- particular (and rather inefficient) way; namely that an array of parameter
- pointers is statically allocated and written into whenever the routine is
- called.
-
- Risc compilers will typically pass parameters in registers.
-