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,b1a96e8174ef9f99 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-18 13:11:04 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!sn-xit-03!sn-xit-04!sn-xit-06!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Need Value of enum type not position. Date: Tue, 18 Nov 2003 15:07:30 -0600 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:2650 Date: 2003-11-18T15:07:30-06:00 List-Id: "Beard, Frank Randolph CIV" wrote in message news:mailman.316.1068485520.25614.comp.lang.ada@ada-france.org... > I would still go with Unchecked_Conversion. The problem with > a look-up table is it requires more maintenance. With the > Unchecked_Conversion approach, you change or add to the type > in one place, instead of having to mirror the change in your > look-up table. Note that the implementation of an enumeration representation clause is generally a lookup array. Meaning that, unless you *really* need those objects to always have the representation, you are better off using an explicit array when you need it. Otherwise, every use of the enumeration potentially is going through the compiler's lookup array (which is even more expensive when going from representation to position number). For instance, E'Succ generates code to find the position number, increment it, and then find the representation. (As does the similar operations for array indexing and for loops). That can be pretty expensive. Compilers do optimize this code when they can, but the general case (as in the original example) remains expensive. Randy.