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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.Oh2LSLzxQ4+YU0Htrufc+A.user.gioia.aioe.org!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Calling a record type's methods (functions or procedure) when record is in an array Date: Sat, 18 Jan 2020 12:31:23 +0000 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: Oh2LSLzxQ4+YU0Htrufc+A.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (darwin) Cancel-Lock: sha1:YOJ7Xbr1cpIvpIu78+AtEdv9NDw= X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:57869 Date: 2020-01-18T12:31:23+00:00 List-Id: Mace Ayres writes: > To modify the item val in the trunk at array (5)(3) I code.. > > ... my_truck_arrary(5)(3).val := trunks.post_val(N) > > rather than my_tunk_arrary(5)(3).val := N > > so I don't directly access the a_trunk record's value fields directly ? this code does indeed access the value fields directly! > -- I have to add the private part too, to hide the inners of type > a_trunk. You're looking for an accessor (though accessors aren't always a good idea; there might be checks needed, attributes may be related so you need to deal with more than one at the same time, eg coordinates): package Mace is type Thing is private; procedure Set_Attribute (Into : in out Thing; Value : Integer); function Get_Attribute (From : Thing) return Integer; private type Thing is record Attribute : Integer; end record; end Mace; package body Mace is procedure Set_Attribute (Into : in out Thing; Value : Integer) is begin Into.Attribute := Value; end Set_Attribute; function Get_Attribute (From : Thing) return Integer is (From.Attribute); end Mace;