From: Jere <jhb.chat@gmail.com>
Subject: Re: constructor in abstract tagged types
Date: Wed, 8 May 2019 13:50:14 -0700 (PDT)
Date: 2019-05-08T13:50:14-07:00 [thread overview]
Message-ID: <58f49c83-eb9d-40d7-9c90-a9523167f63a@googlegroups.com> (raw)
In-Reply-To: <0ca05176-a819-4e9a-8c6c-3a0c1f32f964@googlegroups.com>
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
>
> <SNIPPED>
>
> 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
next prev parent reply other threads:[~2019-05-08 20:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-08 18:37 constructor in abstract tagged types Daniel
2019-05-08 19:26 ` Dmitry A. Kazakov
2019-05-18 11:31 ` Daniel
2019-05-08 20:50 ` Jere [this message]
2019-05-10 22:35 ` Randy Brukardt
2019-05-09 14:40 ` AdaMagica
2019-05-10 4:46 ` Petter Fryklund
2019-05-18 11:35 ` Daniel
2019-05-10 22:40 ` Randy Brukardt
2019-05-18 11:43 ` Daniel
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox