comp.lang.ada
 help / color / mirror / Atom feed
* Enumerated types and attributes thereof?
@ 1998-04-17  0:00 Gerhard J. Feichtinger
  1998-04-17  0:00 ` Gerhard J. Feichtinger
  1998-04-18  0:00 ` Robert Dewar
  0 siblings, 2 replies; 3+ messages in thread
From: Gerhard J. Feichtinger @ 1998-04-17  0:00 UTC (permalink / raw)



Hey all,

I have a question.... (Ada 83)

Let's say you have TEST_TYPE (one, three, five) uses (one => 1,
three => 3, five => 5).

How can I, without using UNCHECKED_CONVERSION get an INTEGER 1,3,5
converted to the correct value of TEST_TYPE?

Can't do it using <'val>  TEST_TYPE'val(1) eval's to three.
Incidentally <'pos> is screwy  TEST_TYPE'pos(one) eval's to 0.

I probably am asking a silly question... 

Gerhard.
-- 
 Gerhard J. Feichtinger             gerhard.j.feichtinger@lmco.com  
 My opinions do not necessarily reflect those of Lockheed Martin FS.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Enumerated types and attributes thereof?
  1998-04-17  0:00 Enumerated types and attributes thereof? Gerhard J. Feichtinger
@ 1998-04-17  0:00 ` Gerhard J. Feichtinger
  1998-04-18  0:00 ` Robert Dewar
  1 sibling, 0 replies; 3+ messages in thread
From: Gerhard J. Feichtinger @ 1998-04-17  0:00 UTC (permalink / raw)



Hello again,

Never mind -- :(  No other way to do it.

Gerhard.

Gerhard J. Feichtinger wrote:

> Hey all,
>
> I have a question.... (Ada 83)
>
> Let's say you have TEST_TYPE (one, three, five) uses (one => 1,
> three => 3, five => 5).
>
> How can I, without using UNCHECKED_CONVERSION get an INTEGER 1,3,5
> converted to the correct value of TEST_TYPE?
>
> Can't do it using <'val>  TEST_TYPE'val(1) eval's to three.
> Incidentally <'pos> is screwy  TEST_TYPE'pos(one) eval's to 0.
>
> I probably am asking a silly question...
>
> Gerhard.
> --
>  Gerhard J. Feichtinger             gerhard.j.feichtinger@lmco.com
>  My opinions do not necessarily reflect those of Lockheed Martin FS.



--
 Gerhard J. Feichtinger             gerhard.j.feichtinger@lmco.com
 My opinions do not necessarily reflect those of Lockheed Martin FS.






^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Enumerated types and attributes thereof?
  1998-04-17  0:00 Enumerated types and attributes thereof? Gerhard J. Feichtinger
  1998-04-17  0:00 ` Gerhard J. Feichtinger
@ 1998-04-18  0:00 ` Robert Dewar
  1 sibling, 0 replies; 3+ messages in thread
From: Robert Dewar @ 1998-04-18  0:00 UTC (permalink / raw)



Gerhard asks

<<How can I, without using UNCHECKED_CONVERSION get an INTEGER 1,3,5
converted to the correct value of TEST_TYPE?

Can't do it using <'val>  TEST_TYPE'val(1) eval's to three.
Incidentally <'pos> is screwy  TEST_TYPE'pos(one) eval's to 0.

I probably am asking a silly question...
>>

Well it is certainly a strange question, it is a bit like asking 
"How can I, without using the plus operator, add two floating-point
numbers."

Unchecked_Conversion is exactly the tool you need here, so why the
reluctance to use it?

As for screwy 'pos, anything can seem "screwy" if you do not know the
language rules! The Pos attribute gives the zero origin position of
the enumeration literal, since one is the first literal, it has the
position number of zero. No one who has read the Ada RM (or for that
matter any elementary Ada book) would expect anything else here!





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1998-04-18  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-17  0:00 Enumerated types and attributes thereof? Gerhard J. Feichtinger
1998-04-17  0:00 ` Gerhard J. Feichtinger
1998-04-18  0:00 ` Robert Dewar

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