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, MSGID_RANDY 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: Robert Dewar Subject: Re: Elimination of "use" clauses Date: 1999/07/09 Message-ID: <7m3k72$t6m$1@nnrp1.deja.com>#1/1 X-Deja-AN: 498905779 References: <377B5807.88B875E0@cs.york.ac.uk> <7lh74s$v36$1@nnrp1.deja.com> <377CE178.6C15F543@hso.link.com> <7ljbsu$ni7$1@nnrp1.deja.com> <3784F737.A04F466D@kaisere.com> X-Http-Proxy: 1.0 x23.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Fri Jul 09 01:45:09 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-07-09T00:00:00+00:00 List-Id: In article <3784F737.A04F466D@kaisere.com>, "R. Tim Coslet" 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.