comp.lang.ada
 help / color / mirror / Atom feed
From: Steve O'Neill <soneill@avidyne.com>
Subject: Re: Representation clause for enumeratives
Date: Thu, 08 Feb 2001 11:27:08 -0500
Date: 2001-02-08T16:23:17+00:00	[thread overview]
Message-ID: <3A82C8DC.1505AC5@avidyne.com> (raw)
In-Reply-To: 3A82BE3F.EB695A73@m_a_i_l.com

I'm making an assumption here that you are choosing these enumeration
values to match to some hardware encoding.  When I have found myself in
similar situations in the past I have usually taken a different route.

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.

Steve O'Neill

"M. Kotiaho" wrote:

> Robert Dewar wrote:
>
> > In article <95u470$ho1$1@nnrp1.deja.com>,
> >   Sandro Binetti <sandrobinetti@my-deja.com> wrote:
> > > In article <95tre2$f33@news.kvaerner.com>,
> > >   "Tarjei T. Jensen" <tarjei.jensen@kvaerner.com> wrote:
> > > > Have you tried to insert a size directive. e.g
> > > >
> > > > type TYP_ENUM is (A,B,C);
> > > >
> > > > for TYP_ENUM'size use 32;
> > >
> > > Done. But the problem is still the same ...
> > > Why?
> >
> > Presumably a capacity limitation in the compiler you are
> > using, not a terribly justifiable one, so you should bring
> > this to the attention of the vendor. Most likely the decision
> > is to use a signed 32-bit integer to represent enumerations,
> > which as you see in this case can be an annoying restriction.
> >
> > Sent via Deja.com
> > http://www.deja.com/
>
> Indeed, GNAT on WinNT (Pentium-II) will allow the following:
>
>     type TYP_ENUM is (A,B,C);
>
>     for TYP_ENUM use(
>        -16#8000000000000000#,
>         16#00000002#,------#
>         16#7FFFFFFFFFFFFFFF#  -- <<<<< NOTICE THIS VALUE !!!
>  );
>
> Apparently, GNAT is using a signed 64-bit integer.
>
> Incidently, both compilers are sticking to the
> "at least" portion of the implementation advice -- they
> just define System.Min_Int and System.Max_Int differently:
>
> (Copied from Lutz Donnerhacke's post)
> >Implementation Advice
> > 9. The recommended level of support for
> enumeration_representation_clauses is:
> >      1. An implementation should support at least the internal codes
> in the
> >         range System.Min_Int..System.Max_Int. An implementation need
> not
> >         support enumeration_representation_clauses for boolean types.
>
> Markku Kotiaho




  reply	other threads:[~2001-02-08 16:27 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-08  9:53 Representation clause for enumeratives Sandro Binetti
2001-02-08 10:12 ` Tarjei T. Jensen
     [not found]   ` <95u470$ho1$1@nnrp1.deja.com>
     [not found]     ` <95ua6q$mp4$1@nnrp1.deja.com>
2001-02-08 15:41       ` M. Kotiaho
2001-02-08 16:27         ` Steve O'Neill [this message]
2001-02-09  7:26           ` Sandro Binetti
2001-02-09  9:29           ` Martin Dowie
2001-02-08 15:55     ` Marin David Condic
2001-02-08 16:22 ` Rod Chapman
2001-02-10  6:34   ` Robert Dewar
2001-02-12 11:32     ` Rod Chapman
2001-02-08 18:52 ` Greg Bek
     [not found] ` <Ndyg6.1048$y03.96769@news.flash.net>
2001-02-09  5:02   ` Ken Garlington
2001-02-10  6:29     ` Robert Dewar
2001-02-10 16:37       ` Ken Garlington
2001-02-10 17:29         ` Robert Dewar
2001-02-11  1:09           ` Ken Garlington
2001-02-11  5:27             ` Robert Dewar
2001-02-11 12:53               ` Laurent Guerby
2001-02-12  0:24                 ` Robert Dewar
2001-02-12 20:10                   ` Laurent Guerby
2001-02-11 14:50               ` Ken Garlington
2001-02-10 17:31         ` Robert Dewar
2001-02-11  1:09           ` Ken Garlington
2001-02-11  5:28             ` Robert Dewar
2001-02-11 14:50               ` Ken Garlington
2001-02-12  0:30                 ` Robert Dewar
2001-02-12  2:34                   ` Ken Garlington
2001-02-10  6:19   ` Robert Dewar
2001-02-10 11:42     ` David C. Hoos, Sr.
2001-02-10 16:37     ` Ken Garlington
     [not found] ` <3A829EB8.A098925E@baesystems.com>
     [not found]   ` <95uae3$n5j$1@nnrp1.deja.com>
2001-02-12  9:12     ` Stuart Palin
replies disabled

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