comp.lang.ada
 help / color / mirror / Atom feed
* Extensions in generic bodies - Language Laywer question
@ 1998-10-08  0:00 dennison
  1998-10-08  0:00 ` Robert I. Eachus
  0 siblings, 1 reply; 2+ messages in thread
From: dennison @ 1998-10-08  0:00 UTC (permalink / raw)


Here's one for the langauge Laywers. 3.9.1(4) says: "A type extension shall
not be declared in a generic body if the parent type is declared outside that
body. "

Does that also go for instantiating generics that *cause* a type extension? My
compiler seems to think so.

My situation: I'm trying to create a generic object. Internally (In the body)
I want to keep a queue of these objects. I figure I'll use the Ada95
Booch-components. So in my generic's body I'm instantiating a Booch-Component
container with the object that my generic was instantiated with. However,
BC.Containers contains a type extension in its private section. So when I
compile my generic's body, my compiler blows up at the line of my
instantiation of BC.Containers parroting LRM:3.9.1(4) and also pointing to
the type extension in BC.Containers.

generic
   type Object is private;
package Interface_Object is
.
.
.
end Interface Object;

with BC.Containers;

package body Interface_Object is

  type Object_Ptr is access all Object;  package Object_Container is new
BC.Containers (Item => Object,	Item_Ptr => Object_Ptr);  package
Object_Queue is new Object_Container.Queues.Bounded (Maximum_Size => 10, 
Bnd_Queue_Nodes => Object_Container); . . . end Interface_Object;

Compiling 'Interface_Object.adb': Thu Oct 08 09:47:13 1998

interface_object.adb: Error: line 7 col 30 LRM:3.9.1(4), A type extension may
not be declared in a generic body if the parent type is declared outside that
body; this applies to the visible part of a generic instantiation  (In
instance of generic Containers at bc-containers.ads: line 47 col 10)



--
T.E.D.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Extensions in generic bodies - Language Laywer question
  1998-10-08  0:00 Extensions in generic bodies - Language Laywer question dennison
@ 1998-10-08  0:00 ` Robert I. Eachus
  0 siblings, 0 replies; 2+ messages in thread
From: Robert I. Eachus @ 1998-10-08  0:00 UTC (permalink / raw)


In article <6vijho$qps$1@nnrp1.dejanews.com> dennison@telepath.com writes:

  > Here's one for the langauge Laywers. 3.9.1(4) says: "A type extension shall
  > not be declared in a generic body if the parent type is declared
  > outside that body."

  Yes, it has to do with dispatch tables.  The same problem occurs
with non-generic bodies, but other rules ensure that the problem cases
can never occur.

  > Does that also go for instantiating generics that *cause* a type
  > extension? My compiler seems to think so.

  Yes.

  > My situation: I'm trying to create a generic object. Internally
  > (In the body) I want to keep a queue of these objects...

  In this case, you should be able to declare the type in the private
part, and I remember that as the reason for keeping the rule simple.
In any case that can be made to work, the type declaration can be
moved to (the private part of) the generic spec.  This may, as in the
current case, also require moving with clauses.  (In pathological
cases, you have to move the declaration to a new child unit.)
--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-10-08  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-08  0:00 Extensions in generic bodies - Language Laywer question dennison
1998-10-08  0:00 ` Robert I. Eachus

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