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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,115cdbb394b3e615 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Why can't you create a out of order subtype? Date: 03 Feb 2005 14:40:27 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1107301914.648240.237290@g14g2000cwa.googlegroups.com> NNTP-Posting-Host: shell01-e.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1107459627 19649 69.38.147.31 (3 Feb 2005 19:40:27 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 3 Feb 2005 19:40:27 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:8152 Date: 2005-02-03T14:40:27-05:00 List-Id: Martin Dowie writes: > Marius Amado Alves wrote: > > For run-time I find the "Value of Image" idiom a better one. It's > > readily available. No Unchecked_Conversion required. > > declare > > M : Msg := Whatever; > > V : Vowelmsg; > > begin > > V := Vowelmsg'Value (Msg'Image (M)); > > -- if control reaches here then M is a vowel > > exception > > when Constraint_Error => -- M is not a vowel > > end; If there are no further uses of V, then I think 11.6 allows the compiler to eliminate the raising of Constraint_Error. I don't much like 11.6... > That's very, very, very slow... True (if it works at all). But you could use the "Value of Image" trick to fill in a table that maps from one type to the other. That would work, and uses of the table would be pretty fast. - Bob