comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: I'm facing an issue with: call to abstract procedure must be dispatching
Date: Wed, 9 Dec 2015 17:03:13 -0600
Date: 2015-12-09T17:03:13-06:00	[thread overview]
Message-ID: <n4abvh$q8e$1@loke.gir.dk> (raw)
In-Reply-To: n47n08$3tr$1@dont-email.me

"Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> wrote in message 
news:n47n08$3tr$1@dont-email.me...
> On 12/08/2015 03:43 PM, Serge Robyns wrote:
>>
>> Now I've a generic question with regards to access type vs. in-out for 
>> parameters.  What is the proper Ada way to pass the "Store" around?
>> Is it:
>> Procedure Do_Something (A_Store : in out T_Abstract_Store'Class);
>> or:
>> Procedure Do_Something (A_Store : not null access 
>> T_Abstract_Store'Class);
>> ?
>>
>> As a former C programmer my habit goes for the not null access variant.
>
> As an Ada S/W engineer, you should use "in out". With "in out", the 
> compiler
> does the work of passing the object in such a way that the operation can 
> read
> and modify the value. With an access, you (or whoever calls your 
> operation) has
> to do extra work to have an access value to pass. It's unnecessary extra 
> work
> and an extra chance to get something wrong, and so to be avoided.

On top of which, it tends to limit how the client can use your package. In 
particular, the client most likely couldn't put values of your object type 
into a container, because Ada puts very strict limits on getting an access 
value into a container. (Additionally, because of the extra runtime 
accessibility checking, the access version is slower. That effect is small 
enough that it shouldn't be a major determining factor in deciding which to 
use, but if all other things are equal, why would anyone want to use the 
slower version??)

                                         Randy.


  reply	other threads:[~2015-12-09 23:03 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-08 16:45 I'm facing an issue with: call to abstract procedure must be dispatching Serge Robyns
2015-12-08 16:59 ` G.B.
2015-12-08 17:04 ` Dmitry A. Kazakov
2015-12-08 17:24   ` Serge Robyns
2015-12-08 17:42     ` Dmitry A. Kazakov
2015-12-08 18:00       ` Serge Robyns
2015-12-08 18:22         ` Dmitry A. Kazakov
2015-12-08 20:21           ` Serge Robyns
2015-12-08 21:08             ` Dmitry A. Kazakov
2015-12-08 21:55               ` Serge Robyns
2015-12-08 22:43                 ` Serge Robyns
2015-12-08 22:55                   ` Jeffrey R. Carter
2015-12-09 23:03                     ` Randy Brukardt [this message]
2015-12-10  8:38                       ` Serge Robyns
2015-12-10 23:43                         ` Randy Brukardt
2015-12-09  8:48                 ` Dmitry A. Kazakov
2015-12-09 10:53               ` G.B.
2015-12-09 12:03                 ` Dmitry A. Kazakov
2015-12-09 13:42                   ` G.B.
2015-12-09 14:23                     ` Dmitry A. Kazakov
2015-12-08 22:55             ` Jeffrey R. Carter
2015-12-08 23:04               ` Serge Robyns
2015-12-08 23:42                 ` Jeffrey R. Carter
2015-12-09 13:40                 ` Jere
2015-12-09 13:48                   ` G.B.
2015-12-09 15:33                     ` Jere
2015-12-13 21:37                 ` Shark8
2015-12-14  2:20                   ` Jeffrey R. Carter
2015-12-15  7:26                     ` Shark8
2015-12-08 17:30 ` Jeffrey R. Carter
2015-12-08 17:48   ` Serge Robyns
2015-12-08 18:46     ` Jeffrey R. Carter
2015-12-08 20:28       ` Serge Robyns
2015-12-08 22:20     ` Simon Wright
replies disabled

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