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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC 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: donh@syd.csa.com.au (Don Harrison) Subject: Re: Eiffel and Java + Ada dispatching Date: 1996/10/30 Message-ID: #1/1 X-Deja-AN: 193257889 sender: news@syd.csa.com.au x-nntp-posting-host: dev11 references: <5563vp$1of@buggy.news.easynet.net> organization: CSC Australia, Sydney reply-to: donh@syd.csa.com.au newsgroups: comp.lang.eiffel,comp.lang.ada Date: 1996-10-30T00:00:00+00:00 List-Id: Vincent WEBER writes: :In article , donh@syd.csa.com.au says... : :> :>Don't mistake Ada's symmetrical syntax for multiple dispatching (binding :>driven by more than one parameter). Ada is still single dispatched so for :>dispatching operations, the symmetry is syntactic rather than semantic. :> : :Hum... I'm lost, two ada specialists saying two different things :) Sorry, I don't qualify as an Ada specialist (and comp.lang.ada will back me up here). :) However, ... :Let me cote :an article from the french magazine "L'Objet" (Vol 1, no 1, Spring 95), by :Antoine Bertier (Tomson Software Products) and Pascal Plisson (Alsys). I tried :to translate from french to english, please apologize the mistakes if any :) Don't know how the French was, but the English is pretty good. :) :"It is important to note than tags of all the parameters have to be identical :at run-time to have the dispatching done to only one effective operation. Notice he's (you're) saying "only one effective effective operation" (single dispatching). What I didn't mention is that in Ada, control over dispatching can be *shared* by multiple parameters, but for a call to be valid the actual dispatching parameters must have the same type ensuring that binding to a unique procedure occurs. In the example below, type TILABLE_WINDOW is presumably tagged so both parameters A and B jointly control dispatching. However, MAIN_WINDOW and MESSAGE_WINDOW must have the same type; otherwise, an exception is raised). It almost appears that having B as a dispatching parameter is redundant but it conveys the extra information that it must have the same type as A. :Therefore there is no priviliged parameter for dispatching as it is the case in :other languages. This is an important advantage of Ada 95 's model compared to :other languages such as C++, that break the natural symetry of some operations :in privileging the parameter used for the dispatching ( et need a way to :reference this parameter : "this" in C++). For instance : : : type TILABLE_WINDOW is new WINDOW; : TILE(A,B : TILABLE_WINDOW); : -- display the two window one under the other : -- in covering all the screen : MAIN_WINDOW, MESSAGE_WINDOW : TILABLE_WINDOW; : TILE(MAIN_WINDOW, MESSAGE_WINDOW); : -- the call is perfectly symetric. the parameters can be swapped : -- in C++ we would have had a dissymetric call like: : -- MAIN_WINDOW.TILE(MESSAGE_WINDOW); : : " (end of quotation). A symmetrical solution in Eiffel which also conveys the fact that the windows must have the same type might be: class TILABLE_WINDOW is ... class TILABLE_WINDOW_OPS is ... tile (a, b: TILABLE_WINDOW) is require same_type (a, b) do ... end ... end and somewhere: main_window, message_window : TILABLE_WINDOW window_ops: TILABLE_WINDOW_OPS ... window_ops.tile (main_window, message_window) We've had to invent another class to get symmetry. Oh, well at least it's obvious we are using single-dispatching. Don. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Don Harrison donh@syd.csa.com.au