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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b1f194b75ae020e4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-03-28 07:44:07 PST Path: nntp.gmd.de!news.rwth-aachen.de!news.rhrz.uni-bonn.de!news.uni-stuttgart.de!rz.uni-karlsruhe.de!xlink.net!howland.reston.ans.net!cs.utexas.edu!news.sprintlink.net!uunet!in1.uu.net!portal.austin.ibm.com!bocanews.bocaraton.ibm.com!watnews.watson.ibm.com!ncohen From: ncohen@watson.ibm.com (Norman H. Cohen) Newsgroups: comp.lang.ada Subject: Re: children Date: 28 Mar 1995 15:44:07 GMT Organization: IBM T.J. Watson Research Center Distribution: world Message-ID: <3l9as8$11km@watnews1.watson.ibm.com> References: <3kv64j$1fhh@info4.rus.uni-stuttgart.de> <3l3kp9$rgv@gnat.cs.nyu.edu> Reply-To: ncohen@watson.ibm.com NNTP-Posting-Host: rios8.watson.ibm.com Date: 1995-03-28T15:44:07+00:00 List-Id: In article <3l3kp9$rgv@gnat.cs.nyu.edu>, dewar@cs.nyu.edu (Robert Dewar) writes: |> We can't do *everything* a CM does in Ada. The question is always how far |> to go. There is therefore no principle involved here, just a matter of |> practicalities and pragmatic convenience. After all if you have no CM at |> all the discussion is silly, since you can always edit the source and |> remove the pragma anyway. Obviously, marking a package as having no children, or marking its private part as off limits to children, does not protect the package against "unauthorized" modification. Obviously the kind of tools that can protect a package against unauthorized modification CAN, IN PRINCIPLE, be extended to protect against unauthorized addition of children. A package marking could serve to bridge the gap between the CM tools that could exist in principle and those that exist in reality--but only after we have bridged the gap between compiler checks that could exist in principle and those that exist in reality! Such marking does serve to inform the reader of the program that all the code having access to the private part is encapsulated in the package body, and thus aids program understanding. However, Tucker and his team took pains--painful pains in the case of the rules for instantiating children of generics--to ensure that all child units having access to the private part of a package P have names beginning P.__; the point of Tuck's recent oblique reference to GNAT users issuing a list-files command was that, if GNAT naming conventions are followed, the command dir P-*.ads lists the declarations of precisely those children. For a compiler based on a traditional program library, an alphabetical listing of compilation units can provide the same information. So marking the parent to provide compiler-checked information to the reader is nice, but there are other ways to obtain the same information. (Purists might argue that encapsulation has been violated, but in fact the "capsule" has just been distributed over several compilation units, as with Ada-83 subunits. Access to the private part of the parent is still confined to a small, clearly identifiable, part of the program.) A no-children marking can serve as a warning to the reader that the inner workings of the package are complex, with many subtle representation invariants, and should not be tampered with casually. Unlike a comment, a compiler-enforced marking commands the attention of the would-be author of a child package, at least for as long as it takes to remove the marking from the parent package. However, since the language offers no comparable protection against casual modification of the parent itself, it is hard to justify such protection against the addition of children. A no-children marking can serve as a statement of ownership and responsibility: By inserting such a marking, the author of a package states that he stands behind the package as delivered. Adding children is tantamount to opening the back cover and voiding the warranty. Of course comments can be used to make the same statement. In short, there are a number of plausible benefits to a no-children marking--and also a number of plausible ways to achieve these benefits without such a marking. [Digression: I heard a story--which may or may not be true but is worth telling anyway--of someone who called the vendor from whom he bought his PC to complain that the hard drive wasn't working correctly. The customer-service rep asked, "Did you check that the connectors weren't loose?" "Yes," responded the customer, proud to demonstrate that he was technically competent and one step ahead of the rep. The rep replied, "Well, if you opened the box, you voided the warranty," and hung up.] -- Norman H. Cohen ncohen@watson.ibm.com