comp.lang.ada
 help / color / mirror / Atom feed
From: Samuel Tardieu <sam@rfc1149.net>
Subject: Re: Subprogram Pointer in a Generic
Date: Thu, 17 Apr 2003 03:12:55 +0000 (UTC)
Date: 2003-04-17T03:12:55+00:00	[thread overview]
Message-ID: <slrnb9s6tn.hvi.sam@willow.dyn.rfc1149.net> (raw)
In-Reply-To: 1ftiuys.1twhum2q9qa00N%claveman@grzorgenplatz.net

Charles H. Sampson wrote:

>      There are two questions.  (1) What are they trying to prevent by
> this restriction?  (2) Is there a more robust way of working around it?

(1) The absence of such a rule would prevent an implementation from
    implementing efficiently shared generic packages: if, from
    within the body, you take a reference to a local subprogram,
    you do not statically know the accessibility "depth", as the
    generic package may be instantiated locally (from within a
    subprogram for example).  Note that building the access value
    from outside the generic package then storing it is subject to
    the classical static accessibility rules and thus does not
    require this restriction.

However, I must admit that I do not understand why it is not
sufficient for the access to subprogram type to be declared in the
corresponding generic declaration, as both accessibility levels can
be statically compared when compiling the generic package body.

Should this restriction be alleviated in Ada 2005?

(2) If you *know* that you can safely use such a reference, use
    your (non portable) compiler-provided attribute ('Unrestricted_Access
    for GNAT) to create the access value. Another solution would
    be to export the subprogram if not done already and build the
    access value from outside.

  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/sam



  parent reply	other threads:[~2003-04-17  3:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-17  1:53 Subprogram Pointer in a Generic Charles H. Sampson
2003-04-17  2:54 ` James S. Rogers
2003-04-17  3:15   ` Samuel Tardieu
2003-04-17  5:27     ` tmoran
2003-04-17  3:12 ` Samuel Tardieu [this message]
2003-04-17  4:17   ` tmoran
2003-04-17 20:24     ` Robert A Duff
2003-04-18  2:59   ` Charles H. Sampson
2003-04-22 16:34   ` Warren W. Gay VE3WWG
2003-04-22 21:17     ` Robert A Duff
2003-04-23 20:46       ` Warren W. Gay VE3WWG
2003-04-17 19:41 ` Matthew Heaney
2003-04-17 20:39 ` Robert A Duff
2003-04-17 23:14   ` Randy Brukardt
replies disabled

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