From: Shark8 <onewingedshark@gmail.com>
Subject: Re: no, it can't be, there's no "with procedure instance_of_generic_procedure is new generic_procedure;" ? Impossible !
Date: Mon, 9 Apr 2018 16:43:31 -0700 (PDT)
Date: 2018-04-09T16:43:31-07:00 [thread overview]
Message-ID: <0a981aae-2429-4195-a7aa-ee5e6da05110@googlegroups.com> (raw)
In-Reply-To: <pace35$hbe$1@gioia.aioe.org>
On Sunday, April 8, 2018 at 12:50:15 AM UTC-6, J-P. Rosen wrote:
> Le 08/04/2018 à 02:32, Mehdi Saada a écrit :
> > I just realized one can't do that:
> >
> > generic
> > with procedure instance_of_generic_procedure is new generic_procedure;
> > ...
> Of course - because it would be useless. The only thing you know from
> the specification of a generic subprogram is its profile, and you can
> import any procedure with an appropriate profile. While restrict to
> those that are in addition an instantiation of a given generic?
The idea behind my proposal for automatic/default instantiation was addressing this, as well as allowing the formal parameters to direct the implicit instantiation.
GENERIC
TYPE Parameter_Type IS (<>);
PROCEDURE Generic_Swap( A, B : Parameter_Type );
PROCEDURE Generic_Swap( A, B : Parameter_Type ) IS
C : Constant Parameter_Type:= A;
BEGIN
A:= B;
B:= C;
END Generic_Swap;
GENERIC
TYPE Something IS (<>);
USE PROCEDURE Swap IS NEW Generic_Swap( Parameter_Type => Something );
PACKAGE Example IS
--...
END Example;
Which would allow a more uniform syntax, which is what this seems to be about, as well as allow Example.Swap to be implicitly instantiated the instantiation of Example.
> You have been mistaken by the case of packages. While it is easy to
> define the matching of subprograms, the matching of packages would be
> almost impossible to define - unless the package in an instantiation of
> a generic, in which case it obviously matches the generic.
>
> When Ada95 was designed, there was a demand for passing packages the
> same way as subprograms (already present in Ada83). It appeared that
> this was possible only for packages that were built from the same
> generic. There is no such problem with subprograms.
There was an extension in the iAPX 432 of "Package Types" that have an interesting correlation to this demand, IMO -- if you want to kno more, here's the manual: http://bitsavers.informatik.uni-stuttgart.de/components/intel/iAPX_432/172283-001_Reference_Manual_for_the_Intel_432_Extensions_to_Ada_Dec81.pdf
next prev parent reply other threads:[~2018-04-09 23:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-08 0:32 no, it can't be, there's no "with procedure instance_of_generic_procedure is new generic_procedure;" ? Impossible ! Mehdi Saada
2018-04-08 6:50 ` J-P. Rosen
2018-04-09 23:43 ` Shark8 [this message]
2018-04-08 11:15 ` Mehdi Saada
2018-04-08 11:46 ` Jere
2018-04-08 13:47 ` Mehdi Saada
2018-04-12 8:56 ` Marius Amado-Alves
2018-04-12 10:14 ` Mehdi Saada
2018-04-13 0:37 ` Shark8
2018-04-13 12:34 ` Mehdi Saada
2018-04-13 15:57 ` Mehdi Saada
2018-04-13 23:59 ` Randy Brukardt
2018-04-14 0:00 ` Randy Brukardt
2018-04-14 6:00 ` Mehdi Saada
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox