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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.141.3.66 with SMTP id f63mr8078596qhd.10.1449668414616; Wed, 09 Dec 2015 05:40:14 -0800 (PST) X-Received: by 10.182.42.195 with SMTP id q3mr79265obl.3.1449668414583; Wed, 09 Dec 2015 05:40:14 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!au2pb.net!feeder.erje.net!2.us.feeder.erje.net!enother.net!enother.net!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!f78no7401589qge.1!news-out.google.com!l1ni1481igd.0!nntp.google.com!mv3no10799802igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 9 Dec 2015 05:40:14 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=138.162.0.41; posting-account=9yqilwkAAAAlbxojEc6DW1OEOsACipCN NNTP-Posting-Host: 138.162.0.41 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> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <25d385ff-a7c6-40e8-bee0-9e465f92d98b@googlegroups.com> Subject: Re: I'm facing an issue with: call to abstract procedure must be dispatching From: Jere Injection-Date: Wed, 09 Dec 2015 13:40:14 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 4367 X-Received-Body-CRC: 375494322 Xref: news.eternal-september.org comp.lang.ada:28735 Date: 2015-12-09T05:40:14-08:00 List-Id: On Tuesday, December 8, 2015 at 6:04:08 PM UTC-5, Serge Robyns wrote: > On Tuesday, 8 December 2015 23:55:52 UTC+1, Jeffrey R. Carter wrote: > > If you don't need assignment because there will never be more than one = of them, > > that's an indication that you don't need a type and a variable; you nee= d a > > module. I suspect you think in terms of types because C++ only provides > > encapsulation and information hiding through its class construct. In Ad= a, your > > 1st thought when you want encapsulation or information hiding should be= a pkg. > >=20 >=20 > How do I then pass the context? I mean, now I pass the parameter around.= through global variables? Also in the future I would like to have multip= le "tasks" running, each with their "context", especially the db session. = I do believe these are good reasons for having a variable. If will be having multiple ones with their own contexts then you will have = to use objects from types to do that. However, if you are only going to ha= ve one, then as Jeffrey Carter suggested, just use a package. A useless un= compiled example (I don't have GNAT in front of me here): package My_Package is type Data_Type is record Value1 : Integer :=3D Integer'First; Value2 : Positive :=3D Positive'First; end record; procedure Update_My_Data(Data : in Data_Type); function View_My_Data return Data_Type; end My_Package; =20 package body My_Package is My_Data : Data_Type; procedure Update_My_Data(Data : in Data_Type) is begin My_Data :=3D Data; end Update_My_Data; function View_My_Data return Data_Type is begin return My_Data; end View_My_Data; end My_Package; My_Data is only accessible via the package body, so any clients have to use= the provided functions of the package to manipulate or look at the data. = This example is over-simplistic, but I just wanted to show you the layout. = It's not the same as using a global since the clients can't access the var= iable directly and you have the freedom to have the public interface hide s= ome implementation details on how the data is actually handled. Since you are familiar with C++, it has a similar construct (I use it for p= eripherals in small embedded systems): A class with only static members an= d static methods. In this case, you are not using the class to generate ob= jects but to organize methods and data with the ability to make some of the= m private (which you cannot do in a namespace) while also being able to ret= ain a private non-global static state for one thing. It is not as elegant = as an Ada package and there are still some differences, but it is the close= st analog to this that C++ has.