comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adambeneschan@aol.com>
Subject: Re: GNAT GPL 2013 bug?
Date: Fri, 9 Aug 2013 08:48:52 -0700 (PDT)
Date: 2013-08-09T08:48:52-07:00	[thread overview]
Message-ID: <72539e4c-dddd-40e4-82e8-14c4f2016ccc@googlegroups.com> (raw)
In-Reply-To: <hrkm713gcc7n$.mep6a9ijq09k.dlg@40tude.net>

On Friday, August 9, 2013 4:01:21 AM UTC-7, Dmitry A. Kazakov wrote:
 
> > Aren't dispatching access parameters inherently always 'not null' anyway,
> > and the explicit qualifier just an optional readability thing?
> 
> No idea, but since Ada 2005 access T can be null. Is the behavior depends
> on whether the parameter is dispatching?
> 
> So considering:
> 
>    type Q is null record;
>    procedure P (X : access Q) is null;
> 
>    Y : access Q := null;
> begin
>    P (Y); -- This is OK (since Ada 2005)
> 
> Now add "tagged" to Q:
> 
>    type Q is tagged null record;
>    procedure P (X : access Q) is null;
> 
>    Y : access Q := null;
> begin
>    P (Y); -- This is not OK?
> 
> I didn't searched ARM for this, but if indeed so, this is a language bug to
> me.

It was a deliberate design decision.  The big difference in your second example isn't just that Q is now tagged; the big difference is that P has become a dispatching procedure, and it dispatches on the argument X.  Passing null for X wouldn't make any sense--what would it dispatch to?  

In this example:

    type Q is tagged null record;
    package Inner is
        procedure P (X : access Q) is null;
    end Inner;

now X can be null, since P isn't dispatching.  In some of the examples in your later post (like the one where Q is private and the full type is a tagged record), there isn't a problem either, since the procedure isn't dispatching.

It has always been the case since Ada 95 that access parameters used for dispatching may not be null.  In Ada 95, actuals for other access parameters weren't allowed to be null either.  In Ada 2005, the language was changed to allow null for access parameters, *except* for those (controlling parameters) which could be dispatched on.  It was also changed to allow "not null".  I believe there was a dilemma when it came to controlling parameters--those still could not be null, but did they want to explicitly require "not null" on them?  The decision was to make those implicitly "not null", which makes some language rules a bit inconsistent but preserved backward compatibility.

                            -- Adam
    
   

  parent reply	other threads:[~2013-08-09 15:48 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-09  9:47 GNAT GPL 2013 bug? Dmitry A. Kazakov
2013-08-09 10:38 ` sbelmont700
2013-08-09 11:01   ` Dmitry A. Kazakov
2013-08-09 11:06     ` sbelmont700
2013-08-09 11:36       ` Dmitry A. Kazakov
2013-08-09 15:48     ` Adam Beneschan [this message]
2013-08-09 16:11       ` Simon Wright
2013-08-09 16:52         ` Adam Beneschan
2013-08-09 18:25           ` Simon Wright
2013-08-09 18:39             ` Adam Beneschan
2013-08-09 19:28               ` Adam Beneschan
2013-08-09 20:05                 ` Robert A Duff
2013-08-09 20:30                   ` Adam Beneschan
2013-08-09 21:35                     ` Simon Wright
2013-08-10 15:10                     ` Shark8
2013-08-09 16:03     ` Simon Wright
2013-08-09 18:55     ` Randy Brukardt
2013-08-09 19:27       ` Dmitry A. Kazakov
2013-08-09 20:04         ` Robert A Duff
2013-08-10  6:51           ` Dmitry A. Kazakov
2013-08-12 16:52             ` Adam Beneschan
2013-08-12 17:03               ` Dmitry A. Kazakov
2013-08-12 17:20                 ` Adam Beneschan
2013-08-12 18:34                   ` Dmitry A. Kazakov
2013-08-12 20:12             ` Randy Brukardt
2013-08-13  6:43               ` Dmitry A. Kazakov
replies disabled

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