robertd@tektronix.UUCP (08/30/84)
-------------
Just for the record, the ANSI/IEEE Joint Pascal Committee is X3J9. X3J11 is
the "C" committee.
Regarding the J&W User Manual suggestion that actual parameters passed to 'var'
formal parameters be "distinct", two points:
First, the User Manual section was exactly that, not a definition of the
language. As such, it includes style suggestions like this, which seems
to be suggesting that "aliasing" of variables should be avoided.
Second, such a restriction is not possible to enforce without examining
the data flow of a program. Consider the following example:
var
x: integer;
procedure twovars( var a, b: integer);
begin
{ don't care }
end;
procedure sneaky( var p: integer);
begin
twovars( p, x); { aliasing ! }
end;
begin
sneaky( x);
end;
Here the passing of x as a var parameter to sneaky results in the call to
twovars passing x as both actual parameters. It can certainly be argued that
passing global variables as parameters opens the way for such aliasing, but
I doubt anyone will seriously suggest prohibiting it. There are certainly
programs that make use of passing (more) global variables as well as
aliasing.
Regarding assignment to value parameters: This is practice that amounts
to style preference. I too have been bitten by forgeting to make a parameter
'var', but at the same time I have made use of such assignments. A value
parameter IS a local copy of the actual parameter. The best way to find this
problem (without changing the language and breaking a lot of existing programs)
is to either use a good cross-reference that shows assignments, or bug the
author of your compiler to (optionally!) provide a warning when a value
parameter is assigned a value.
Bob Dietrich
Tektronix, Inc.
(503) 629-1727
{ucb or dec}vax!tektronix!robertd uucp address
robertd@tektronix csnet address
robertd.tektronix@rand-relay arpa address