From: comar@cs.nyu.edu (Cyrille Comar)
Subject: Re: Overloading for T and T'Class
Date: 18 Nov 1994 23:54:33 -0500
Date: 1994-11-18T23:54:33-05:00 [thread overview]
Message-ID: <3ak0e9$8hp@lang8.cs.nyu.edu> (raw)
In-Reply-To: CzC6Ho.Lqn@swlvx2.msd.ray.com
jgv@swl.msd.ray.com (John Volan) writes:
: However, doing this might cause overload resolution problems when you
: make an invocation:
:
: with P;
: procedure P_Client (X: in out P.T) is
: begin
: ...
: P.Op (X); -- Error in overload resolution -- ambiguous.
: ...
: P.Op (P.T'(X)); -- Although maybe these would work?
: P.Op (P.T'Class'(X));
: ...
: end P_Client;
:
: On the other hand, the following doesn't appear to be ambiguous:
:
: with P;
: procedure Another_P_Client (X: in out P.T'Class) is
: begin
: ...
: P.Op (X); -- No problem, only one way to interpret this
: ...
: end Another_P_Client;
:
: (FYI: GNAT-1.83 seems to like the package spec P, but dies with an
: assertion failure on an attempt to invoke. (Bug report has been
: filed.) Anyway, it would be nice to get some human confirmation on
: this. Tucker, you have the last word: Is this legal?)
Jon,
your analysis is not quite correct, all the calls in your example are ambiguous
even the last one: it can be interpreted either as a dispatching call to the
primitive Op or a simple call to the classwide Op. The latest version of gnat
(to be released shortly :-) does a better job than 1.83 and give the right
diagnostics:
gcc -c -gnatl ess.adb
NYU GNAT Compiler Version 2.0 (C) Copyright NYU, 1992,1993,1994
Compiling: ess.adb 94-11-19 04:45.08
1. procedure ess is
2. package P is
3. type T is tagged null record;
4. procedure Op (X : in out T);
5. procedure Op (X : in out T'Class);
6. end P;
7.
8. package body P is
9. procedure Op (X : in out T) is begin null; end;
10. procedure Op (X : in out T'Class) is begin null; end;
11. end P;
12.
13. procedure P_Client (X: in out P.T) is
14. begin
15. P.Op (X); -- Error in overload resolution -- ambiguous.
|
>>> ambiguous expression (cannot resolve "Op")
>>> possible interpretation at line 5
>>> possible interpretation at line 4
16. P.Op (P.T'(X)); -- Although maybe these would work?
|
>>> ambiguous expression (cannot resolve "Op")
>>> possible interpretation at line 5
>>> possible interpretation at line 4
17. P.Op (P.T'Class'(X));
|
>>> ambiguous expression (cannot resolve "Op")
>>> possible interpretation at line 5
>>> possible interpretation at line 4
18. end P_Client;
19.
20. procedure Another_P_Client (X: in out P.T'Class) is
21. begin
22. P.Op (X);
|
>>> ambiguous expression (cannot resolve "Op")
>>> possible interpretation at line 5
>>> possible interpretation at line 4
23. end Another_P_Client;
24.
25. begin
26. null;
27. end;
--
------------------------------------------------------------------------
Cyrille Comar, E-mail: comar@cs.nyu.edu
Gnat Project US phone: (212) 998-3489
prev parent reply other threads:[~1994-11-19 4:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
1994-11-11 21:33 Overloading for T and T'Class John Volan
1994-11-14 2:07 ` David Weller
1994-11-15 5:01 ` Cyrille Comar
1994-11-15 2:22 ` Bob Duff
1994-11-16 11:33 ` Robert I. Eachus
[not found] ` <3a6goo$j7s@starbase.neosoft.com>
1994-11-15 2:35 ` Tucker Taft
1994-11-15 11:39 ` David Weller
1994-11-16 4:32 ` Brad Balfour
1994-11-16 14:34 ` John Volan
1994-11-15 14:15 ` Norman H. Cohen
1994-11-16 1:22 ` John Volan
1994-11-16 11:59 ` David Weller
1994-11-19 4:54 ` Cyrille Comar [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