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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Aliased Unchecked_Unions not seen or taken notice of Date: Mon, 12 Nov 2018 18:14:17 -0600 Organization: JSA Research & Innovation Message-ID: References: <59fabb8a-45b4-429d-822b-58878a208df0@googlegroups.com> Injection-Date: Tue, 13 Nov 2018 00:14:18 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="16347"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:54821 Date: 2018-11-12T18:14:17-06:00 List-Id: "Lucretia" wrote in message news:bed99006-94ac-457c-9461-24d326eb4c60@googlegroups.com... > On Monday, 12 November 2018 20:13:53 UTC, Dmitry A. Kazakov wrote: >> On 2018-11-12 19:29, Lucretia wrote: >> > On Monday, 12 November 2018 17:56:05 UTC, Lucretia wrote: >> > >> >> type Results (Success : Boolean) is >> >> record >> >> case Success is >> >> when False => >> >> Error : Errors_Ptr; >> >> >> >> when True => >> >> Output : Values_Ptr; >> >> end case; >> >> end record with >> >> Convention => C_Pass_By_Copy; >> > >> > This compiles fine. So it seems impossible to use unchecked_union and >> > access types together. >> >> What about C_Pass_By_Copy? That looks much inconsistent with access to >> me. > > I did try removing that too. > >> BTW, why do you want to use unchecked union? In comparable cases I >> rather simply overload imported functions with whatever arguments: > > Because it's not that simple. Sure, but it's almost always simple enough. We built Claw without using Unchecked_Union at all (it didn't exist in Ada 95), and there weren't many (if any) cases where the result would have been better had it existed. Worse, Unchecked_Union is an easy way to introduce erroneous execution into one's program accidentally; at least using Unchecked_Conversion or some similar scheme makes that obvious. (Using the "wrong" discriminant is erroneous, even though that isn't checked or checkable.) I'd keep the use of Unchecked_Union *very* limited, mostly to just cases where it is a component of some outer type. And even that might be better handled with Unchecked_Conversion (for reasons noted above). Randy.