comp.lang.ada
 help / color / mirror / Atom feed
From: AdaMagica <christ-usch.grein@t-online.de>
Subject: Re: User defined type conversion
Date: Sun, 12 May 2013 07:13:13 -0700 (PDT)
Date: 2013-05-12T07:13:13-07:00	[thread overview]
Message-ID: <fcaa7fb7-6e50-4860-b48d-4c4f68621dad@googlegroups.com> (raw)
In-Reply-To: <518f3dba$0$17523$703f8584@news.kpn.nl>

On Sunday, May 12, 2013 9:04:36 AM UTC+2, ldries46 wrote:
> Is a variant record perhaps the solution for your problem.
>
> type Rec = (bit16, bit 8);
>
> type ABC is
>    record
>       Option : Rec;
>       case Option
>          when bit16 =>
>               A16 : Unsigned_16;

That doesn't compile. Option must be a discriminant and then you can't change the view by just changing the discriminant.
You might think that Unchecked_Union is the solution, but the program is erroneous if the record is read with the wrong discriminant.

The correct way is Unchecked_Conversion, as has been said before.

  reply	other threads:[~2013-05-12 14:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-09 14:07 User defined type conversion Vinícius Franchini
2013-05-09 14:50 ` Adam Beneschan
2013-05-09 16:12 ` Shark8
2013-05-09 16:50   ` Adam Beneschan
2013-05-09 18:24 ` Jeffrey Carter
2013-05-09 18:39   ` Vinícius Franchini
2013-05-09 19:15     ` Adam Beneschan
2013-05-09 20:00       ` Vinícius Franchini
2013-05-09 20:19     ` Jeffrey Carter
2013-05-12  7:04 ` ldries46
2013-05-12 14:13   ` AdaMagica [this message]
2013-05-12 15:02 ` anon
replies disabled

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