Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site dartvax.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!dartvax!alexc
From: alexc@dartvax.UUCP (Alex Colvin)
Newsgroups: net.unix-wizards,net.lang
Subject: Re:  smart compilers
Message-ID: <2676@dartvax.UUCP>
Date: Sun, 6-Jan-85 13:05:17 EST
Article-I.D.: dartvax.2676
Posted: Sun Jan  6 13:05:17 1985
Date-Received: Tue, 8-Jan-85 02:52:07 EST
References: <6599@brl-tgr.ARPA> <979@opus.UUCP> <1146@ut-ngp.UUCP> <18397@lanl.ARPA> <472@intelca.UUCP>
Organization: Dartmouth College, Hanover, NH
Lines: 24
Xref: watmath net.unix-wizards:11381 net.lang:1207

(intelca.472) mentions what can only be called a horrendous  com-
piler  bug.   That one has been known since roughly FORTRAN II --
namely passing constants by reference.  The solution  adopted  by
most  such  languages  (FORTRAN,PL/I) is to always pass copies of
the constant.

Please understand that the aforementioned compiler is NOT  optim-
izing.  It is compiling incorrect code.

The DTSS PL/I compiler does  the  correct  optimization  in  this
case.  Iff the interprocedure analysis detects that a (reference)
parameter is not modified, then it passes constant  arguments  by
reference,  without  forcing  a copy.  This is done ONLY if it is
known to be safe.

As to passing constants, I see nothing wrong with it.   I  prefer
it  to  passing  variables.  At least with a constant you can see
what you're getting.  True, magic constants (e.g. 501) should  be
given  some sort of explanatory name (e.g. StreetAddress).  But I
see little point in defining ZERO as a name for 0.  Pascal  text-
books  are  particularly  prone to this sort of foolishness.  One
defined NINE as 9. If anything they should have defined it as Ra-
dixLessOne.   That  would  cause  less  surprise  when some idiot
changes it to 7.