comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Records that could be arrays
Date: Sun, 26 Feb 2006 10:51:07 +0100
Date: 2006-02-26T10:50:58+01:00	[thread overview]
Message-ID: <bes7dbq7ouvl.1ru56in08q8bb.dlg@40tude.net> (raw)
In-Reply-To: 1140924272.052117.106800@u72g2000cwu.googlegroups.com

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



  reply	other threads:[~2006-02-26  9:51 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-23  4:11 Records that could be arrays Justin Gombos
2006-02-23  4:51 ` tmoran
2006-02-23 13:19   ` Justin Gombos
2006-02-24 10:19     ` Stephen Leake
2006-02-23  6:32 ` Wilhelm Spickermann
2006-02-23 13:08   ` Stephen Leake
2006-02-23 13:20   ` Justin Gombos
2006-02-23 14:29     ` Wilhelm Spickermann
2006-02-24 10:31       ` Stephen Leake
2006-02-26 22:34         ` Wilhelm Spickermann
2006-02-23  8:21 ` john Doef
2006-02-23  9:22 ` Jean-Pierre Rosen
2006-02-23 13:11   ` Stephen Leake
2006-02-23 13:37   ` Justin Gombos
2006-02-23 13:06 ` Stephen Leake
2006-02-23 20:23   ` Simon Wright
2006-02-24 21:23   ` Randy Brukardt
2006-02-25 11:39     ` Dmitry A. Kazakov
2006-02-26  3:24       ` Steve Whalen
2006-02-26  9:51         ` Dmitry A. Kazakov [this message]
2006-02-27  2:26           ` Steve Whalen
2006-02-27  9:33             ` Dmitry A. Kazakov
2006-03-01 22:44             ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox