From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: [Revisited] How to get around "access type must not be outside generic unit"
Date: Thu, 25 Jan 2007 12:07:19 +0100
Date: 2007-01-25T12:07:19+01:00 [thread overview]
Message-ID: <b9d60ta46231$.1444vdwg4fxg2$.dlg@40tude.net> (raw)
In-Reply-To: EMOdnZk0RPY-WyrYnZ2dnUVZ_rOqnZ2d@megapath.net
On Wed, 24 Jan 2007 14:50:49 -0600, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> news:1u2mhr9ypij4u.bn3yayn7o9l3$.dlg@40tude.net...
> ...
>>> But in any case, the solution to your problem (as always) is to put the
>>> 'Access into the private part of the specification. Do that with an
>>> appropriate constant declaration. (If the parameter type of Register was
>>> anonymous, there is no problem, so there must be a named type that can be
>>> used.) Doing so will force the generic to be instantiated at the library
>>> level.
>>
>> OK, that's definitely better than Unchecked_Conversion. In Ada 95 it was
>> enough to add a declaration of the subprogram to the specification, now we
>> also need an access object. This is strange, at least not obvious. Why
>> should it change anything?
>
> Because it's part of the contract model.
>
> That is assume-the-best in the
> visible part of the spec, and assume-the-worst in the body. (We're somewhat
> confused about the private part.) Whenever we assume-the-best, there is a
> required recheck in the instance.
>
> Thus, putting such a 'Access in the spec means that it will be rechecked and
> rejected if it causes trouble. In this case, that means that the generic
> will be rejected if it is instantiated in a nested scope.
Hmm, I don't think it is a contract. To be a contract "I want X'Access"
should be in the generic formal part. It is closer to how C++ templates
work. (for "I want X'Access" there even exists a reserved keyword)
But that's no matter.
>> I mean, if it is semantically correct, then why
>> the compiler cannot deduce it? Is it semantically correct? In the case with
>> Glib above, would it be possible to instantiate a generic package in a
>> local scope; call to Boxed_Type_Register_Static passing a constant as you
>> described; and then leave the scope?
>
> No, the instance will be rejected at compile-time as failing an
> accessibility check.
[...]
I see, thank you for explanation.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
prev parent reply other threads:[~2007-01-25 11:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-17 10:07 How to get around "access type must not be outside generic unit" Michael Erdmann
2006-12-17 12:45 ` Pascal Obry
2006-12-17 14:28 ` Michael Erdmann
2006-12-17 15:53 ` Pascal Obry
2006-12-17 20:49 ` Robert A Duff
2006-12-18 3:35 ` Brian May
2006-12-18 7:49 ` Jean-Pierre Rosen
2006-12-18 23:15 ` Brian May
2006-12-19 1:48 ` Randy Brukardt
2006-12-19 7:41 ` Jean-Pierre Rosen
2006-12-18 20:32 ` Michael Erdmann
2006-12-18 20:57 ` Randy Brukardt
2007-01-23 18:18 ` [Revisited] How to get around "access type must not be outside generic unit" (was: How to get around "access type must not be outside generic unit") Dmitry A. Kazakov
2007-01-24 0:57 ` Randy Brukardt
2007-01-24 11:42 ` [Revisited] How to get around "access type must not be outside generic unit" Dmitry A. Kazakov
2007-01-24 11:58 ` Ludovic Brenta
2007-01-24 13:46 ` Dmitry A. Kazakov
2007-01-24 20:50 ` Randy Brukardt
2007-01-25 11:07 ` Dmitry A. Kazakov [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