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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,961b968d014d8843 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-01-26 08:43:04 PST Newsgroups: comp.lang.ada Path: pad-thai.cam.ov.com!bloom-beacon.mit.edu!Shiva.COM!world!bobduff From: bobduff@world.std.com (Robert A Duff) Subject: Re: Ada Objects Help! Message-ID: Organization: The World Public Access UNIX, Brookline, MA References: <3f9g1u$j4m@nps.navy.mil> <3fopnh$9k1@gnat.cs.nyu.edu> <1995Jan24.230910.2241@nbivax.nbi.dk> Date: Thu, 26 Jan 1995 16:20:11 GMT Date: 1995-01-26T16:20:11+00:00 List-Id: In article <1995Jan24.230910.2241@nbivax.nbi.dk>, Jacob Sparre Andersen wrote: >I am pretty sure I know how Borland Pascal and C++ decides which virtual >method to call, but as I've understood Ada95, the decision could be based on >more than one object. Am I right? And how is it done? Yes, it is possible for more than one parameter to be "controlling". In that case, there's a run time check that the tags of all controlling parameters are equal. If they are, then that tag determines what subprogram body to dispatch to. It's not like CLOS, which has "multi-methods", which can dispatch based more than one parameter, according to a rather complicated set of rules. By the way, dispatching on result is an interesting twist that most OOP languages don't have: function Union(X, Y: Set) return Set; function Empty_Set return Set; X: Set'Class := ...; Y: Set'Class := Union(X, Empty_Set); The appropriate version of function Empty_Set to call is determined (at run time) based on the tag of Y, since Empty_Set itself doesn't have any controlling parameters. - Bob