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:a02:6307:: with SMTP id j7mr52122jac.65.1557348615115; Wed, 08 May 2019 13:50:15 -0700 (PDT) X-Received: by 2002:a9d:4909:: with SMTP id e9mr28200439otf.160.1557348614881; Wed, 08 May 2019 13:50:14 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.166.215.MISMATCH!b2no81952itd.0!news-out.google.com!v189ni45itv.0!nntp.google.com!b2no81951itd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 8 May 2019 13:50:14 -0700 (PDT) In-Reply-To: <0ca05176-a819-4e9a-8c6c-3a0c1f32f964@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=70.109.61.2; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 70.109.61.2 References: <0ca05176-a819-4e9a-8c6c-3a0c1f32f964@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <58f49c83-eb9d-40d7-9c90-a9523167f63a@googlegroups.com> Subject: Re: constructor in abstract tagged types From: Jere Injection-Date: Wed, 08 May 2019 20:50:15 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:56263 Date: 2019-05-08T13:50:14-07:00 List-Id: On Wednesday, May 8, 2019 at 2:37:25 PM UTC-4, Daniel wrote: > Hello, im trying to know how can i use abstract tagged types and constructors at the same time. > > I have this > > > > Option 2: > > return Son'(Father with > Skate =>True); > > Problem: i cannot initialize Father or call any kind of constructor of Father becouse compiler don't let me make any kind of function of a abstract tagged type. > > Regards, > Daniel. GNAT accepts: function F_Build(Years : Natural) return Son is begin return (Years => Years, Skate => True, others => <>); end F_Build; I assume since it is abstract you don't have to lead with "Father with" in the aggregate initialization. If you need something more complex for the other fields you can optionally use extended returns: function F_Build(Years : Natural) return Son is begin return Result : Son := (Years => Years, Skate => True, others => <>) do Result.Field1 := -- Something complex; *** end return; end F_Build; Tested this with GNAT 7.1.1