Re: By value-result vs. by reference (Robb Nebbe)
Thu, 28 Apr 1994 12:36:35 GMT

          From comp.compilers

Related articles
Re: By value-result vs by reference (1994-04-21)
Re: By value-result vs. by reference (1994-04-28)
Re: By value-result vs. by reference (1994-04-28)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Robb Nebbe)
Keywords: design, Ada
Organization: Ecole Polytechnique Federale de Lausanne
References: 94-04-145 94-04-178
Date: Thu, 28 Apr 1994 12:36:35 GMT (David Keppel) writes:
: - It's hard to promise things about exceptions. The safest thing
: that a programmer can do is to assign only to locals and then copy
: to the reference parameters just before return. But even this can
: blow up if assignment can cause an exception (either when a
: structure is half-modified or if an exception occurs after the
: first assignment has completed). How can assignment cause an
: exception? Consider both structures that span page boundaries and
: field assignment that, as in the VAX, requires floating-point
: values to be valid to be moved.

In Ada an exception can't be raised in the middle of an assignment which
is just a raw memory copy. Any problem with page boundaries will not be
delivered as an exception. The conditions when an exception may be raised
(either the failure of a run-time check or an explict raise statement) are
well defined making it possible to prove (in many cases fairly trivially)
that an exception will not occur.

The problems with not specifying whether a parameter will be passed by
value/result or by reference are all related to one entity being
accessible and modifiable by two different paths in the same procedure.
Something that no one could justify doing on purpose and which is almost
always wrong no matter what method of parameter passing is chosen.

Ada compilers are permitted (but not required) to detect when this kind of
aliasing occurs and are even permitted to raise an exception.

- Robb Nebbe

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.