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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!wuarchive!mit-eddie!uw-beaver!uw-june!pattis From: pattis@cs.washington.edu (Richard Pattis) Newsgroups: comp.lang.ada Subject: Re: Unusual "use" semantics Summary: (1) Another way to overload "=" selectively (2) How to USE only infix operators in a package Message-ID: <12744@june.cs.washington.edu> Date: 9 Aug 90 15:59:14 GMT References: <20@polymnia.tsd.arlut.utexas.edu> <12342@hydra.gatech.EDU> <12435@encore.Encore.COM> Distribution: usa Organization: U of Washington, Computer Science, Seattle List-Id: In article <12435@encore.Encore.COM>, mwever@encore (Mike Wever) writes: > i would disagree that "good programing practice prohibits the use of the > "use" use clause". it it my understanding that the use clause was put in > for infix operator such as "=". i would submit to this group that the > addition of the use clause to avoid the ugly case is indeed much cleaner > code then without. the abuse of the use clause has more to do with using it > to avoid dotted notions for objects, functions, procedures, and or types > with are visable from the specs of "withed" packages. > > i spent a year or so looking at a 300K loc system which was written in ada. > it was very hard to understand because of the fact that the use clause was > used to avoid dotted notions. my humble advice is then to only use the use > clause to make directly visable an infix operator, and make all other items > expressly clear by using dotted notation. when i am changing a piece of > code i often comment out the use clause and put in the dotted notions, and > only put it back in if there is an infix operator which should be directly > visable. (1) We can also overload "=" by FUNCTION "=" (L : POSITIVE_COUNT; R : INTEGER) RETURN BOOLEAN RENAMES TEXTIO."="; So we can use this mechanism selectively, to make some subprograms visible without using USE to make all entities in a package visible. (2) When we construct a package that overloads lots of infix operators (say a complex number package) we can place all the operators inside a nested package, and then USE only that nested package (not the outer one). This allows infix notation for all the operators in the nested package, while forcing selected names for all the other entities declared in the package. I came on this idea (no doubt invented many times before) to solve exactly the problem stated above, in a CS-1 book chapter I'm writing. This was my only example of nested packages. Does anyone have any other good examples of nested packges that I could use in my book? Rich Pattis