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.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a8985ede8fe3d111 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-10-27 03:19:45 PST Newsgroups: comp.lang.ada Path: bga.com!news.sprintlink.net!howland.reston.ans.net!news.moneng.mei.com!uwm.edu!lll-winken.llnl.gov!enews.sgi.com!wdl1!mail!cps248!biggar From: biggar@lds.loral.com (Mark Biggar, 5172) Subject: Re: Child packages Message-ID: <1994Oct21.140246.8554@lds.loral.com> Sender: news@lds.loral.com Reply-To: biggar@lds.loral.com Organization: LORAL Data Systems References: Date: Fri, 21 Oct 1994 14:02:46 GMT Date: 1994-10-21T14:02:46+00:00 List-Id: In article D8I@inmet.camb.inmet.com, bobduff@dsd.camb.inmet.com (Bob Duff) writes: > Note also that the distinction between public and private has never been > perfect in Ada. If you see (in the visible part of a package): > > Message: constant String := "File not found."; > > You can't be sure exactly what information is being exported. > Is the package promising that this string will always be 15 characters > long, and/or contain exactly those characters? Or is it merely > promising that the thing is called Message, and it's of type String. > If somebody wants to change the message to be more informative, will > that break existing clients? We don't know for sure. > > Now, you may say that one ought to have made it a function, so changing > the message would only require a change to the body. Well, perhaps, but > that interface promises less to the client in one respect -- the client > can be sure that a reference to Message above will not have side > effects, and will always produce the same value. Using a function > doesn't make any such promise. Furthermore, it's more verbose (by a > factor of 5, if you're counting lines of code), so a lot of people will > choose the constant-declaration way. I'd say that if you put the above declaration in the visible part of your package spec then you are pretty well promising that the string won't change in the future and that users can depend on it always being 15 characters long and containing exactly those characters. But if you had instead written (in Ada9x, but unfortunataly not in Ada83): ... Message: constant String: private Message: constant String := "File Not Found."; ... Then all you are promising is that it is a constant string and you should fell free to change it anytime you want and if a user writes code that, for example, depends on the string being 15 characters long, then you can reasonably claim that they are cheating and making use of a property that you didn't want exported. Actually, if I was attending a walkthough of a users code and they had used anything other then Message'Length in either case I would red flag it. I know that the above are just personal conventions, but isn't this one of the major reasons why 9x allows deferred constants of any type not just private types, and besides users of a package arn't suppose to peek into private parts anyway, are they? -- Mark Biggar mab@wdl.loral.com