comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Access parameters and accessibility
Date: Wed, 17 Dec 2014 16:58:10 -0600
Date: 2014-12-17T16:58:10-06:00	[thread overview]
Message-ID: <m6t1qc$73o$1@loke.gir.dk> (raw)
In-Reply-To: slrnm92hsh.nrc.lithiumcat@nat.rebma.instinctive.eu

"Natasha Kerensikova" <lithiumcat@instinctive.eu> wrote in message 
news:slrnm92hsh.nrc.lithiumcat@nat.rebma.instinctive.eu...
> On 2014-12-17, Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote:
>> On Wed, 17 Dec 2014 07:02:56 +0000 (UTC), Natasha Kerensikova wrote:
>>
>>> Now you got me really worried, because I thouhgt access discriminants
>>> were safe. It was under that assumption that I actually started to
>>> really like them.
>>>
>>> More specifically, the pattern I caught myself using a lot looks like
>>> the following:
>>>
>>>    type Preprocessed_Data (Input_Data : access Input_Data_Type) is 
>>> record
>>
>> not null access?
>
> I tought access discriminants were not allowed to be null.
> Has that changed?
> Or do you advise "not null access" to make it explicit?

Explicit is always better, regardless of the rules.

Ada 95 did not define null for anonymous access types, but all more recent 
versions of Ada do. The only implicit restriction against null that I 
remember in modern Ada is for dispatching anonymous access parameters. See 
3.10(13.1/2). Ahh, yes, AARM 3.10(26.c/2) says:

Inconsistences with Ada 95
Access discriminants and noncontrolling access parameters no longer exclude 
null. A program which passed null to such an access discriminant or access 
parameter and expected it to raise Constraint_Error may fail when compiled 
with Ada 2005. One hopes that there no such programs outside of the ACATS. 
(Of course, a program which actually wants to pass null will work, which is 
far more likely.)

Moral: If you're programming for Ada 2005 or later, always use a null 
exclusion when that makes sense. (It's even a good idea on controlling 
parameters, we would have preferred to require it but that would have been 
severely incompatible with Ada 95.)

                                Randy.


  reply	other threads:[~2014-12-17 22:58 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-15 16:52 Access parameters and accessibility Michael B.
2014-12-15 17:54 ` Dmitry A. Kazakov
2014-12-15 18:48   ` Jeffrey Carter
2014-12-15 20:23     ` Michael B.
2014-12-15 21:02       ` Dmitry A. Kazakov
2014-12-16  1:10 ` sbelmont700
2014-12-16 13:57   ` Michael B.
2014-12-16 14:12     ` Georg Bauhaus
2014-12-16 21:34     ` sbelmont700
2014-12-17 14:30       ` Michael B.
2014-12-17 15:41         ` sbelmont700
2014-12-18 17:48           ` Michael B.
2014-12-17 16:03         ` Adam Beneschan
2014-12-18 16:07           ` Michael B.
2014-12-16  7:45 ` Randy Brukardt
2014-12-16  8:48   ` Stefan.Lucks
2014-12-16 20:47     ` Randy Brukardt
2014-12-16 21:24       ` Georg Bauhaus
2014-12-16  9:08   ` Natasha Kerensikova
2014-12-16 10:00     ` Dmitry A. Kazakov
2014-12-16 14:57     ` Robert A Duff
2014-12-16 19:46   ` Michael B.
2014-12-16 20:59     ` Randy Brukardt
2014-12-17  7:02       ` Natasha Kerensikova
2014-12-17  8:28         ` Dmitry A. Kazakov
2014-12-17  9:06           ` Natasha Kerensikova
2014-12-17 22:58             ` Randy Brukardt [this message]
2014-12-17 22:25         ` Randy Brukardt
2014-12-18  0:47         ` Shark8
2014-12-17  2:02     ` Adam Beneschan
2014-12-17 23:18       ` Randy Brukardt
2014-12-18  0:56         ` Robert A Duff
2014-12-18  1:17           ` Randy Brukardt
2014-12-18  5:29             ` Shark8
2014-12-18 23:12             ` Randy Brukardt
2014-12-18  8:27         ` Dmitry A. Kazakov
2014-12-18 21:20           ` Randy Brukardt
2014-12-19 12:16 ` Michael B.
replies disabled

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