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!mx02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Ada Distilled problem Date: Fri, 04 Mar 2016 21:36:47 +0000 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="900e1437335c90c92a3116ad49605f53"; logging-data="5262"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187H5E1MJfcAcwsMZMZdEBcIRKmh1XpfUc=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:0vA2dNZ+mNcUur78I/vzbhywcrg= sha1:zdTeUlK3C+WbNGJnAMtTN/hQVSY= Xref: news.eternal-september.org comp.lang.ada:29675 Date: 2016-03-04T21:36:47+00:00 List-Id: Brad Moore writes: > 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. Yes, I agree. When I said I "can't see any way of twisting this so it can compile" I meant that I was trying to get Main to compile without changing Lists.