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,152a2caafe08bc4b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-27 07:19:45 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.mathworks.com!wn3feed!worldnet.att.net!135.173.83.71!wnfilter1!worldnet-localpost!bgtnsc04-news.ops.worldnet.att.net.POSTED!not-for-mail Message-ID: <3C7CF8EF.7030907@worldnet.att.net> From: Jim Rogers User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1 X-Accept-Language: en-us MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: scope and visibility References: <3C7C59CE.7040104@users.sf.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 27 Feb 2002 15:19:44 GMT NNTP-Posting-Host: 12.86.34.9 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1014823184 12.86.34.9 (Wed, 27 Feb 2002 15:19:44 GMT) NNTP-Posting-Date: Wed, 27 Feb 2002 15:19:44 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:20517 Date: 2002-02-27T15:19:44+00:00 List-Id: Dave Poirier wrote: > I understand the difference between 'with' and 'use', that's no problem, > but I'm having quite a hard time with 'private' and friends. Is there > any tutorial detailing from side-to-side how those work for ada-newbies? When you use the term "friends" I assume you are looking at Ada from a C++ point of view. Technically, Ada does not have "friends". Ada does have a hierarchical package structure which allows much of the visibility you expect from "friends". Ada "private" declarations are closest to C++ and Java "protected" declarations. Any item declared first in a package body is closest to a C++ or Java "private" declaration. A child package has direct visibility to its parent package in the following manner: The public part of the child package has visibility to the public part of the parent package. The private part of the child package has visibility to the public and private parts of the parent package. The child package has NO visibility to the items declared in the parent's package body. One difference between Ada hierarchical packages and C++ friends is that the Ada parent package does not need to be modified to allow access from the child. In C++ a class must declare its friends. In real programming this often causes the C++ developer to modify the "parent" class to allow friendship. Such modifications can be expensive in a maintenance environment where several products already depend on the compilation unit containing the "parent" class. In Ada, the parent package is never modified to allow a child class. This simplifies maintenance issues by not requiring a change to released compilation units. Jim Rogers