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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC 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: Marin David Condic Subject: Re: Elimination of "use" clauses Date: 1999/07/09 Message-ID: <3785F03D.3F5B3B44@pwfl.com>#1/1 X-Deja-AN: 499081682 Content-Transfer-Encoding: 7bit Sender: condicma@bogon.pwfl.com 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> <3784DC54.6463EDCA@decada.zko.dec.com> <7m3foq$nuj@dfw-ixnews14.ix.netcom.com> Content-Type: text/plain; charset=us-ascii Organization: Pratt & Whitney Mime-Version: 1.0 Reply-To: diespammer@pwfl.com Newsgroups: comp.lang.ada Date: 1999-07-09T00:00:00+00:00 List-Id: Richard D Riehle wrote: > > Ada permits us to remove the insulation at appropriate places. We would > never expect a consumer to go around scraping insulation from electrical > wires in the home. We should not expect clients of packages to do the > same. Instead, we should carefully expose, in our package design, those > places where entities can safely connect with each other. This is a key > difference between engineering and programming. > I think I can agree that package designers can/should help make decisions about what should be directly visible, via some version of the _Ops package, but don't you think that a lot of visibility issues are going to depend on the caller? I mean, when I buy a 100 feet of wire at The Home Depot, I expect the *default* to be that it is insulated so that I don't string it through my attic and produce hazards where I least expect it. But with a trusty pair of wire dykes I expect to strip & connect where my application demands. I personally like to limit the "use" clause to the smallest scope possible - If I'm using Ada.Strings.Unbounded somewhere in a package, I may use explicit dotted notation on the parameters of the subprograms, but within the subprogram itself, apply the "use" clause to eliminate the clutter. The caller of my package then knows where to find the data types for the parameters, but within the package we kind of assume that someone will recognize "Move" and "To_String" as being operations from A.S.U. But it was *my* decision about what is clear and what may be obfuscated within the context of my application. > The use clause, when invoked willy-nilly, exposes too much of the > bare wire. The use type is not much better, but one can see its > usefulness in teaching environments. At the same time, excessive > paranoia over the use clause is usually unwarranted. > I think it tends to be a tempest in a teapot. In practice, I think clarity is more a result of the talent of the programmer rather than the language features. Someone who thinks, speaks and writes clearly is likely to produce code that communicates its intentions clearly with or without the use clause. I think the advantage of the use clause is more one of protecting the namespace than one of clarity/obfuscation. If the given caller has no ambiguities or collisions with the names of the withed package, the use clause is probably not going to hurt the clarity much. If there are collisions, then avoid the use clause. (Except for infix operators! There's nothing uglier than seeing 'My_Package."<" (L, R)' ;-) In general, eschew obfuscation. :-) MDC -- Marin David Condic Real Time & Embedded Systems, Propulsion Systems Analysis United Technologies, Pratt & Whitney, Large Military Engines M/S 731-95, P.O.B. 109600, West Palm Beach, FL, 33410-9600 ***To reply, remove "bogon" from the domain name.*** Visit my web page at: http://www.mcondic.com/