comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Aliased Unchecked_Unions not seen or taken notice of
Date: Mon, 12 Nov 2018 18:14:17 -0600
Date: 2018-11-12T18:14:17-06:00	[thread overview]
Message-ID: <psd50q$fur$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: bed99006-94ac-457c-9461-24d326eb4c60@googlegroups.com

"Lucretia" <laguest9000@googlemail.com> 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.



  reply	other threads:[~2018-11-13  0:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-12 17:56 Aliased Unchecked_Unions not seen or taken notice of Lucretia
2018-11-12 18:29 ` Lucretia
2018-11-12 20:13   ` Dmitry A. Kazakov
2018-11-12 21:02     ` Lucretia
2018-11-13  0:14       ` Randy Brukardt [this message]
2018-11-12 18:53 ` Per Sandberg
2018-11-12 19:44   ` Lucretia
2018-11-13  0:17     ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox