comp.lang.ada
 help / color / mirror / Atom feed
From: Keith Thompson <kst@cts.com>
Subject: Re: Unchecked_Conversion on different sized types -- problem?
Date: 2000/01/14
Date: 2000-01-14T00:00:00+00:00	[thread overview]
Message-ID: <yecpuv416oa.fsf@king.cts.com> (raw)
In-Reply-To: qXpf4.429$dw3.15200@news.wenet.net

"Mike Silva" <mjsilva@jps.net> writes:
[...]
> type T is ( BLACK, WHITE );
> 
> for T use ( BLACK => 30, WHITE => 37 );

Enumeration representation clauses are, in my opinion, a poorly
designed feature of the language.  The idea of assigning a numeric
value to each element of an enumeration type is potentially useful,
but the lack of a well-defined way to use get at the representation
makes it nearly useless in most applications.

When Ada 83 was originally designed, it was intended that a
representation clause should have as little effect as possible on the
behavior of a type; it's the compiler's responsibility to generate
code that "hides" the representation.  In this case, I think the
language designers hid the representation too well.  During the Ada 95
design, I think it was felt that enumeration representation clauses
weren't used often and thus weren't worth fixing.  (I'm probably
horribly misrepresenting the intent of the designers of both Ada 83
and Ada 95; feel free to jump in and correct me.)

With the addition of a couple of predefined attributes, similar to
'Val and 'Pos but operating on the underlying representation rather
than on position numbers, enumeration representation clauses could
have been far more useful.  GNAT's 'Enum_Rep attribute provides part
of this, but of course any code that uses it is non-portable.

-- 
Keith Thompson (The_Other_Keith) kst@cts.com  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center           <*>  <http://www.sdsc.edu/~kst>
Welcome to the last year of the 20th century.




  parent reply	other threads:[~2000-01-14  0:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-13  0:00 Unchecked_Conversion on different sized types -- problem? Mike Silva
2000-01-13  0:00 ` Jim Rogers
2000-01-13  0:00   ` Mike Silva
2000-01-13  0:00     ` James S. Rogers
2000-01-13  0:00 ` Bryce Bardin
2000-01-13  0:00   ` Mike Silva
2000-01-13  0:00     ` Mike Silva
2000-01-14  0:00       ` Bryce Bardin
2000-01-14  0:00         ` Mike Silva
2000-01-14  0:00   ` Matthew Heaney
2000-01-13  0:00 ` reason67
2000-01-14  0:00 ` Keith Thompson [this message]
2000-01-16  0:00   ` David A. Cobb
2000-01-14  0:00 ` Jeff Carter
2000-01-14  0:00 ` Wrap-Up (was Re: Unchecked_Conversion on different sized types -- problem?) Mike Silva
2000-01-15  0:00   ` Matthew Heaney
2000-01-15  0:00     ` Robert A Duff
2000-01-14  0:00 ` Unchecked_Conversion on different sized types -- problem? Werner Pachler
2000-01-14  0:00   ` reason67
2000-01-14  0:00   ` Bryce Bardin
2000-01-14  0:00 ` Vladimir Olensky
replies disabled

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