comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Instanciation in a package spec.
Date: Thu, 23 Jan 2003 16:14:47 GMT
Date: 2003-01-23T16:14:47+00:00	[thread overview]
Message-ID: <wcc7kcvu9l4.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: b0p0t1$h0r$1@s1.read.news.oleane.net

"Jean-Pierre Rosen" <rosen@adalog.fr> writes:

> "Robert A Duff" <bobduff@shell01.TheWorld.com> a �crit dans le message de news: wccn0lsvth6.fsf@shell01.TheWorld.com...
> > "Jean-Pierre Rosen" <rosen@adalog.fr> writes:
> > > Since the body of the instance is elaborated at the point of instanciation, the body of the
> > > generic has better been elaborated already....
> >
> > I understand the *need* for the rule in Ada.  But it's still an annoying
> > restriction.  It's perfectly reasonable to want to export a generic and
> > an instance of that generic from the same package.  But Ada's
> > elaboration model prevents it.
> >
> If you make the instance a child (and put a pragma Elaborate_Body in the parent's spec),
> then it's OK.

That sometimes works, but not always.  It also requires the client to
"with" bits and pieces of the abstraction.  That's *sometimes* desirable
anyway, but in many cases, you want the client to get the whole
abstraction in one with_clause.  And you don't want to have extra names
polluting the namespace (sometimes you end up needing a name for the
child package, *and* names for some stuff inside it).

> Of course, you won't be able to use it from the body of the parent, but if you put it
> in a visible part, it's presumabely for external use.

It's likely for *both* internal and external use.

Instead of Elab_Body in the parent, you can put Elab_All(Parent) in the
child.  Then the parent body can 'with' the child (so long as it doesn't
call it during elaboration).

But often you want access to the instance in the private part of the
parent, so the child idea won't work.  For example, the private part has
a record component that is of a type declared in the instance.

A related problem is that you can't pass a private type to a generic (in
the same package visible part where the private type is declared).
I understand the reasons behind this rule, but it's still very
annoying.

- Bob



  reply	other threads:[~2003-01-23 16:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-22 10:48 Instanciation in a package spec Grein, Christoph
2003-01-22 16:54 ` Robert A Duff
2003-01-23 10:54   ` Jean-Pierre Rosen
2003-01-23 14:19     ` Robert A Duff
2003-01-23 15:13       ` Dmitry A. Kazakov
2003-01-23 16:23         ` Robert A Duff
2003-01-25 11:04           ` Dmitry A. Kazakov
2003-01-23 15:13       ` Jean-Pierre Rosen
2003-01-23 16:14         ` Robert A Duff [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-01-22 10:22 Gautier direct_replies_not_read
2003-01-22 17:53 ` Martin Dowie
replies disabled

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