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:a05:620a:911:: with SMTP id v17mr39390148qkv.251.1579370552036; Sat, 18 Jan 2020 10:02:32 -0800 (PST) X-Received: by 2002:a05:6830:1e16:: with SMTP id s22mr10509491otr.340.1579370551712; Sat, 18 Jan 2020 10:02:31 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!fdn.fr!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!g89no10069379qtd.0!news-out.google.com!w29ni1685qtc.0!nntp.google.com!g89no10069371qtd.0!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 18 Jan 2020 10:02:31 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=73.93.154.250; posting-account=GiLbEwoAAACYQywnkrMcpkBZWnZYVPiI NNTP-Posting-Host: 73.93.154.250 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: Sat, 18 Jan 2020 18:02:32 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:57877 Date: 2020-01-18T10:02:31-08:00 List-Id: Thank you. I see, we can pass the record (type) thing as a parameter, along= with any other parameters (like value) and then interact with the record = =E2=80=98thing=E2=80=99 in sub programs.=20 Since my objects (type of Thing) are only instantiated as elements in my ar= ray, thing_array, I can only/ would I address them like this ? looping.. i looping j set_attribute(my_thing_array(i,j).value, 6); ... end loop; end loop; In this way I only access (not ACCESS type) my thing via set_attribute proc= edure and not with... thing.value :=3D 5, which is the direct access we wa= nt to avoid.=20 And with type thing being private, its attributes are only accessible via s= ub programs in package Mace. In your code below with my mark up =E2=80=9C * ?=E2=80=9D, are the sub pro= grams private in any way since they are below Type Thing is private, or th= e privacy is applied to Thing? That is, what is the full scope of privacy in declaring type thing as priva= te, to type thing only, or the sub programs too. Or is this a confused que= stion anyway? ? 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 :=3D Value; end Set_Attribute; function Get_Attribute (From : Thing) return Integer is (From.Attribute); end Mace;