* Actual subprogram and generic instantiation in same unit
@ 2003-10-27 12:33 Oliver Kellogg
2003-10-27 13:20 ` Duncan Sands
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kellogg @ 2003-10-27 12:33 UTC (permalink / raw)
To my amazement the following compiles:
-- file: inst.ads
with Generic_Package; -- takes a parameterless generic formal procedure P
package Lump is
procedure Manipulate;
package Instantiation is new Generic_Package (P => Manipulate);
end Lump;
Poor compiler has to instantiate a package using a procedure
whose body it has not yet seen...
Is that considered good Ada style?
Are there cases where this lumping together could cause problems?
Thanks,
Oliver M. Kellogg
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Actual subprogram and generic instantiation in same unit
2003-10-27 12:33 Actual subprogram and generic instantiation in same unit Oliver Kellogg
@ 2003-10-27 13:20 ` Duncan Sands
2003-10-30 13:35 ` Oliver Kellogg
0 siblings, 1 reply; 3+ messages in thread
From: Duncan Sands @ 2003-10-27 13:20 UTC (permalink / raw)
To: Oliver Kellogg, comp.lang.ada
On Monday 27 October 2003 13:33, Oliver Kellogg wrote:
> To my amazement the following compiles:
>
> -- file: inst.ads
> with Generic_Package; -- takes a parameterless generic formal procedure P
>
> package Lump is
>
> procedure Manipulate;
>
> package Instantiation is new Generic_Package (P => Manipulate);
>
> end Lump;
>
>
> Poor compiler has to instantiate a package using a procedure
> whose body it has not yet seen...
Why should that be a problem? After all, it has all the information it needs
to generate calls to the procedure.
Duncan.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Actual subprogram and generic instantiation in same unit
2003-10-27 13:20 ` Duncan Sands
@ 2003-10-30 13:35 ` Oliver Kellogg
0 siblings, 0 replies; 3+ messages in thread
From: Oliver Kellogg @ 2003-10-30 13:35 UTC (permalink / raw)
Duncan Sands <baldrick@free.fr> wrote in message news:<mailman.227.1067260813.25614.comp.lang.ada@ada-france.org>...
> >
> > Poor compiler has to instantiate a package using a procedure
> > whose body it has not yet seen...
>
> Why should that be a problem? After all, it has all the information it needs
> to generate calls to the procedure.
>
As a layman, I would assume this is the hard part of implementing
generics in Ada compilers - it's what sets them apart from simple
text substitution robots.
From my personal experience I would still advise against such a
usage; it's a test for the compiler when the scenario gets more
complicated, in particular when the compiler implements generics
with the text expansion approach.
--Oliver
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-10-30 13:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-27 12:33 Actual subprogram and generic instantiation in same unit Oliver Kellogg
2003-10-27 13:20 ` Duncan Sands
2003-10-30 13:35 ` Oliver Kellogg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox