comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Ada Distilled problem
Date: Fri, 04 Mar 2016 18:21:26 +0000
Date: 2016-03-04T18:21:26+00:00	[thread overview]
Message-ID: <lysi06je8p.fsf@pushface.org> (raw)

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"?

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


             reply	other threads:[~2016-03-04 18:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-04 18:21 Simon Wright [this message]
2016-03-04 18:58 ` Ada Distilled problem Brad Moore
2016-03-04 21:36   ` Simon Wright
2016-03-04 19:01 ` Jeffrey R. Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox