Re: accessing record element (question to the pros)



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
.