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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,961b968d014d8843 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-01-22 10:30:21 PST Newsgroups: comp.lang.ada Path: nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!udel!news.mathworks.com!noc.near.net!inmet!henning!stt From: stt@henning.camb.inmet.com (Tucker Taft) Subject: Re: Ada Objects Help! Message-ID: Sender: news@inmet.camb.inmet.com Organization: Intermetrics, Inc. References: <3f9g1u$j4m@nps.navy.mil> <1995Jan16.132400@lglsun.epfl.ch> <131279@cup.portal.com> <3fopnh$9k1@gnat.cs.nyu.edu> Date: Sun, 22 Jan 1995 18:30:21 GMT Date: 1995-01-22T18:30:21+00:00 List-Id: In article <3fopnh$9k1@gnat.cs.nyu.edu>, Robert Dewar wrote: >"How can Ada be object oriented if you always have to pass the data to the >function?" > >I have a clearer version of this question > >"How can Ada be object oriented if the second and third characters of its > name are not special characters?" > >:-) As Robert is implying, object-oriented languages differ in both significant and insignificant ways. Clearly you need to identify the object which is the "target" when invoking an operation. In C++ and Smalltalk, this object is identified in a "prefix" of the invocation of the operation. In Ada 95 and CLOS (Common Lisp Object System), this object is identified as one of the parameters of the invocation of the operation. It turns out that the Ada 95/CLOS approach is somewhat more powerful, in that you can syntactically transform the C++/Smalltalk "prefix" notation into the Ada 95/CLOS "parameter" notation, but not necessarily vice-versa. Both Ada 95 and CLOS allow multiple "objects" controlling the dispatch, making binary operations simpler and more symmetrical. Ada 95 is unique in allowing the result context to control the run-time dispatch. CLOS is more general in that a best-fit pattern match is performed at run-time to decide which implementation to invoke (roughly analogous to the best-fit compile-time overload resolution algorithm that C++ performs), while Ada 95 requires a "perfect" match (allowing a simple single-level-of-indirection to perform the dispatch). So when you see "object->operation(other params)" in C++ or "object op other-params" in Smalltalk, you can imagine this as "operation(object, other params)" in Ada 95 (or "(operation object other-params)" in CLOS). When implementing an operation in Ada 95, the implicit "this" parameter in C++ becomes a normal "formal" parameter in Ada, with a name picked by the programmer (the programmer could chose "This" if desired). Although there are some semantic implications of this choice of prefix vs. parameter notations, by and large it is a syntactic choice. -Tucker Taft stt@inmet.com Intermetrics, Inc.