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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,be3624bccee5d9e7 X-Google-Attributes: gid103376,public From: geert@fozzie.sun3.iaf.nl (Geert Bosch) Subject: Re: Abstract type derivation? Date: 1996/04/12 Message-ID: <4kl5eb$djn@fozzie.sun3.iaf.nl>#1/1 X-Deja-AN: 147165789 references: <4kb0hb$k87@dfw.dfw.net> organization: La Calandre Infortunee newsgroups: comp.lang.ada Date: 1996-04-12T00:00:00+00:00 List-Id: David wrote: `` I want to create an abstract type that is derived from Controlled (which is itself abstract). Either the syntax isn't clear or it can't be done :-) '' Hmm... I've made an abstract storage pool class (for my GNAT garbage collector) and it compiled just fine. Right now, the class isn't abstract anymore, but I'm rather sure it did compile properly. I also can't think of a reason to prohibit abstract derivations of non-abstract types, since it's a very useful thing to have for good SE practice. type Queue is new Controlled with private; -- allows users to declare a type Queue I don't understand this comment. *You* did declare a type Queue, so what does that have to do with users declaring a type Queue. Do you mean a type derived from Queue, or an object of type Queue. type Queue is abstract tagged private; -- what I want, but now I don't have "Adjust" available, major bummer. You give very, very little context so it's hard to guess what you're trying to do. If you want the users of your Queue to be able to take advantage of the fact that Queue is a controlled type by letting them inherit Queue and override Adjust etc., then you use your first declaration. When you want to completely hide the implementation of Queue (so nobody will be able to provide a new implementation of adjust), then your second approach is the right one. Of course the complete declaration of Queue in the private part of the package should be the same as in the first case. Below I'll give you a sample to illustrate my points and make things more concrete. Am I missing something obvious? Either you are, or I am! ;-) Regards, Geert Example code for abstract controlled types: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ with Ada.Finalization; use Ada.Finalization; package Queues is -- Queue_A implements a type that is completely abstract to the -- user of the package. The user can see nothing but the operations -- exported here. type Queue_A is abstract tagged private; procedure My_Operation(Q: in out Queue_A) is abstract; -- Queue_B implements a type that shows it's inheritance -- from Controlled, but nothing else. The user may override -- the Initialize, Adjust and Finalize operations. type Queue_B is abstract new Controlled with private; procedure My_Operation(Q: in out Queue_B) is abstract; private -- In both cases the complete declaration in the private part -- is the same. type Queue_A is abstract new Controlled with null record; type Queue_B is abstract new Controlled with null record; end Queues; -- E-Mail: geert@sun3.iaf.nl *** As far as we know, there have not been *** Phone: +31-53-4303054 ** any undetected failures in our software. **