Re: Records that could be arrays
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Sun, 26 Feb 2006 10:51:07 +0100
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
.
- Follow-Ups:
- Re: Records that could be arrays
- From: Steve Whalen
- 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
- Re: Records that could be arrays
- From: Steve Whalen
- Records that could be arrays
- Prev by Date: Re: OT: Re: help with include and library files in GPS
- Next by Date: Programming in Ada 2005 book
- Previous by thread: Re: Records that could be arrays
- Next by thread: Re: Records that could be arrays
- Index(es):
Relevant Pages
|
|