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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c6e6cdf6ff50e684 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-02-09 01:28:50 PST From: "Martin Dowie" Newsgroups: comp.lang.ada References: <95tqbh$ag7$1@nnrp1.deja.com> <95tre2$f33@news.kvaerner.com> <95u470$ho1$1@nnrp1.deja.com> <95ua6q$mp4$1@nnrp1.deja.com> <3A82BE3F.EB695A73@m_a_i_l.com> <3A82C8DC.1505AC5@avidyne.com> Subject: Re: Representation clause for enumeratives Date: Fri, 9 Feb 2001 09:29:54 -0000 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 NNTP-Posting-Host: superted.dsge.edinbr.gmav.gecm.com Message-ID: <3a83b6c6$1@pull.gecm.com> X-Trace: 9 Feb 2001 09:22:14 GMT, superted.dsge.edinbr.gmav.gecm.com Path: supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!193.190.198.17!newsfeeds.belnet.be!news.belnet.be!btnet-peer1!btnet-feed3!btnet!newreader.ukcore.bt.net!pull.gecm.com!superted.dsge.edinbr.gmav.gecm.com Xref: supernews.google.com comp.lang.ada:5044 Date: 2001-02-09T09:29:54+00:00 List-Id: also, if you are using the enumeration a lot for, say, array indexing _not_ having underlying representations tends to lead to much faster code. You lose a little CPU time at the interface to do the conversion, but you may find you gain many times that amount in your application. If you want to save some typing make a few generics to do the conversions. I know of several projects where precisely this sort of thing is happening (and not just limited to enumeration conversions :-). Come to think of it, I can hardly remember the last time I use a rep. clause for an enumeration... Steve O'Neill wrote in message news:3A82C8DC.1505AC5@avidyne.com... > Rather than try to encode the enumeration values (which frequently leads to > frustration and maintenance issues) I would instead create an array of > appropriately typed objects that are indexed by the enumeration that I was > trying to map. I would index into, search through, etc. that array > whenever I wanted to convert to/from the external hardware to the internal > meaning. It might not seem as elegant or as potentially efficient as > assigning the enumeration value directly but in my experience it is a lot > less painful. With the proper encapsulation and design metaphor it can > actually turn out to be fairly intuitive. [snip]