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,c2f62556e56c9683 X-Google-Attributes: gid103376,public From: Brian Rogoff Subject: Re: 'with'ing and 'use'ing Date: 2000/02/29 Message-ID: #1/1 X-Deja-AN: 591493829 References: <38BC2EB3.2639372B@acm.org> Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: nntp1.ba.best.com 951862628 214 bpr@206.184.139.136 MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-02-29T00:00:00+00:00 List-Id: On Tue, 29 Feb 2000, Jeffrey Carter wrote: > Roger Hoyle wrote: > > > > Hi, > > > > I'm just trying to clear something up in my head. > > > > I'm trying to interface with a lot [a *lot* :] of Ada95 code and the rest > > of the code has a policy of not 'use'ing other packages, just 'with'ing > > them to force the full names of types & functions etc. As a result, I'm > > adopting the same attitude. > > > > 1) Is this basically a good idea? It seems sensible to me, but then I know > > little about Ada. (I'm asking about generally not 'use'ing stuff, not > > specifically my current situation) > > Whether using a package is a good thing depends solely on how easy it is > for someone unfamiliar with the code to read or modify it. Some packages > are designed to be used; see, for example, Ada.Strings.Unbounded. This > package was designed to be used; the type is named Unbounded_String, and > "Unbounded" shows up in many names (Null_Unbounded_String, > To_Unbounded_String). This makes it easy to tell where things came from. > > Other packages are so common that it doesn't affect readability to use > them; examples include Ada.Text_IO and > Ada.Numerics.Elementary_Functions. If you see "Put_Line" or "Sqrt" in > your code it's pretty obvious where they come from. > > Other packages are not designed to be used, or are designed not to be > used. I tend to write data structure packages so that the code has > declarations such as > > Frequency : Frequency_List.Handle; > Pending : Event_Queue.Handle; I use a very similar style when now myself, with the main type exported from a package getting the name "T" and helper types getting names like "Index_T". One of the things that motivated me to try that style was a deliberate attempt to program without use clauses. I use use clauses but I thought it would be a good exercise to try and program without them. > These type names would be ambiguous without the dot notation if you used > both packages, and since they both have "Get" operations, the code can > be difficult to read. You probably shouldn't use these packages. > > Some people (and organizations) have strict "don't use" policies, while > others use pretty much everything. I advocate pragmatism based on ease > of reading and modifying the code. I agree completely with this sentiment, and the rest of the post. Draconian rules like "never use use clauses, goto, exceptions for control flow, ATC, subprogram nesting, etc" seem silly to me. Understand the motivations for the proposed restrictions, and decide for yourself based on the situation. -- Brian