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.5 required=5.0 tests=BAYES_00,STOX_REPLY_TYPE 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!sn-xt-sjc-04!sn-xt-sjc-07!sn-xt-sjc-01!sn-post-sjc-01!supernews.com!corp.supernews.com!not-for-mail From: "ME" Newsgroups: comp.lang.ada Subject: Re: Ada Gems in educational material Date: Fri, 7 Mar 2008 21:50:56 -0800 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <13t4a9thd0dkr85@corp.supernews.com> References: <47cec0cf$0$21928$9b4e6d93@newsspool2.arcor-online.net> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Windows Mail 6.0.6000.16480 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16545 X-Complaints-To: abuse@supernews.com Xref: g2news1.google.com comp.lang.ada:20233 Date: 2008-03-07T21:50:56-08:00 List-Id: "Jerry" wrote in message news:f34a2d2c-879c-415c-ba4e-657195c92c34@34g2000hsz.googlegroups.com... On Mar 5, 8:48 am, Georg Bauhaus 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. Jerry Yes it does. Tucker Taft showed me how to do it. I used nested discriminated records even. The problem is that if you have a whole buffer of ,for example,commands to convert i.e. an array you can't do the type conversion on the whole array at once. Ada does not allow this. There is a lot of flexibility of course you can specify where the discriminant goes in the record rep clause and even change the bit order. Then there are the usual limitations with discriminated records like the invariant part must come first etc.