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.52.92.69 with SMTP id ck5mr6114383vdb.7.1436286449007; Tue, 07 Jul 2015 09:27:29 -0700 (PDT) X-Received: by 10.140.42.225 with SMTP id c88mr69902qga.26.1436286448987; Tue, 07 Jul 2015 09:27:28 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!w90no1434259qge.0!news-out.google.com!w15ni30875qge.0!nntp.google.com!w90no1434255qge.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 7 Jul 2015 09:27:28 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=94.107.233.114; posting-account=6m7axgkAAADBKh082FfZLdYsJ24CXYi5 NNTP-Posting-Host: 94.107.233.114 References: <0ade6abf-34c0-46e2-8bd9-d60a00056321@googlegroups.com> <28d2406c-d579-4710-9b34-108317fe9abf@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Declaring constants for a abstract tagged type and concrete sub classes From: Serge Robyns Injection-Date: Tue, 07 Jul 2015 16:27:28 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:26683 Date: 2015-07-07T09:27:28-07:00 List-Id: On Monday, 6 July 2015 19:37:00 UTC+2, G.B. wrote: > On 06.07.15 15:49, Serge Robyns wrote: > > >> In case you can afford a publicly abstract but > >> privately non-abstract type, > >> > >> package Abstract_Root is > >> type T_Root is abstract tagged private; > >> procedure Set_XYZ (Self: in out T_Root; ABC : in Integer); > >> function Get_XYZ (Self: in T_Root) return Integer; > >> No_Element : constant T_Root; -- or T_Root'Class; > >> private > >> type T_Root is tagged record > >> XYZ : Integer; > >> end record; > >> No_Element : constant T_Root := T_Root'(Xyz => 666); > >> end Abstract_Root; > >> > >> Every object needs to be of a concrete type, whether constant > >> or not. (...) > > > Seems not to work as expected, at least not on GNAT 2015. > > Just FTR, this is a working example, tested with GNAT 2015; > did you change T_Root to concrete in the private part of > Abstract_Root, leaving it abstract only in the public part? > Is your constant No_Element perhaps declared outside Abstract_Root? > > > If I use No_Element : constant T_Root; => I get "type of object > cannot be abstract" compile error I found the issue ... In the private part I still had a type T_Root is abstract tagged record. This is why I did put it aside for a while and then re-look at it afresh. Now I'm facing my other issue, how to "merge" the root and child part in a new No_Element ... This is about valid Ada syntax. No_Element : constant T_Concrete := ( T_Root.No_Element, 789); This gets expectingly rejected. And I'm facing my inexperience in Ada. Serge