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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3dbf2f325f33ce35 X-Google-Attributes: gid103376,public From: "Michael F. Yoder" Subject: Re: Elimination of "use" clauses Date: 1999/07/08 Message-ID: <3784DC54.6463EDCA@decada.zko.dec.com>#1/1 X-Deja-AN: 498836114 Content-Transfer-Encoding: 7bit References: <377B5807.88B875E0@cs.york.ac.uk> <7lh74s$v36$1@nnrp1.deja.com> <377CE178.6C15F543@hso.link.com> <7ljbsu$ni7$1@nnrp1.deja.com> <7ltl2q$mog$1@nnrp1.deja.com> Organization: Compaq Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-07-08T00:00:00+00:00 List-Id: Ted Dennison wrote: > > In article <7ljbsu$ni7$1@nnrp1.deja.com>, > Robert Dewar wrote: > > > and that is by NO means the worst case. Well if you are really > > usephobic, or worse, live in an environment which mandates that > > use be disallowed (I have encountered such absurdities), then > > you end up doing a package renaming: > > > > X := NFR.Random (Gen); > > Interesting strawman. But the enviroments I have worked in tend to > highly discourage "renames" as well. So instead you are "stuck" using > full dot notation. Not a strawman. The best ways of dealing with use clauses are what I call "Tony Tye" methods (since he devised the first one I used) and make package renamings a staple. The basis of these methods is to have a simple package renaming, at the top of a unit, for every "withed" package; this renaming provides an abbreviated name for that package within the unit. If you like acronyms you might use ASU for Ada.Strings.Unbounded and ASWU for Ada.Strings.Wide_Unbounded. I'd more likely use, e.g., Unb and WUnb. It is helpful but not necessary to keep these abbreviations consistent across units. Most (or all) identifiers denoting entities in the "withed" packages are then prefixed by an abbreviated name and a dot. A strict "Tony Tye" method would forbid 'use' and 'use type' clauses entirely. A loose one would allow all 'use type' clauses, and also allow 'use' for all predefined packages and at most one non-predefined package. The point to the "at most one" rule is that it enables you to (usually) know at a glance where any identifier is declared: if X isn't from any surrounding scope, and you know the predefined packages well enough to tell X isn't from one of them, it must be in the single special used package. My personal preference is to be fairly free about 'use type' (but to drive it into the narrowest scope possible) and to otherwise lean towards no use clauses at all. I'll admit I sometimes allow myself two used packages if one is Ada.Text_IO. This is better than using fancy tools because even if the tool use is as simple as double-clicking on the identifier, that's more distracting than having the information immediately evident. It requires no conscious thought or finger movement to realize that 'Unb.Insert' comes from the unbounded strings package. "Use-phobia" of this sort usually aids code reading, whether the code is hardcopy or not. ---- Michael Yoder