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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC 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 Path: g2news1.google.com!news4.google.com!feeder.news-service.com!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Constructors with multiple inheritance Date: Fri, 30 Sep 2011 18:42:39 +0200 Organization: cbb software GmbH Message-ID: <1gnrks1djlaok.1k0r5f8z9ylfx.dlg@40tude.net> 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> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: EMY6V9w2JsuJ/8EEiAFEEw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: g2news1.google.com comp.lang.ada:21211 Date: 2011-09-30T18:42:39+02:00 List-Id: On Fri, 30 Sep 2011 07:04:24 -0700 (PDT), in comp.lang.ada you wrote: >>> Yes, I agree. But that's the point. I want to reserve the address (so I >>> can build my queues from there). >> >> The problem is not the result, but the argument of Construct. > > Ok. But did not understand the problem if the argument is null. Because null cannot be dereferenced. If you want null allowed you have to declare it as: function Construct (Object_Reference : access Parent_Class) return Parent_Class_Ptr; or function Construct (Object_Reference : Parent_Class_Ptr) return Parent_Class_Ptr; The first variant is a "method" of Parent_Class in the first argument. The second variant is not. > So if I inherit a class Technically you cannot inherit class. Class is a set of types closed upon derivation. When you derive type S from type T, then S and T are members of the class rooted in the type T. S inherits operations etc from T. What in C++ is called class is in Ada a tagged type and/or a class-wide type, because C++ fails to distinguish them. > which have a method defined in the "function Construct return > Parent_Class_Ptr" Construct is not a "method" of Parent_Class because there is no covariant argument/result of that type. > form instead of the "function Construct (Obj : > Parent_Class) return Parent_Class_Ptr" This one is a "method" (primitive operation in Ada terms) in the argument Obj. It is still not a "method" in the result. > it behaves the same manner? I.e., > the childs have full access to the methods and can even override them? This is confused. 1. In Ada access is based on visibility, which in turn rely on the packages structure, not types. 2. Inheritance and overriding is related to tagged types. You can always derive from a type which view is tagged. (A type can be privately tagged, but publicly not, from this type you cannot derive) >>> So I need to fix the >>> package.function_constructor call and use a call of type >>> object.method_constructor. >> >> Why? > > Well, the prefixed notation if I understood well was made exactly for > filling this. Prefix notation works only if you have the first argument of tagged type. The questions are why do you need an argument which is null? Why do you need access types at all. It does not look how things are usually done in Ada. >> What is wrong with the abstract factory pattern? > > Nothing wrong. I'm not questioning this. So why don't you use it? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de