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 2002:a05:660c:1282:: with SMTP id s2mr7197029ita.47.1558179091761; Sat, 18 May 2019 04:31:31 -0700 (PDT) X-Received: by 2002:a9d:7f8b:: with SMTP id t11mr1249983otp.110.1558179091202; Sat, 18 May 2019 04:31:31 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!u76no314798ita.0!news-out.google.com!p73ni289itp.0!nntp.google.com!i64no316468iti.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 18 May 2019 04:31:30 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=89.131.20.193; posting-account=C8J7NQoAAAD_ybGY7--QIRi6KpLjoH1Z NNTP-Posting-Host: 89.131.20.193 References: <0ca05176-a819-4e9a-8c6c-3a0c1f32f964@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: constructor in abstract tagged types From: Daniel Injection-Date: Sat, 18 May 2019 11:31:31 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:56324 Date: 2019-05-18T04:31:30-07:00 List-Id: El mi=C3=A9rcoles, 8 de mayo de 2019, 21:26:10 (UTC+2), Dmitry A. Kazakov = escribi=C3=B3: > On 2019-05-08 20:37, Daniel wrote: >=20 > > Hello, im trying to know how can i use abstract tagged types and constr= uctors at the same time. >=20 > Ada does not have proper constructors. But there are various software=20 > patterns to work this around. >=20 > > I have this > >=20 > > package FATHERS is > > type Father is abstract tagged record > > Years : Natural; > > field1 : Natural; > > -- .....and 15 more fields > > end record; > >=20 > > function F_build(Years :Natural) return Father is abstract; > > procedure F_forced_to_do_it is abstract; >=20 > private > -- > -- Class-wide initialization of Father's fields > -- > procedure Initialize (Object : in out Father'Class; Years : Natural); >=20 > > end FATHERS; > >=20 > > package FATHERS.SONS is > > type Son is new father with record > > skate : boolean; > > end Son; > >=20 > > function F_Build(Years :Natural) return Son; > > procedure F_Forced_to_do_it; > > end FATHERS.SONS; > >=20 > > package body FATHERS.SONS is > >=20 > > function F_Build(Years : Natural) return Son is > > begin > return Result : Son do > Initialize (Result, Years); -- Parent's "constructor" > Result.Skate :=3D True; > end return; > > end F_Build; > >=20 > > end FATHERS.SONS; >=20 > --=20 > Regards, > Dmitry A. Kazakov > http://www.dmitry-kazakov.de Thank you Dmitry. It really works for me!