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: fac41,953e1a6689d791f6 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,953e1a6689d791f6 X-Google-Attributes: gid103376,public From: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: Eiffel and Java + Ada dispatching Date: 1996/11/08 Message-ID: #1/1 X-Deja-AN: 195181202 references: <327F0D64.619A@iam.unibe.ch> organization: The Mitre Corp., Bedford, MA. newsgroups: comp.lang.eiffel,comp.lang.ada Date: 1996-11-08T00:00:00+00:00 List-Id: In article <55p0i3$2u4@tjnews.is.s.u-tokyo.ac.jp> jezequel@piccolo.is.s.u-tokyo.ac.jp (Jean-Marc Jezequel) writes: > Just to change the subject, does anyone know why the designers of > Ada95 did not choose to include the true multiple-dispatch a la > CLOS (or point to a reference on this)? At leat the syntax have > been a problem; whereas it is in Java/C++/Eiffel. It was felt to be too much work for too little gain. With the current rules a programmer can provide a multiply dispatching routine, and it is not that uncommon. But there is a little extra work for the implementor of the operation, but it is linear. (In other words if you have a routine: function Foo(X: Foob; Y: Foob'CLASS) return Boolean; That underneath calls: function Foobar(X: Foob'CLASS; Y: Foob; Additional: Parameters) return Boolean; Then simulating 'true' multiple dispatch may require overriding Foo and Foobar for a new descendent of Foob, not just redefinition of Foo. But the amount of work to be done, assuming you know what you are doing is the same. For example, I created a heterogenous list class, and thought that it would be nice to have the operation: function "&"(X,Y: Object'Class) return List; where X and Y can be of any type descended from Object. The body is REAL easy: function "&"(X,Y: Object'Class) return List is begin return Append(New_List(X),Y); end "&"; Append and New_List are functions that are dispatching and may require overriding, but as you can see, the "&" above dispatches on both parameters, but doesn't require writing N squared operations for N new subclasses. In fact, it will usually be the case that no new operations need to be writen or overridden when a new object type is added to the list. In more complex cases, the programmer may have some work to do to figure out how to keep the implementation burden of adding a new class under control, but in general you simply can't manage the N-squared case and don't want to. (This is not to say that there aren't cases where you want to implement boundary conditions with special values. For example a list type that can contain other lists, but that I have never seen any case where you want the general non-linear complexity.) -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...