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.2 required=5.0 tests=BAYES_00,URI_TRY_3LD autolearn=no 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 20:53:13 +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; charset=utf-8 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (darwin) Cancel-Lock: sha1:+rpnZKZK33U/qETSZIE/kTBC/qc= X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:57881 Date: 2020-01-18T20:53:13+00:00 List-Id: Mace Ayres writes: > 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 ‘thing’ in sub programs. Yes. > Since my objects (type of Thing) are only instantiated as elements in > my array, 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; > And with type thing being private, its attributes are only accessible > via sub programs in package Mace. Yes. > In your code below with my mark up “ * ?”, are the sub programs > private in any way since they are below Type Thing is private, or the > privacy is applied to Thing? > > That is, what is the full scope of privacy in declaring type thing as > private, to type thing only, or the sub programs too. Or is this a > confused question anyway? >> 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; The package spec has a public part (everything above the 'private' in the left margin of line 5) and a private part (everything after). The two subprograms are publicly visible. You need a tutorial! Try https://learn.adacore.com and specifically about privacy https://learn.adacore.com/courses/intro-to-ada/chapters/privacy.html or look here for lots of learning material https://www.adaic.org/learn/materials/#tutorials