From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: I'm facing an issue with: call to abstract procedure must be dispatching Date: Wed, 9 Dec 2015 17:03:13 -0600 Organization: JSA Research & Innovation Message-ID: References: <8bc7fd76-f00a-4eea-9715-470af028fc84@googlegroups.com> <1krm4xun4e4ny.jmh9kvf6s0a9.dlg@40tude.net> <12dc7aea-933d-4271-95bd-10df808917e4@googlegroups.com> <5hfb2q9imjfu.zs3xp9gxw0d3.dlg@40tude.net> <5788b259-8886-4ee2-8c3d-7799abfd840e@googlegroups.com> <14acd8b0-a5e9-40fd-b7cc-d319f914d507@googlegroups.com> <112596d0-d4ee-46e9-a02d-8de837aff352@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1449702194 26894 24.196.82.226 (9 Dec 2015 23:03:14 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 9 Dec 2015 23:03:14 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:28745 Date: 2015-12-09T17:03:13-06:00 List-Id: "Jeffrey R. Carter" 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.