From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=0.0 required=3.0 tests=BAYES_40,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:a05:6214:20a7:: with SMTP id 7mr61490745qvd.59.1609430810758; Thu, 31 Dec 2020 08:06:50 -0800 (PST) X-Received: by 2002:a25:8708:: with SMTP id a8mr83519596ybl.92.1609430810610; Thu, 31 Dec 2020 08:06:50 -0800 (PST) Path: eternal-september.org!reader02.eternal-september.org!2.eu.feeder.erje.net!feeder.erje.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 31 Dec 2020 08:06:50 -0800 (PST) In-Reply-To: <5fedd239$0$21616$426a74cc@news.free.fr> Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=2a02:1206:4564:fe50:f889:7d12:c5e3:3c88; posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG NNTP-Posting-Host: 2a02:1206:4564:fe50:f889:7d12:c5e3:3c88 References: <3c1a2fe9-e8f2-401f-870d-aecd9e0f9c69n@googlegroups.com> <6dd44b3c-b3de-4943-ac70-0e25eaf279efn@googlegroups.com> <5fedd239$0$21616$426a74cc@news.free.fr> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8c9e6c01-495d-4bce-a6d1-c440f559d8bbn@googlegroups.com> Subject: Re: Question on variant/discriminated records From: Gautier write-only address Injection-Date: Thu, 31 Dec 2020 16:06:50 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:60996 List-Id: > > Imagine you have a function Evaluate (r : rec1_Type) return Float.=20 > > Except in trivial cases like=20 > > if r.option1 =3D b then result :=3D result + r.y; end if;=20 > > the compiler cannot guess the value of the discriminant.=20 > > > Isn't the discriminant stored in the record ? Yes. But if both "y"s were allowed, the compiler should for the non-trivial= cases, generate a hidden "case" instruction to select the right "y" depend= ing on the value of option1 (both "y"s are not necessarily at the same posi= tion in the record). Certainly the language designers have considered the a= dditional complexity and performance cost of that point. Fortunately the ne= sted choice as suggested by Dmitry solves the problem.