From: Simon Wright <simon@pushface.org>
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
Date: 2020-01-18T20:53:13+00:00 [thread overview]
Message-ID: <lyblr0xz9i.fsf@pushface.org> (raw)
In-Reply-To: e99b708d-d0bd-4ae6-b099-3bcfb9cadc77@googlegroups.com
Mace Ayres <maceayres0@gmail.com> 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
next prev parent reply other threads:[~2020-01-18 20:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-17 23:30 Calling a record type's methods (functions or procedure) when record is in an array Mace Ayres
2020-01-18 12:31 ` Simon Wright
2020-01-18 18:02 ` Mace Ayres
2020-01-18 20:53 ` Simon Wright [this message]
2020-01-21 20:51 ` Shark8
2020-01-21 23:17 ` Jeffrey R. Carter
2020-01-23 15:00 ` joakimds
2020-01-23 15:02 ` joakimds
2020-01-23 16:51 ` Simon Wright
2020-01-24 9:47 ` joakimds
2020-01-23 20:15 ` Optikos
2020-01-19 15:06 ` Mace Ayres
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox