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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6cd0753a57f9edec,start X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Resolution of Dispatching Operations Date: 1997/02/23 Message-ID: #1/1 X-Deja-AN: 220813549 Content-Type: text/plain; charset=ISO-8859-1 Organization: Estormza Software Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1997-02-23T00:00:00+00:00 List-Id: I have a question about the rules for resolution of (dispatching) operations. I have a type with 2 operations that differ only with respect to whether the arguments are class-wide or specific: procedure Op (L : in T; R : in out T'Class); procedure Op (L : in T'Class; R : in out T); If I'm in a context where I have 2 class-wide objects and I call Op, which version of Op gets called? Like this declare O1, O2 : T'Class; begin Op (O1, O2); end; On my compiler, the first version gets called, but I have no idea why that one would be favored over the other. My expectation is that at some point, either at compile-time or at run-time, I would get an error that says the compiler couldn't figure out which operation I meant. What am I missing? Here is the code: -- STX package P is type T is tagged limited null record; procedure Op (L : in T; R : in out T'Class); procedure Op (L : in T'Class; R : in out T); end; with Ada.Text_IO; use Ada.Text_IO; package body P is procedure Op (L : in T; R : in out T'Class) is begin Put_Line ("Op T, T'Class"); end; procedure Op (L : in T'Class; R : in out T) is begin Put_Line ("Op T'Class, T"); end; end; with P; procedure test_p is procedure Q (L : in P.T'Class; R : in out P.T'Class) is begin P.Op (L, R); end; O1, O2 : P.T; begin Q (P.T'Class (O1), P.T'Class (O2)); end; -- ETX -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271