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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,162afea183f99845 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Thu, 06 Mar 2008 11:32:37 +0100 From: Georg Bauhaus Reply-To: rm.tsoh+bauhaus@maps.futureapps.de User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada Gems in educational material References: <47cec0cf$0$21928$9b4e6d93@newsspool2.arcor-online.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <47cfc845$0$21930$9b4e6d93@newsspool2.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 06 Mar 2008 11:32:37 CET NNTP-Posting-Host: fa938bd9.newsspool2.arcor-online.net X-Trace: DXC==bYFU1`hg\Egj[ZPFj7ehOA9EHlD;3YcB4Fo<]lROoRAFl8W>\BH3YBX\M_\bMjBTCA:ho7QcPOVC8Y_O[Ki:BkC0EPfM3QRCbL X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:20193 Date: 2008-03-06T11:32:37+01:00 List-Id: Jerry wrote: > On Mar 5, 8:48 am, Georg Bauhaus bauh...@maps.futureapps.de> wrote: >> Gem #27: Changing Data Representation (Part 1) by Robert Dewar >> explains how to use type derivation if you want to have two >> representations of the same data. The types let you convert >> between an external and an internal representation, say. >> >> http://www.adacore.com/2008/03/03/gem-27/ > > I wonder if this works on records with discriminants. It should work I think, according to LRM 13.5.1 and 3.2.1(6). This works with GNAT. -gnatR2[s] might be useful. package News5 is -- components type C is range 1000 .. 5000; -- discriminating values type T is range -1 .. +1; -- internal type type R(D: T) is record Data: C; end record; -- external type type X(D: T) is new R(D); for X'Size use 36; for X use record Data at 0 range 0 .. 11; D at 0 range 24 .. 27; end record; Internal: R := R'(0, Data => 4200); External: X := X(Internal); end News5;