From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8e64f4db20d57eb5 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Call by reference vs. call by value Date: 1996/07/24 Message-ID: #1/1 X-Deja-AN: 169951352 references: <31F10E50.726@egr.uri.edu> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-07-24T00:00:00+00:00 List-Id: In article , Robert Dewar wrote: >I actually like the Fortran rule as to exactly what is and what is not >allowed in Fortran. It is as follows: > > if there are two aliased paths to the same object, it is erroneous (to use > the Ada terminology) to assign to the object via either path. > >That's a very well defined rule. I much prefer it to eithe the bogus rule >in the Ada 83 RM (erroneous if effect differs, but effect never defined), >or to the Ada 95 RM rule that programs are simply non-determinisitc if >their effects depend on the mechanism. I think both the Ada rule and the Fortran rule are pretty ugly. The problem is that you can't pin the error down to one piece of code. Is it the fault of the caller, or the callee? There's nothing in the spec that gives any sort of contractual information about which side has to do what. >You can now if you like follow this up with specific coding rules designed >to prevent this from occurring (e.g. forbidding globally visible objects >to be passed as out or in out parameters to routines that can see the >global, or forbidding the same object from being passed as two separate >parameters if one of them is out or in out). But at the call site, I can't tell which global variables are visible to the callee, without looking at its body. So not only can I get bugs, but the bugs can be triggered by porting the code, or by turning on the optimizer, which is more painful than a normal run-of-the-mill bug. I must admit it's not *that* big of a deal, since you don't normally have a lot of global variables lying around. - Bob