comp.lang.ada
 help / color / mirror / Atom feed
From: "Michael F. Yoder" <yoder@decada.zko.dec.com>
Subject: Re: Elimination of "use" clauses
Date: 1999/07/08
Date: 1999-07-08T00:00:00+00:00	[thread overview]
Message-ID: <3784DC54.6463EDCA@decada.zko.dec.com> (raw)
In-Reply-To: 7ltl2q$mog$1@nnrp1.deja.com

Ted Dennison wrote:
> 
> In article <7ljbsu$ni7$1@nnrp1.deja.com>,
>   Robert Dewar <robert_dewar@my-deja.com> 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




  parent reply	other threads:[~1999-07-08  0:00 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-01  0:00 Elimination of "use" clauses Dr. Neil C. Audsley
1999-07-01  0:00 ` czgrr
1999-07-01  0:00   ` Ted Dennison
1999-07-02  0:00     ` czgrr
1999-07-02  0:00       ` Ted Dennison
1999-07-01  0:00 ` Samuel T. Harris
1999-07-01  0:00 ` Joe Wisniewski
1999-07-02  0:00 ` Robert Dewar
1999-07-02  0:00   ` Ed Falis
1999-07-03  0:00     ` Joe Wisniewski
1999-07-03  0:00       ` Keith Thompson
1999-07-03  0:00       ` Ed Falis
1999-07-13  0:00     ` Peter Amey
1999-07-02  0:00   ` Ted Dennison
1999-07-02  0:00     ` Ed Falis
1999-07-02  0:00     ` Stephen Leake
1999-07-02  0:00     ` Robert Dewar
     [not found]       ` <7ltus1$ah1@dfw-ixnews19.ix.netcom.com>
1999-07-13  0:00         ` Robert A Duff
1999-07-18  0:00           ` Richard D Riehle
1999-07-18  0:00             ` Dale Stanbrough
1999-07-20  0:00               ` David Kristola
1999-07-20  0:00               ` Richard D Riehle
1999-07-19  0:00                 ` Brian Rogoff
1999-07-20  0:00                   ` Robert Dewar
1999-07-20  0:00                     ` Brian Rogoff
1999-07-21  0:00                       ` Robert Dewar
1999-07-21  0:00                         ` Brian Rogoff
1999-07-22  0:00                           ` Robert Dewar
1999-07-22  0:00                             ` Brian Rogoff
1999-07-22  0:00                           ` Robert Dewar
1999-07-22  0:00                             ` Brian Rogoff
1999-07-21  0:00                       ` Ted Dennison
1999-07-21  0:00                         ` Robert A Duff
1999-07-21  0:00                         ` Robert Dewar
1999-07-21  0:00                     ` Robert A Duff
1999-07-21  0:00                       ` Michael F. Yoder
1999-07-21  0:00                         ` Robert A Duff
1999-07-23  0:00                 ` Tucker Taft
1999-08-03  0:00                   ` Richard D Riehle
1999-07-18  0:00             ` jerry
1999-07-19  0:00               ` Vladimir Olensky
1999-07-20  0:00               ` Richard D Riehle
1999-07-20  0:00                 ` jerry
1999-07-20  0:00                 ` Opaque Types (was Elimination of "use" clauses) David C. Hoos, Sr.
1999-07-19  0:00             ` Elimination of "use" clauses Ted Dennison
1999-07-19  0:00               ` Tucker Taft
1999-07-19  0:00                 ` Ted Dennison
1999-07-02  0:00   ` Samuel T. Harris
1999-07-02  0:00     ` Robert Dewar
1999-07-08  0:00       ` R. Tim Coslet
1999-07-09  0:00         ` Robert Dewar
1999-07-09  0:00           ` tmoran
     [not found]       ` <7ltl2q$mog$1@nnrp1.deja.com>
1999-07-08  0:00         ` Michael F. Yoder [this message]
1999-07-09  0:00           ` Richard D Riehle
1999-07-09  0:00             ` Michael F. Yoder
1999-07-09  0:00             ` Marin David Condic
1999-07-09  0:00           ` Robert Dewar
1999-07-09  0:00             ` Dale Stanbrough
1999-07-12  0:00               ` Robert Dewar
1999-07-12  0:00                 ` Ted Dennison
1999-07-09  0:00             ` Michael F. Yoder
1999-07-14  0:00               ` Tucker Taft
1999-07-10  0:00             ` Simon Wright
1999-07-12  0:00               ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox