From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9cfa83146b0781ed X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-11-18 20:54:33 PST Path: nntp.gmd.de!xlink.net!howland.reston.ans.net!pipex!uunet!panix!cmcl2!thecourier.cims.nyu.edu!thecourier.cims.nyu.edu!nobody From: comar@cs.nyu.edu (Cyrille Comar) Newsgroups: comp.lang.ada Subject: Re: Overloading for T and T'Class Date: 18 Nov 1994 23:54:33 -0500 Organization: Courant Institute of Mathematical Sciences Message-ID: <3ak0e9$8hp@lang8.cs.nyu.edu> References: NNTP-Posting-Host: lang8.cs.nyu.edu Date: 1994-11-18T23:54:33-05:00 List-Id: 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