comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Enumerated types and attributes thereof?
Date: 1998/04/18
Date: 1998-04-18T00:00:00+00:00	[thread overview]
Message-ID: <dewar.892872637@merv> (raw)
In-Reply-To: 3537A1F6.41C6@lmco.com


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!





      parent reply	other threads:[~1998-04-18  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]
replies disabled

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