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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e5eb8ca5dcea2827 X-Google-Attributes: gid103376,public From: Hyman Rosen Subject: Re: Ada OO Mechanism Date: 1999/05/25 Message-ID: #1/1 X-Deja-AN: 482017206 Sender: hymie@calumny.jyacc.com References: <7i05aq$rgl$1@news.orbitworld.net> <7i17gj$1u1k@news2.newsguy.com> <7iems7$1vm@news2.newsguy.com> X-Complaints-To: abuse@panix.com X-Trace: news.panix.com 927661061 19911 209.49.126.226 (25 May 1999 19:37:41 GMT) Organization: PANIX Public Access Internet and UNIX, NYC NNTP-Posting-Date: 25 May 1999 19:37:41 GMT Newsgroups: comp.lang.ada Date: 1999-05-25T19:37:41+00:00 List-Id: Samuel Mize writes: > THE QUESTION: how does one do "mix-in" classes in C++? I'd bet a > nickel that you can, but I don't know the specific mechanism. The > "mix-in" metaphor is described in the Ada 95 Rationale, 4.6.2. I believe this Ada -- generic type S is abstract tagged private; package P is type T is abstract new S with private; -- operations on T private type T is abstract new S with record -- additional components end record; end P; corrsponds to this C++ -- template class P { public: class T : public S { private: // additional components } }; and given some type A, one could declare objects of type P::T. These objects are derived from A and also implement the extra operations of T. I haven't bothered to duplicate the 'abstract', but that's easily done by giving T an abstract destructor, ~T() = 0. > - The class is the primary form of data encapsulation. Classes support static data and function members, and nested classes. I believe that this gives C++ the equivalent of Ada's packages. > - Each "message" (implemented as a dispatching function call) goes > to exactly one object (or class). Any other objects mentioned are > passive arguments. How is this different from Ada? Does Ada allow dispatching on more than one argument? > - When an object sends a message, it waits for the called object > to complete its processing of the message (that is, for the return > of the function call) before continuing. > - One thread of control calls all objects; they are not independent > active entities. Well, no argument there. C++ does not have a language-defined parallel processing capability, and Ada is absolutely superior in that regard. However, I would say that this is generally considered orthogonal to object-oriented programming, since your statement above is equally true if you replace objects and messages with plain function calls. > I'm sure one could create, in C++ ... > But each of these would be working against the object-oriented model > built into the language. Instead, C++ programmers generally use third-party or system packages which allow parallel processing. These have no impact upon the OO model at all, and certainly don't forbid anything you might normally do. You do have to be careful about protecting shared resources, but that's true in Ada as well. I think including parallel behavior in your definition of OO is stretching that definition beyond any accepted usage. > I'm not saying that C++ is "lesser," "worse" or "wrong," I'm just saying > that it takes a different, but equally valid, design approach. The > same is true for Ada. To quote you, > There are other OO design approaches that are harder to implement in > C++ than in Ada, because C++ strongly supports one specific view of > object-oriented technology. See? You said there are OO approaches that are harder to implement in C++ than in Ada. If you're talking about implementing parallel processing, fine, I agree. Otherwise, I would like to see an example, so that I can determine whether that's really true, or whether it comes from an incomplete understanding of C++.