comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nickroberts@callnetuk.com>
Subject: Re: Newbie Access Types
Date: 1999/08/25
Date: 1999-08-25T00:00:00+00:00	[thread overview]
Message-ID: <37c45ac7@eeyore.callnetuk.com> (raw)
In-Reply-To: 7pe6tg$dqq$1@dailyplanet.wam.umd.edu

You are correct about a formal out parameter of an access type being
initialised from the value of the actual, as per RM 6.4.5(13). I believe the
reason you suggest is or was the reason for this rule.

It has always seemed to me that an equally satisfactory rule (or allowable
option) would be for the formal to be initialised to null, especially when
Access_Check is in effect (or, if not, where it is known the hardware traps
an attempt to dereference a null access value, and this trap can be handled
as an exception).

However, it also seems to me that it could be quite cogently argued that
such an initialisation is folly, in that there is no reason why the
subprogram failing to set the value of the parameter (to something logically
sensible in the prevailing context) should not cause the program to come
crashing disastrously down anyway. (And the language allows worse things to
happen anyway, such as when an abort divides an operation to do with access
values.)

I would not, myself, subscribe to such an argument, since I (and, I imagine,
others) would hold that, in practice, there will be many situations where
such an initialisation will save a problem turning into a crisis.

I should imagine that the initialisation could be eliminated by an optimiser
under certain circumstances, but (as I'm sure Robert Dewar would be quick to
point out) it may well be that this optimisation would never be worthwhile
in practice (too complicated for the small benefit).

-------------------------------------
Nick Roberts
http://www.adapower.com/lab/adaos
-------------------------------------

Ronald Ayoub <rayoub@wam.umd.edu> wrote in message
news:7pe6tg$dqq$1@dailyplanet.wam.umd.edu...
| I have read that an access type parameter is always copied in even when
| the parameter is an out parameter and that this is so that the access type
| is not undefined which can cause problem. Could someone please elaborate
| on this? It is my thought that access types are initialized to null when
| not explicitly initialized so that an uncopied access type going into a
| function will only result in the formal parameter being initialized to
null.
| Maybe I'm being picky but I like to learn things thoroughly.







  parent reply	other threads:[~1999-08-25  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-18  0:00 Newbie Access Types Ronald Ayoub
1999-08-18  0:00 ` Matthew Heaney
1999-08-25  0:00 ` Nick Roberts [this message]
1999-08-27  0:00   ` Robert A Duff
1999-08-27  0:00     ` Matthew Heaney
replies disabled

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