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.5 required=5.0 tests=BAYES_00,INVALID_MSGID, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10a640,9ca80649c409e17e X-Google-Attributes: gid10a640,public X-Google-Thread: 109fba,97482af7429a6a62 X-Google-Attributes: gid109fba,public X-Google-Thread: 1108a1,371d317eff97da58 X-Google-Attributes: gid1108a1,public X-Google-Thread: 103376,97482af7429a6a62 X-Google-Attributes: gid103376,public X-Google-Thread: 10d15b,97482af7429a6a62 X-Google-Attributes: gid10d15b,public From: davis@ilog.fr (Harley Davis) Subject: Re: C++ not OOP? (Was: Language Efficiency Date: 1995/04/19 Message-ID: #1/1 X-Deja-AN: 101106209 sender: news@ilog.fr references: <3mbmd5$s06@icebox.mfltd.co.uk> organization: Ilog SA, Gentilly, France newsgroups: comp.object,comp.lang.c++,comp.lang.ada,comp.lang.cobol,comp.lang.clos Date: 1995-04-19T00:00:00+00:00 List-Id: In article <3n0tk9$149v@watnews1.watson.ibm.com> ncohen@watson.ibm.com (Norman H. Cohen) writes: |> Question: Using single dispatch, how does one code a subroutine to display |> a given shape on a given device? |> |> Answer: Well, you have to pick either the shape object or the device object |> to control dispatch. The methods, then, will contain big cases around the |> type of the other object supplied. For example, each device could act |> differently according to the shape given it (via some ugly case or switch type |> construction), or each shape could act differently according to the device |> given it (via another ugly case or switch type construction). This is obviously a poorly designed solution. The right approach is to come up with an "abstract device" with concrete implementations corresponding to each actual device. The routine to write a given shape on a given device dispatches based on the shape, passing the device object as a parameter. The routine to write a given shape issues calls on the abstract device interface, and these calls dispatch based on the underlying concrete device. This approach is not contradictory with the multiple dispatch approach. Multiple dispatch can enhance your solution. Start with an abstract interface to devices. Write routines for all shapes which use this abstract interface. Then, for speed critical shape/device pairs, write more specific multimethods which use underlying device implementation information for optimization. Indeed, I believe this is the textbook approach to using multimethods. -- Harley Davis -- ------------------------------------------------------------------------------ Harley Davis net: davis@ilog.fr ILOG S.A. tel: +33 1 46 63 66 66 2 Avenue Galli�ni, BP 85 fax: +33 1 46 63 15 82 94253 Gentilly Cedex, France url: http://www.ilog.com/ Ilog Talk information: info@ilog.com