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 2 of 2 Topic 4224 of 5857
Post > Topic >>

Re: Records that could be arrays

by "Dmitry A. Kazakov" <mailbox@[EMAIL PROTECTED] > Feb 26, 2006 at 10:51 AM

On 25 Feb 2006 19:24:32 -0800, Steve Whalen wrote:

> 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;

(:-)) Is it C or FORTRAN? I thought nobody uses EQUIVALENCE blocks
anymore!

No, the above is not an implementation of two interfaces by the same type.
It is two overlapped objects of two different types. The difference, apart
from safety issues, is that you have to do it on per instance basis. To
get
it right, you need 1) multiple interface inheritance (this comes with Ada
200Y) 2) abstract array and record interfaces (this does not.)

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
 




 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 Wed Aug 20 4:44:34 CDT 2008.