comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-deja.com>
Subject: Re: Elimination of "use" clauses
Date: 1999/07/09
Date: 1999-07-09T00:00:00+00:00	[thread overview]
Message-ID: <7m3k72$t6m$1@nnrp1.deja.com> (raw)
In-Reply-To: 3784F737.A04F466D@kaisere.com

In article <3784F737.A04F466D@kaisere.com>,
  "R. Tim Coslet" <coslett@kaisere.com> wrote:
> Our coding standard USED to prohibit all use of "renames"
> (except for operators) for just the reason you give below:
> renaming packages to get short dot notation form simply
> obscures the code.

A nice example of crippling the language in the name of
controlling style! Renames is an absolutely critical feature
of the language. It is important for abstraction purposes, and
provides essential expressive power not at all easily replaced
by any other means.

For example if we have

    X : integer renames a(i,j).x1(k);

it is really horrible to do

    Capture_I : constant integer := i;
    Capture_J : constant integer := j;
    Capture_K : constant integer := k;

and then replace subsequent uses of X by

    A (Capture_I, Capture_J).x1(Capture_K);

And of course I am assuming A and x1 are declared objects and
not pointers, or things get even more ludicrous.

> They did finally loosen up on "renames" after seeing how a
> rename of an array reference or list reference inside a loop
> or subprogram works (and usually clues in the compiler to only
> do the index calculation ONCE instead of on every reference).

A decent compiler should do this automatically in almost all
cases without the need for renames, but in any case this is a
lousy reason for modifying the standards (ok, we will write
what we think is kludgy code because our compiler generates
better code if we do).

The proper reason for loosening up on this rule is that there
is no point in removing critical features of the language
without very good reason. Worrying about misuse in package
namings is not a "very good reason".

Almost all rules on Ada style that prohibit the use of a feature
entirely are misguided. I say almost all, because there are
definite examples, which are not so much style rules, as usage
rules, e.g. don't use dynamic allocation in safety critical
programs. They typically correspond to the use of pragma
Restrictions.

Going back to the use clause case,
if you prohibit use completely, and do not allow package
renamings, then you provoke another common disease, short
cryptic package names.

And please note that all this gets *MUCH* worse with child
packages in Ada 95. No doubt some brilliant manager will
prohibit the use of child packages because it leads to unwieldy
names :-)

> Of course one has to realize that our entire coding standard
> was developed when our "environment" consisted of nothing but
> VAX LSE, an Ada83 compiler, and CCC. It is in review for
> potentially significant changes.

It is definitely reasonable to take environment and tools into
effect when designing coding standards. The package renaming
for example is not unreasonable if you really are confined to
reading all code on paper.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




  reply	other threads:[~1999-07-09  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 ` Joe Wisniewski
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-02  0:00 ` Robert Dewar
1999-07-02  0:00   ` Samuel T. Harris
1999-07-02  0:00     ` Robert Dewar
     [not found]       ` <7ltl2q$mog$1@nnrp1.deja.com>
1999-07-08  0:00         ` Michael F. Yoder
1999-07-09  0:00           ` Robert Dewar
1999-07-09  0:00             ` Michael F. Yoder
1999-07-14  0:00               ` Tucker Taft
1999-07-09  0:00             ` Dale Stanbrough
1999-07-12  0:00               ` Robert Dewar
1999-07-12  0:00                 ` Ted Dennison
1999-07-10  0:00             ` Simon Wright
1999-07-12  0:00               ` Robert Dewar
1999-07-09  0:00           ` Richard D Riehle
1999-07-09  0:00             ` Marin David Condic
1999-07-09  0:00             ` Michael F. Yoder
1999-07-08  0:00       ` R. Tim Coslet
1999-07-09  0:00         ` Robert Dewar [this message]
1999-07-09  0:00           ` tmoran
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             ` 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-18  0:00             ` Elimination of "use" clauses Dale Stanbrough
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                       ` Ted Dennison
1999-07-21  0:00                         ` Robert Dewar
1999-07-21  0:00                         ` Robert A Duff
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                     ` 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-20  0:00               ` David Kristola
1999-07-19  0:00             ` Ted Dennison
1999-07-19  0:00               ` Tucker Taft
1999-07-19  0:00                 ` Ted Dennison
1999-07-02  0:00   ` Ed Falis
1999-07-03  0:00     ` Joe Wisniewski
1999-07-03  0:00       ` Ed Falis
1999-07-03  0:00       ` Keith Thompson
1999-07-13  0:00     ` Peter Amey
replies disabled

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