* Procedure Overloading
@ 2003-07-24 20:49 Justin Schaub
2003-07-25 7:57 ` Dmitry A. Kazakov
0 siblings, 1 reply; 3+ messages in thread
From: Justin Schaub @ 2003-07-24 20:49 UTC (permalink / raw)
Is there a way to specify which overloaded procedure is called in the
following example?
package A
type Access_Integer is access Integer;
procedure compute( Num : access Integer);
procedure compute(Num : Access_Integer);
end A;
procedure Test is
B : Access_Integer;
begin
compute(B);
end Test;
The GNAT compiler allows compilation of the package A, but when compiling
the procedure B it says that there is an ambiguous reference to the
overloaded compute function.
I have heard that you could simply do
compute (Access_Integer'(B));
but that didn't work either. Any ideas? I know it's a silly example but we
are importing the ADA GLU bindings that have a similar issue.
Justin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Procedure Overloading
@ 2003-07-25 5:57 christoph.grein
0 siblings, 0 replies; 3+ messages in thread
From: christoph.grein @ 2003-07-25 5:57 UTC (permalink / raw)
To: comp.lang.ada
Why on earth have the creators of the Ada GLU binding chosen to shoot themselves
into the foot?
I do not see a way to resolve the overloading ambiguity (except of course
changing the declarations :-(.
There are other ways to produce unresolvable ambiguities, e.g.
generic
type T is private;
package G is
procedure P (X: T);
procedure P (X: Boolean);
end G;
with G;
package I is new G (Boolean); -- legal, but I.P is unresovably ambiguous.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Procedure Overloading
2003-07-24 20:49 Justin Schaub
@ 2003-07-25 7:57 ` Dmitry A. Kazakov
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry A. Kazakov @ 2003-07-25 7:57 UTC (permalink / raw)
On Thu, 24 Jul 2003 20:49:45 GMT, "Justin Schaub" <none> wrote:
>Is there a way to specify which overloaded procedure is called in the
>following example?
>
>package A
>
>type Access_Integer is access Integer;
>
>procedure compute( Num : access Integer);
>procedure compute(Num : Access_Integer);
>
>end A;
>
>procedure Test is
> B : Access_Integer;
>begin
> compute(B);
>end Test;
>
>The GNAT compiler allows compilation of the package A, but when compiling
>the procedure B it says that there is an ambiguous reference to the
>overloaded compute function.
>
>I have heard that you could simply do
>
>compute (Access_Integer'(B));
>
>but that didn't work either. Any ideas? I know it's a silly example but we
>are importing the ADA GLU bindings that have a similar issue.
Passing integers by pointers plus clashed types is indeed silly.
You can rename compute:
procedure Test is
procedure compute_with_anonymous (Num : access Integer)
renames A.compute;
procedure compute_with_named (Num : Access_Integer)
renames A.compute;
B : Access_Integer;
begin
compute_with_named (B);
end Test;
---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-07-25 7:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-25 5:57 Procedure Overloading christoph.grein
-- strict thread matches above, loose matches on Subject: below --
2003-07-24 20:49 Justin Schaub
2003-07-25 7:57 ` Dmitry A. Kazakov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox