Newsgroups: comp.lang.dylan
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!swrinde!gatech!udel!news.mathworks.com!uunet!newsflash.concordia.ca!CC.UMontreal.CA!IRO.UMontreal.CA!saguenay.iro.umontreal.ca!premont
From: premont@IRO.UMontreal.CA (Patrick Premont)
Subject: Re: Message passing vs multi-me
Message-ID: <D3pn7z.JII@IRO.UMontreal.CA>
Sender: news@IRO.UMontreal.CA
Organization: Universite de Montreal
X-Newsreader: TIN [version 1.2 PL2]
References: <n1419894588.66904@qmsmtp.wds.disney.com>
Date: Thu, 9 Feb 1995 02:07:10 GMT
Lines: 26

Ed Cessna (Ed_Cessna@studio.disney.com) wrote:
:         Reply to:   Message passing vs multi-method example?

: Since we're on this subject, does anyone have an example that demonstrates
: the power of multi-methods that would be difficult (or a kludge) to implement
: in a message passing language?

Let's say you want to compute the intersection of two regions of the plane.
These two regions may be rectangular, polygonal, rectangular and upright, ...

You will probably have many algorithms : one for the general case and
others that use all the available infomation about BOTH of the regions
(their specific class) to speed up the computation.

In dylan, this is trivial to setup.

In C++, you'd have to do REGION1.intersect(REGION2). This intersect
method would be defined in each class and would relay the task to
another method by calling REGION2.intersect_2(REGION1). The type of
REGION1 is known staticaly at that point so you use overloading by
defining intersect_2 in every class and for every type of parameter.

If there was no method overloading available, you'd have to add the
type of REGION1 in the name of intersect_2.

Patrick Premont
