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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,efe03f20164a417b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-03-19 19:23:18 PST Newsgroups: comp.lang.ada Path: nntp.gmd.de!stern.fokus.gmd.de!ceres.fokus.gmd.de!zib-berlin.de!news.mathworks.com!news.kei.com!bloom-beacon.mit.edu!news.bu.edu!inmet!news From: "S. Tucker Taft" Subject: Re: An observation of Ada (may offend) Message-ID: Sender: news@inmet.camb.inmet.com Organization: Intermetrics, Inc. References: <3kbkm1$41o@miranda.gmrc.gecm.com> <3kcflv$164a@watnews1.watson.ibm.com> Date: Mon, 20 Mar 1995 03:23:18 GMT Date: 1995-03-20T03:23:18+00:00 List-Id: ncohen@watson.ibm.com (Norman H. Cohen) wrote: > > In article <3kbkm1$41o@miranda.gmrc.gecm.com>, bill@valiant.gmrc.gecm.com > (R.A.L Williams) writes: >... > |> h. And a special one for Ada95: poor encapsulation of objects. I can > |> define a 'member function' for a class by including the class in the > |> parameter list. Unlike C++ or Eiffel, I can do this *anywhere* in my code, > |> even a nested function hidden somewhere seemingly 'irrelevant'. Whereas > |> other features of Ada go out of their way to force the programmer to > |> follow 'good practice' (sometimes a matter of opinion), this seems > |> very lax. > ... > > If there is a weakness in Ada encapsulation, it has nothing to do with > parameter lists, but with the definition of "logically within the > defining unit". Anyone can write a child package that is "logically > within the defining unit". (Do-While Jones once called this the "Howard > Hughes effect": strangers claiming to be your heirs.) Child units enjoy > access analogous to that permitted for C++ protected members in a > subclass of a definining class. Thus the strongest degree of hiding that > Ada can provide is that of C++ "protected", not C++ "private". By putting a declaration in a nested package private part, or in the package body, you achieve hiding as effective as C++ "private." When introducing Ada 95 to C++ programmers, I generally explain that Ada has three levels of visibility control, analagous to the three in C++ -- the visible part of a package (visible to all), the private part of the package (visible to children), and the package body (visible to the package body itself only). Most C++ programmers are a bit jealous of the ability to define in Ada 95 additional local subprograms in a package body without having to disturb the spec. In C++, you have to edit the class spec to add private member functions (or play games with "friends"). > Norman H. Cohen ncohen@watson.ibm.com -Tucker Taft stt@inmet.com Intermetrics, Inc.