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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a37:de05:: with SMTP id h5mr48026633qkj.474.1579446400941; Sun, 19 Jan 2020 07:06:40 -0800 (PST) X-Received: by 2002:aca:f10:: with SMTP id 16mr9744187oip.117.1579446400644; Sun, 19 Jan 2020 07:06:40 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!peer03.am4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!g89no1115679qtd.0!news-out.google.com!o19ni207qtr.1!nntp.google.com!g89no1115674qtd.0!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 19 Jan 2020 07:06:40 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=2601:645:c000:3db6:48dc:8f66:e571:5193; posting-account=GiLbEwoAAACYQywnkrMcpkBZWnZYVPiI NNTP-Posting-Host: 2601:645:c000:3db6:48dc:8f66:e571:5193 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Calling a record type's methods (functions or procedure) when record is in an array From: Mace Ayres Injection-Date: Sun, 19 Jan 2020 15:06:40 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 2708 X-Received-Body-CRC: 567663475 Xref: reader01.eternal-september.org comp.lang.ada:57897 Date: 2020-01-19T07:06:40-08:00 List-Id: On Friday, January 17, 2020 at 3:30:54 PM UTC-8, Mace Ayres wrote: > My package 'trunks.ads' includes=20 > ... > type a_trunk;. >=20 > function set_lock ... return lock_state; >=20 > function post_val(v:integer) --- return integer > ... > type a_trunk is > record > id : ,,, > val > ... > lock : lock_state -- enumeration type defined earlier (open, lock= ed) > end record; >=20 > Package body 'trunks.adb includes ... >=20 > function set_lock ( ..... not relevant >=20 > function post_val i(v:integer) return integer is ..return v; >=20 > ------ > In package 1 I have a multi dimension array of type a_truck that I get to= with > .. > loop de loop i,j > my_trunk_array (i)(j) > .. > ------- >=20 > To modify the item val in the trunk at array (5)(3) I code.. >=20 > ... my_truck_arrary(5)(3).val :=3D trunks.post_val(N) >=20 > rather than my_tunk_arrary(5)(3).val :=3D N >=20 > so I don't directly access the a_trunk record's value fields directly >=20 > -- I have to add the private part too, to hide the inners of type a_trunk= . >=20 > It seem a little convoluted, but I see no other way to manipulate my a_tr= uck type records that only 'exist' the array. >=20 > I am just learning Ada. Is this reasonable? =E2=80=94=E2=80=94 Thanks Simon.