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.50.142.2 with SMTP id rs2mr375985igb.6.1457117895806; Fri, 04 Mar 2016 10:58:15 -0800 (PST) X-Received: by 10.182.19.129 with SMTP id f1mr126850obe.20.1457117895780; Fri, 04 Mar 2016 10:58:15 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!ok5no6069619igc.0!news-out.google.com!pn7ni214igb.0!nntp.google.com!ok5no6069618igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 4 Mar 2016 10:58:15 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=68.145.219.148; posting-account=lzqe5AoAAADHhp_gregSufVhvwu22fBS NNTP-Posting-Host: 68.145.219.148 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Ada Distilled problem From: Brad Moore Injection-Date: Fri, 04 Mar 2016 18:58:15 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:29671 Date: 2016-03-04T10:58:15-08:00 List-Id: On Friday, March 4, 2016 at 11:21:28 AM UTC-7, Simon Wright wrote: > A Stack Overflow user has been having problems[1] trying to use the > queue manager described at page 82 of Ada Distilled (2005 version)[2]. > > To see the problem in its essentials, the (inoperative!) spec could be > > generic > type Element is tagged private; > package Lists is > type Item is new Element with private; > type List is tagged private; > > procedure Insert (Self : in out List; I : Item'Class); > > private > type Item is new Element with null record; > type List is tagged null record; > end Lists; > > with a calling program > > with Lists; > procedure Main is > type Temp is tagged null record; > package Temp_List is new Lists (Temp); > > FL : Temp_List.List; > > Instance : Temp := Temp'(null record); > > begin > Temp_List.Insert (Self => FL, I => Instance); > end Main; > > resulting in > > main.adb:11:40: expected type "Item'Class" defined at lists.ads:4, > instance at line 4 > main.adb:11:40: found type "Temp" defined at line 3 > > and I can't see any way of twisting this so it can compile. And, in any > case, what is the point of "type Item"? I dont see any point. Looks to me like the example needs to be corrected. I would change the 'I' parameter of the Insert to be of type Element'Class, then this should compile. Brad > > Has anyone managed to use the Ada Distilled design? (of course, nowadays > one would implement either directly or over predesigned containers). > > [1] > http://stackoverflow.com/questions/35790004/ada-package-with-generic-tagged > [2] http://www.adaic.org/learn/materials/#ada_2005_books - first entry