From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ffc9e2fe760c58fd X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed-east.nntpserver.com!nntpserver.com!statler.nntpserver.com!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Records that could be arrays Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <189zs75645p7g.1usdp56yox0lg$.dlg@40tude.net> <1140924272.052117.106800@u72g2000cwu.googlegroups.com> Date: Sun, 26 Feb 2006 10:51:07 +0100 Message-ID: NNTP-Posting-Date: 26 Feb 2006 10:50:58 MET NNTP-Posting-Host: 2c17e601.newsread4.arcor-online.net X-Trace: DXC=W>BJ_OP:ejgIfPPldTjW\KbG]kaMXQc4L4[MA2TPj1dE2[fYJ[[[6LHn;2LCV^[ 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