Article View: net.lang.pascal
Article #90Re: X3J9 (Pascal) loops
From: robertd
Date: Thu, 30 Aug 1984 18:31
Date: Thu, 30 Aug 1984 18:31
53 lines
2813 bytes
2813 bytes
-------------
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
Technical Details
Message-ID:
<3506@tektronix.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!hogpc!houti!ariel!vax135!cornell!uw-beaver!tektronix!robertdReferences:
<2356@dartvax.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 (Tek) 9/26/83; site tektronix.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!hogpc!houti!ariel!vax135!cornell!uw-beaver!tektronix!robertd From: robertd@tektronix.UUCP Newsgroups: net.lang.pascal Subject: Re: X3J9 (Pascal) loops Message-ID: <3506@tektronix.UUCP> Date: Thu, 30-Aug-84 14:31:53 EDT Article-I.D.: tektroni.3506 Posted: Thu Aug 30 14:31:53 1984 Date-Received: Sat, 1-Sep-84 11:44:15 EDT References: <2356@dartvax.UUCP> Organization: Tektronix, Beaverton OR Lines: 53