Re: accessing record element (question to the pros)
- From: "Jeffrey R. Carter" <spam@xxxxxxxx>
- Date: Fri, 24 Feb 2006 18:02:09 GMT
Norbert Caspari wrote:
Could somebody please help me to correct my code, showing me how to access a numeric value to the variable Yyy.
You can't, because Yyy is not of a numeric type.
However, in general, you can't do what you seem to be trying to do. Variant records do not allow unchecked type conversion; the language rules prohibit it. That's what Ada.Unchecked_Conversion is for.
For the specific problem of accessing bits in an unsigned integer, you can use the logical operators on modular types: and, or, Shift_Right, and so on. For a signed integer, you can unchecked convert to an array of Boolean, but then you have a portability problem: is the LSB in 'First or 'Last? This is not defined by the language.
--
Jeff Carter
"I've got to stay here, but there's no reason
why you folks shouldn't go out into the lobby
until this thing blows over."
Horse Feathers
50
.
- Follow-Ups:
- Re: accessing record element (question to the pros)
- From: Simon Wright
- Re: accessing record element (question to the pros)
- References:
- accessing record element (question to the pros)
- From: Norbert Caspari
- accessing record element (question to the pros)
- Prev by Date: Re: accessing record element (question to the pros)
- Next by Date: Re: accessing record element (question to the pros)
- Previous by thread: Re: accessing record element (question to the pros)
- Next by thread: Re: accessing record element (question to the pros)
- Index(es):