> Date: Wed, 21 Feb 2001 11:20:45 -0800
> From: Van Snyder <[log in to unmask]>
> Subject: Constructive use for INCLUDE (was "How to compile with MODULE")
> There has been some traffic expressing an opinion that INCLUDE ought to
> be obsolescent.
>
> I have found a constructive use for it, that is not served by modules:
> INCLUDE can be used to simulate part of the facility called a "template"
> in C++ or a "generic" in Ada.
The use of an INCLUDE file (to contain only the body of a procedure).
with declarations of relevant variables for two procedures in the source code
is suggested in my book "Introduction to Fortran 90/95, Algorithms, and
Structured Programming", ISBN 0-9596384-8-2, published in 1996. Only in
that case, the code is a Shell sort.
> Suppose you have, say, a QuickSort routine. Doing it "right" isn't
> a small code -- you want both the Hibbard and Sedgewick modifications.
> So, if you have a new type that needs sorting, you would rather not
> duplicate everything. Sure, it's easy to duplicate with a cut-and-
> paste command in your favorite editor. But then you have the possibility
> of unplanned divergence as the result of maintenance.
>
> What I do in this circumstance is to put the body of the procedure in
> an INCLUDE file. This may include some of the local variables -- ones
> such as loop counters, etc., but not temporary variables of the type
> being sorted.
>
> For each type I write a procedure header, with declarations of the
> dummy arguments (at least the ones that are of the "generic" type),
> and temporary variables of the "generic" type. Then I include the
> procedure body, and finally the end statement.
> --
> What fraction of Americans believe | Van Snyder
> Wrestling is real and NASA is fake? | [log in to unmask]
> Any alleged opinions are my own and have not been approved or disapproved
> by JPL, CalTech, NASA, Dan Goldin, George Bush, the Pope, or anybody else.
>
|