comp.lang.ada
 help / color / mirror / Atom feed
From: news.cnri.reston.va.us!newsserver.jvnc.net!louie!balin.cis.udel.edu!carro ll@uunet.uu.net  (Mark C. Carroll)
Subject: Re: OO Preprocessor for Ada
Date: 19 Jul 93 14:32:30 GMT	[thread overview]
Message-ID: <1993Jul19.143230.18648@udel.edu> (raw)

In article <15JUL199315464091@cl2.cl.uh.edu> RILEY@cl.uh.edu writes:
>Thanks for the suggestions, but I still have a couple of questions:
>
>In article <CA7zB0.LuI@inmet.camb.inmet.com>, stt@spock.camb.inmet.com (Tucker
 Taft) writes..
>>>>Here are some possible look and feel issues:
>>>> 
>>>>  1) Prefix notation  
>>>>      i.e. blah.operation(params) instead of operation(blah,params)
>> 
>>However, this breaks down for binary operators.  One nice
>>feature of CLOS and Ada 9X, is that binary operators are handled
>>symmetrically, without any need for non-inheritable "friends."
>
>How does Smalltalk handle binary operators?
>I don't think it involves "friends".

Smalltalk uses a trick called multiple dispatch.

The idea is, you dispatch on the first parameter, which calls a method
which selects one of a group of available methods, and dispatches
one of those on the second parameter.

Bad explanation. Let me use an example:
  	a + b

What this does is send the message "+" with the argument "b" to the
object "a". Now, none of the types are known statically, so the compiler
cannot select the correct method for adding an object of type "TypeOfA" to
an object for type "TypeOfB". But "a" does know it's own type. So it
dispatches again, using that information: the method "+" for object
"a" dispatches again, and does:

	b addATypeA: a

So you've dispatched twice: once on the type of A (in the method "+")
and once on the type of b (in the method "addATypeA").

It's rather kludgy, but it does do what you need. But I think that
multimethod binding (which if I'm reading things correctly Ada9x does)
is prefereable.

	<MC>
-- 
|| Mark Craig Carroll: <MC>     ||"I live to see my fondest dreams realized,
|| CIS Grad, Univ of Delaware   || Of living under the sights and sounds of
|| PGP key available by finger  || the gifted, Who gave so much to me"
|| carroll@udel.edu             ||   - _Feed_the_Fire_, Happy Rhodes

             reply	other threads:[~1993-07-19 14:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-07-19 14:32 news.cnri.reston.va.us!newsserver.jvnc.net!louie!balin.cis.udel.edu!carro [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-08-19 19:03 OO Preprocessor for Ada cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!vixen.cso.u
1993-08-19 10:36 Graham Matthews
1993-08-18 22:30 agate!spool.mu.edu!sol.ctr.columbia.edu!emory!europa.eng.gtefsd.com!darwi
1993-08-18 20:31 cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!vixen.cso.u
1993-08-18 19:22 cis.ohio-state.edu!math.ohio-state.edu!darwin.sura.net!source.asset.com!c
1993-07-21 14:41 David Emery
1993-07-16 15:58 Robert I. Eachus
1993-07-15 14:46 Tucker Taft
1993-07-15 13:02 dog.ee.lbl.gov!overload.lbl.gov!agate!howland.reston.ans.net!math.ohio-st
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox