From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Discriminant problem
Date: Tue, 31 Aug 2021 00:03:16 +0200 [thread overview]
Message-ID: <sgjkj4$kn4$1@dont-email.me> (raw)
In-Reply-To: <lytuj8dqya.fsf@pushface.org>
On 8/29/21 8:51 PM, Simon Wright wrote:
>
> the compiler says
>
> value for discriminant "Node_Test" must be static
> non-static function call (RM 4.9(6,18))
This has always been the rule for aggregates.
> OK, I get that (tiresome though it is, and I'm amazed I've never come
> across it before), but how to approach it? I seem to be OK with
That is surprising.
> case Get_Node_Type_Test (T.Node_Type_Part.all) is
> when Text_Node_Test =>
> Location_Step.Node_Test :=
> (Node_Test => Text_Node_Test,
> Name => Null_Unbounded_String);
> when ...
> end case;
>
> but this seems very ugly.
Agreed. What I usually do is
declare
Result : Whatever (D => Non_Static_Value);
-- Discriminant of an object need not be static
begin
Result.F1 := ...;
...
Location_Step.Node_Test := Result;
end;
--
Jeff Carter
"You can never forget too much about C++."
115
next prev parent reply other threads:[~2021-08-30 22:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-29 18:51 Discriminant problem Simon Wright
2021-08-30 8:13 ` Simon Wright
2021-08-30 22:03 ` Jeffrey R. Carter [this message]
2021-08-31 1:53 ` Randy Brukardt
2021-09-09 19:51 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox