Re: Records that could be arrays
- From: "Steve Whalen" <SteveWhalen001@xxxxxxxxxxx>
- Date: 25 Feb 2006 19:24:32 -0800
Dmitry A. Kazakov wrote:
... The rest is a question of language deficiency. In this case an
inability to provide an array interface to a record type (to have
enumerated components), or a record interface to an array (to have named
components.) ...
I'm not sure what you mean by a language deficiency. If you really
want to address an object as either a record or an array, doesn't
something like this meet your needs?
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Redefine is
type IntRecord is
record
FirstInt : Integer;
SecondInt : Integer;
end record;
type IntArray is
array (1 .. 2) of Integer;
RecVar : IntRecord := (FirstInt => 1, SecondInt => 2);
ArrayVar : IntArray;
for ArrayVar'Address
use RecVar'Address;
begin
Put("First Record Element = ");
Put(RecVar.FirstInt);
New_Line;
Put("Array Element 2 = ");
Put(ArrayVar(2));
New_Line;
end Redefine;
.
- Follow-Ups:
- Re: Records that could be arrays
- From: Dmitry A. Kazakov
- Re: Records that could be arrays
- References:
- Records that could be arrays
- From: Justin Gombos
- Re: Records that could be arrays
- From: Stephen Leake
- Re: Records that could be arrays
- From: Randy Brukardt
- Re: Records that could be arrays
- From: Dmitry A. Kazakov
- Records that could be arrays
- Prev by Date: Re: limited types (Was: Records that could be arrays)
- Next by Date: Re: limited types (Was: Records that could be arrays)
- Previous by thread: Re: Records that could be arrays
- Next by thread: Re: Records that could be arrays
- Index(es):
Relevant Pages
|
|