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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5f0f4bfb0467bb19 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.59.229 with SMTP id c5mr4464228pbr.6.1320896946651; Wed, 09 Nov 2011 19:49:06 -0800 (PST) Path: h5ni19772pba.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: "Rego, P." Newsgroups: comp.lang.ada Subject: Re: Constructors with multiple inheritance Date: Wed, 9 Nov 2011 19:47:01 -0800 (PST) Organization: http://groups.google.com Message-ID: <6366850.176.1320896821400.JavaMail.geo-discussion-forums@yqcm23> References: <11513972.2788.1317325228383.JavaMail.geo-discussion-forums@yqnv12> <1rj1mmkvwud1d.dzqoy4jhdfca$.dlg@40tude.net> <4976045.4489.1317352313370.JavaMail.geo-discussion-forums@yqjw35> <2pu3h5hqltxi$.ze4yrf1f2y8z.dlg@40tude.net> <23774546.1654.1317391464047.JavaMail.geo-discussion-forums@yqnk41> <1gnrks1djlaok.1k0r5f8z9ylfx.dlg@40tude.net> <21605158.153.1320805494018.JavaMail.geo-discussion-forums@yqiu15> Reply-To: comp.lang.ada@googlegroups.com NNTP-Posting-Host: 200.148.121.196 Mime-Version: 1.0 X-Trace: posting.google.com 1320896946 25506 127.0.0.1 (10 Nov 2011 03:49:06 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 10 Nov 2011 03:49:06 +0000 (UTC) Cc: mailbox@dmitry-kazakov.de In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=200.148.121.196; posting-account=TRgI1QoAAABSsYi-ox3Pi6N-JEKKU0cu User-Agent: G2/1.0 X-Google-Web-Client: true Xref: news1.google.com comp.lang.ada:18898 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-11-09T19:47:01-08:00 List-Id: > 1. Test_Obj is null pointer. > 2- Objects are not constructed that way. > 3. Memory leak > 4. Tasks component does not terminate, which will block finalization of t= he > object >=20 > P.S. I absolutely fail to comprehend what are you trying to do. Virtually > every second line of the sample you posted looks wrong. May I suggest you > to formulate what do you actually want? People here might show you right > patterns to achieve that goal. I'm having a big difficult in simplifying the problem, but I will try. Init= ially forget about the task termination, I plan to implement it as other se= rvices to run from inside other tasks which are going to communicate with e= ach other, but for now it's just future. I also know that there's memory le= ak, and that the object is null. Maybe I can explain this easier trying to use C++. Let's suppose I have a c= lass Par_Class with an integer and a pointer to a string. I could code, for= example, (please correct me if I'm doing wrong) class Par_Class { public: Par_Class (int aValue, const char *aName); private: int theValue; char *theName; }; the constructor could be implemented as Par_Class::Par_Class (int aValue, const char *aName){ theValue =3D aValue; strcpy (theName, aName); }; and finally we could instantiate this class with Par_Class Par_Obj (23, "My object is this"); and sure this constructor method belongs to the class Par_Class and not to = any other class. In Ada 2005, this class could be coded, for example, as --par_pkg.ads package Par_Pkg is type Par_Class is tagged private; type Par_Class_Ptr is access all Par_Class; type Integer_Ptr is access Integer; function Construct=20 (P : access Par_Class; aValue : Integer; aName : Integer_Ptr) return Par_Class_Ptr; private type Par_Class is tagged record theValue : Integer; theName : Integer_Ptr; end record; end Par_Pkg; -- par_pkg.adb package body Par_Pkg is function Construct=20 (P : access Par_Class; aValue : Integer; aName : Integer_Ptr) return Par_Class_Ptr is pragma Unreferenced (P); P_Ptr : constant Par_Class_Ptr :=3D new Par_Class; begin P_Ptr.theValue :=3D aValue; P_Ptr.theName :=3D aName; return P_Ptr; end Construct; end Par_Pkg; and the user could call with Par_Pkg; use Par_Pkg; procedure Par_Main is Par_Obj : Par_Class_Ptr; Int_Obj : Integer_Ptr; begin Int_Obj :=3D new Integer; Int_Obj.all :=3D 12; -- don't worry about been string or integer Par_Obj :=3D Par_Obj.Construct=20 (aValue =3D> 23, aName =3D> Int_Obj); end Par_Main; The compiler says me that Par_Obj is null when I use Par_Obj :=3D Par_Obj.C= onstruct, and I know it, and agree with it, because exactly what I want to = do is to initialize my object (and so the object is not null anymore), so I= can access other stuffs which are not shown here. I don't want to have a C= onstructor without class parameter (so according to Ada 2005 Rationale it w= ould not be a method of the class Par_Class), because it runs away from my = system architecture.=20 So, I would like to now if there is a way, in Ada 2005, on how I can use a = method-like function (using this definition of the class from AR2005, even = though exist other definitions). If there's no solution for this, no proble= m, I use the pure Construct implementation, it's already running ok, but I = prefer to use this (possibly) other implementation scheme, if I can use. Thank you again.