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 10.176.1.140 with SMTP id 12mr1962572ual.15.1483542587455; Wed, 04 Jan 2017 07:09:47 -0800 (PST) X-Received: by 10.157.31.20 with SMTP id x20mr3156551otd.10.1483542587409; Wed, 04 Jan 2017 07:09:47 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!1.eu.feeder.erje.net!feeder.erje.net!2.us.feeder.erje.net!feeder.usenetexpress.com!feeder1.iad1.usenetexpress.com!216.166.98.84.MISMATCH!border1.nntp.dca1.giganews.com!nntp.giganews.com!d45no115637qta.0!news-out.google.com!g131ni3811itg.0!nntp.google.com!b123no216095itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 4 Jan 2017 07:09:46 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=67.0.242.189; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 67.0.242.189 References: <29380aa7-0c3b-4908-94c6-aa91f3996b42@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <70f79da7-018c-48a3-bf3d-79da0e871a72@googlegroups.com> Subject: Re: Experimenting with the OOP features in Ada From: Shark8 Injection-Date: Wed, 04 Jan 2017 15:09:47 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:33045 Date: 2017-01-04T07:09:46-08:00 List-Id: On Wednesday, January 4, 2017 at 5:18:42 AM UTC-7, Laurent wrote: >=20 > with My_Strings; > with My_Strings.Handle; > with Object; >=20 > package Base_Types is >=20 > type Object is abstract new Object.Entity with private; > =20 > subtype Name_Type is My_Strings.Handle.My_Safe_String; > subtype Code_SIL_Type is My_Strings.Handle.My_Safe_String; >=20 > procedure Set_Name (Item : in out Object; Name : String) is abstract; > procedure Set_Code_SIL (Item : in out Object; Code_SIL : String) is ab= stract; >=20 > function Name_Value (Item : Object) return String is abstract; > function Code_SIL_Value (Item : Object) return String is abstract; >=20 > private >=20 > type Object=20 > is abstract new Object.Entity with > record > Name : Name_Type; > Code_SIL : Code_SIL_Type; > end record; > =20 > type Base_Type_Ptr is access Object'Class; >=20 > end Base_Types; >=20 > There seems to be no place where I can insert an tagged keyword? Is that > possible or do I have to do it differently? >=20 > When I compile this I get a few errors: >=20 > and some more of the following but they are just a symptom not the cause: >=20 > 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 typ= e >=20 > 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 decl= aration > base_types.ads:28:33: tagged type required, found type "Object" defined a= t line > 21 You're misunderstanding the errors -- they aren't about the keyword 'Tagged= ', they're about the declaration itself. When you have "Type object [...]" everything after that hides package Objec= t you're withing. (Hence the compiler saying "type 'Object' cannot be used = before end of its declaration".) -- The solution is to _immediately_ after = "package Base_Types is" insert a line renaming package Object and then pref= ix type object's derivation-definition with the rename. Example: With Object; package Base_Types is Package Obj_Rename renames Object; =20 type Object is abstract new Obj_Rename.Object.Entity with private; That will take care of that error.