comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Construction initialization problem
Date: Thu, 4 Dec 2008 15:02:12 -0800 (PST)
Date: 2008-12-04T15:02:12-08:00	[thread overview]
Message-ID: <b5578996-6595-499c-8031-3bfae82a6070@s9g2000prm.googlegroups.com> (raw)
In-Reply-To: gh9l0i$gsj$1@munin.nbi.dk

On Dec 4, 2:17 pm, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de> wrote in messagenews:oscmgxrpod50$.g7h7snlssha0$.dlg@40tude.net...
>
> > Consider this:
>
> >   type A is tagged limited null record;
> >   type B (X : not null access A'Class) is tagged limited null record;
>
> > Now we want to specialize B so that its instances would already contain A:
>
> You never explained why you would want the discriminant in the first place.
> I would think that it would be better to do what you've said about C
> (include the instance directly in it) from the beginning, and the problem
> doesn't come up.
>
> Access discriminants have a fairly high overhead in Ada (because of the
> possibility of coextensions), so unless you *need* coextensions, they ought
> to be avoided.
>
> One could use a named access type instead to declare the discriminant if you
> really need a discriminant. But the only time you must use a discriminant is
> if you have a discriminant-dependent component, and there is no interesting
> way to make a component dependent on an access discriminant. So I'd prefer
> to just avoid the discriminant.

I thought access discriminants---at least those with anonymous access
type---were put into Ada 95 (before there were coextensions) to allow
objects to point to other objects in a nested scope, in a restricted
way (i.e. only in limited types) that prevented those references to a
nested objects from staying around after the nested object
disappeared.  I wasn't aware that there were enough new features in
Ada 2005 to provide this ability without using access discriminants.
So what am I missing?

                                 -- Adam



  reply	other threads:[~2008-12-04 23:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-04 16:08 Construction initialization problem Dmitry A. Kazakov
2008-12-04 17:35 ` Adam Beneschan
2008-12-04 22:17 ` Randy Brukardt
2008-12-04 23:02   ` Adam Beneschan [this message]
2008-12-06  1:47     ` Randy Brukardt
2008-12-05  9:00   ` Dmitry A. Kazakov
2008-12-06  1:42     ` Randy Brukardt
2008-12-06 10:16       ` Dmitry A. Kazakov
replies disabled

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