comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: pointers and genericity
Date: Thu, 17 Feb 2005 17:11:27 -0600
Date: 2005-02-17T17:11:27-06:00	[thread overview]
Message-ID: <l9CdnTueAo6puYjfRVn-uA@megapath.net> (raw)
In-Reply-To: wccsm3wo8hv.fsf@shell01.TheWorld.com


"Robert A Duff" <bobduff@shell01.TheWorld.com> wrote in message
news:wccsm3wo8hv.fsf@shell01.TheWorld.com...
...
> If the access type is outside the generic body, then it's illegal
> to take 'Access of a procedure declared inside the generic body.
> The workaround is to declare the procedure in the generic
> package spec.  If you don't want to export it, put it in
> the private part.
>
> I think the reason for this rule has something to do with making it
> easier to implement code sharing of generic bodies.

The root reason for the rule is to avoid contract problems with the
accessibility checks. (As it says in the AARM!). Unlike objects,
accessibility checks for subprograms are always done at compile-time. Since
we don't know where the generic will be instantiated, and we never look in
bodies after the template is compiled, we need an assume-the-worst rule for
the check. This is it.

Yes, it makes the implementation easier, but that's not the only (or even
major) motivation. Note that this rule was changed in Ada 2005 (AI-229)
because it still allowed the creation of dangling pointers. In so doing, we
also relaxed it a bit.

                  Randy.







      parent reply	other threads:[~2005-02-17 23:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-15 12:10 pointers and genericity Xavier Serrand
2005-02-15 13:12 ` Dmitry A. Kazakov
2005-02-16  9:27   ` Xavier Serrand
2005-02-16  9:35     ` Martin Dowie
2005-02-16  9:53     ` Egil H. H�vik
2005-02-16 15:00     ` Robert A Duff
2005-02-17 22:50       ` Xavier Serrand
2005-02-17 23:11       ` Randy Brukardt [this message]
replies disabled

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