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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.224.215.194 with SMTP id hf2mr16663285qab.0.1368367993430; Sun, 12 May 2013 07:13:13 -0700 (PDT) X-Received: by 10.49.120.68 with SMTP id la4mr1770761qeb.35.1368367993324; Sun, 12 May 2013 07:13:13 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!mx05.eternal-september.org!feeder.eternal-september.org!feeder.erje.net!eu.feeder.erje.net!news.glorb.com!m7no5030648qam.0!news-out.google.com!y6ni29564qax.0!nntp.google.com!m7no5030644qam.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 12 May 2013 07:13:13 -0700 (PDT) In-Reply-To: <518f3dba$0$17523$703f8584@news.kpn.nl> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=91.7.82.248; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf NNTP-Posting-Host: 91.7.82.248 References: <518f3dba$0$17523$703f8584@news.kpn.nl> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: User defined type conversion From: AdaMagica Injection-Date: Sun, 12 May 2013 14:13:13 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:15527 Date: 2013-05-12T07:13:13-07:00 List-Id: 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.