Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: Records tha...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 4224 of 5828
Post > Topic >>

Re: Records that could be arrays

by "Steve Whalen" <SteveWhalen001@[EMAIL PROTECTED] > Feb 25, 2006 at 07:24 PM

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;
 




 2 Posts in Topic:
Re: Records that could be arrays
"Steve Whalen"   2006-02-25 19:24:32 
Re: Records that could be arrays
"Dmitry A. Kazakov&q  2006-02-26 10:51:07 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 17:46:22 CDT 2008.