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!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: Experimenting with the OOP features in Ada Date: Tue, 3 Jan 2017 13:01:23 -0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <29380aa7-0c3b-4908-94c6-aa91f3996b42@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Tue, 3 Jan 2017 13:01:23 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="a12737357a658730bd7499ca260b1af3"; logging-data="11590"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19FlkS7DFTpKYl/CHGZwThhqrclTo+L3bI=" User-Agent: Pan/0.140 (Chocolate Salty Balls; GIT b8fc14e git.gnome.org/git/pan2) Cancel-Lock: sha1:VIYcX34p5B3rmrcmNod9K0wxVuM= Xref: news.eternal-september.org comp.lang.ada:33017 Date: 2017-01-03T13:01:23+00:00 List-Id: On Mon, 02 Jan 2017 08:27:44 -0800, Laurent wrote: > On Monday, 2 January 2017 15:44:57 UTC+1, Brian Drummond wrote: >> So the >> following are equivalent: >> >> Test_Antibiotic := Base_Types.Antibiotics.Create_Code_SIL ( >> This => Test_Antibiotic, Code_SIL => "Test >> Antibiotic 3") >> >> Test_Antibiotic := Test_Antibiotic.Create_Code_SIL >> (Code_SIL => "Test Antibiotic 3"); >> >> but the preferred form would be >> >> Test_Antibiotic.Set_Code_SIL (Code_SIL => "gen"); >> >> -- Brian > > Yes last one looks nice but doesn't work. No selector... Object is > private. > So 2nd one. > Now I won't compile because Base_Types.Object is abstract. So I have to > figure out how/where to put the overriding works. In John Barnes Book it > looks so easy and light. Doing it myself feels clumsy I recommend learning how to make the nicest looking one work; my procedure was a first pass at guidance, not a complete solution. Procedure Set_Code_SIL (This : in out Base_Types.Antibiotics.Objects; Code_SIL => "gen"); Where did you put this procedure? As Dmitry says, you need to provide setters if you're manipulating parts of an object, so this procedure, a setter, should be part of the Base_Types.Antibiotics package (with implementation in its body) so that it has access to the private part, where the components are declared. The error message fragment (without file:location) you report suggests it was probably somewhere else. -- Brian