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!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Experimenting with the OOP features in Ada Date: Wed, 4 Jan 2017 13:44:28 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <29380aa7-0c3b-4908-94c6-aa91f3996b42@googlegroups.com> NNTP-Posting-Host: s3c6wwRqkurrfTZpuYYZ+w.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:33040 Date: 2017-01-04T13:44:28+01:00 List-Id: On 2017-01-04 13:18, Laurent wrote: > Other thing I don't understand: > > For the persistent storage solution I need those handles. Actually the base type for persistent objects is Object.Archived.Deposit. Object.Entity is merely a reference-counted object. Object.Archived.Deposit is that plus operations to serialize/deserialize and handle inter-object dependencies/references. > So I tried to adapt > the Base_Types package by copying the Safe_Strings example. > > with My_Strings; > with My_Strings.Handle; > with Object; > > package Base_Types is > > type Object is abstract new Object.Entity with private; > > subtype Name_Type is My_Strings.Handle.My_Safe_String; > subtype Code_SIL_Type is My_Strings.Handle.My_Safe_String; > > procedure Set_Name (Item : in out Object; Name : String) is abstract; > procedure Set_Code_SIL (Item : in out Object; Code_SIL : String) is abstract; > > function Name_Value (Item : Object) return String is abstract; > function Code_SIL_Value (Item : Object) return String is abstract; > > private > > type Object > is abstract new Object.Entity with > record > Name : Name_Type; > Code_SIL : Code_SIL_Type; > end record; If you are not going to change string components you could simply do type Object (Name_Length : Positive; Code_SIL_Length : Positive) is abstract new Object.Entity with record Name : String (1..Name_Length); Code_SIL : String (1..Code_SIL_Length); end record; > type Base_Type_Ptr is access Object'Class; > > end Base_Types; > > There seems to be no place where I can insert an tagged keyword? Object.Entity and Object.Archived.Deposit are already tagged. > When I compile this I get a few errors: > > and some more of the following but they are just a symptom not the cause: > > test.adb:16:23: invalid prefix in selected component "Test_Antibiotic" > test.adb:16:38: prefixed call is only allowed for objects of a tagged type > > base_types.ads:7:32: object "Object" cannot be used before end of its > declaration > base_types.ads:22:20: type "Object" cannot be used before end of its declaration > base_types.ads:28:33: tagged type required, found type "Object" defined at line > 21 The package name Object gets hidden by the declaration the type Object. Change it to: type Object is abstract new Standard.Object.Entity ... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de