comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Need Value of enum type not position.
Date: Tue, 18 Nov 2003 15:07:30 -0600
Date: 2003-11-18T15:07:30-06:00	[thread overview]
Message-ID: <vrl2jfmq49fqc1@corp.supernews.com> (raw)
In-Reply-To: mailman.316.1068485520.25614.comp.lang.ada@ada-france.org

"Beard, Frank Randolph CIV" <frank.beard@navy.mil> 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.








  reply	other threads:[~2003-11-18 21:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-10 17:30 Need Value of enum type not position Beard, Frank Randolph CIV
2003-11-18 21:07 ` Randy Brukardt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-11-10 18:25 Beard, Frank Randolph CIV
2003-11-07 18:27 Daniel Allex
2003-11-07 19:26 ` Robert I. Eachus
2003-11-08  0:16   ` Nick Roberts
2003-11-10 13:48 ` Mark Doherty
2003-11-10 18:04 ` Marius Amado Alves
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox