comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: Call by reference vs. call by value
Date: 1996/07/23
Date: 1996-07-23T00:00:00+00:00	[thread overview]
Message-ID: <dewar.838132574@schonberg> (raw)
In-Reply-To: Pine.SUN.3.91.960723082703.22250A-100000@erlang.praxis.co.uk


Peter Amey said

"This is another Ada feature well covered by the SPARK subset.  The rules
of SPARK (which are checked by the SPARK Examiner) prohibit all cases
of aliasing where program meaning might be affected by the parameter
passing mechanism used. A SPARK program has copy-in, copy-out semantics
regardless of the compiler used to compile it."

Right (or for that matter you can say a SPARK program has by reference
semantics regardless of the compiler used to compile it [for the array
case] :-)

SPARK itself is too restrictive for a lot of general use purposes, but the
kinds of restrictions that it has are worth considering individually in
any coding standard.

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 the above (Fortran) rule is he one you should have in mind wihile
programming (it is a bit more restrictive than the Ada 95 approach, since
there are progrmas whose effect does not depend on the mechanism, but which
violate this rule), but in practice it is perfectly workable.

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).





  reply	other threads:[~1996-07-23  0:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-20  0:00 Call by reference vs. call by value Christopher Felaco
1996-07-20  0:00 ` James A. Krzyzanowski
1996-07-20  0:00   ` Robert Dewar
1996-07-20  0:00 ` Robert Dewar
1996-07-21  0:00   ` Robert A Duff
1996-07-21  0:00     ` Robert Dewar
1996-07-22  0:00       ` Robert A Duff
1996-07-23  0:00         ` Peter Amey
1996-07-23  0:00           ` Robert Dewar [this message]
1996-07-24  0:00             ` Robert A Duff
1996-07-23  0:00           ` Robert A Duff
1996-07-27  0:00             ` Peter Morris
1996-07-28  0:00               ` Robert A Duff
1996-07-24  0:00           ` Richard A. O'Keefe
1996-07-22  0:00   ` Karl Cooper {46901}
1996-07-22  0:00     ` Robert Dewar
1996-07-22  0:00   ` Felaco
1996-07-22  0:00     ` Robert Dewar
1996-07-22  0:00     ` Robert A Duff
1996-07-30  0:00       ` Richard A. O'Keefe
1996-07-30  0:00   ` Felaco
1996-07-31  0:00     ` Robert A Duff
1996-08-02  0:00     ` Robert Dewar
1996-08-03  0:00     ` JP Thornley
1996-08-05  0:00       ` Roderick Chapman
1996-07-21  0:00 ` Robert A Duff
1996-07-21  0:00   ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1996-07-25  0:00 Marin David Condic, 407.796.8997, M/S 731-93
1996-07-26  0:00 ` Peter Amey
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox