From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=BAYES_00,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Discriminant problem Date: Tue, 31 Aug 2021 00:03:16 +0200 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 30 Aug 2021 22:03:17 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="170b88e280b372a24cf42b600488aae1"; logging-data="21220"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/XcLNzxkzWEX+Nuo04lFBIFQkJXpy20uY=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 Cancel-Lock: sha1:tggAGy2mMLBVNBBh0H91XvohtXU= In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:62588 List-Id: 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