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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ab3fadb7cac7363c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!25g2000yqn.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: using `use' : what is the best practice ? Date: Tue, 7 Jun 2011 16:38:53 -0700 (PDT) Organization: http://groups.google.com Message-ID: <03a8fa21-b515-41ea-bc65-b6ab85b0e88c@25g2000yqn.googlegroups.com> References: <57e75a35-058c-4172-9a3d-e11e7c5f7697@l2g2000prg.googlegroups.com> NNTP-Posting-Host: 24.230.151.194 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1307489934 12604 127.0.0.1 (7 Jun 2011 23:38:54 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 7 Jun 2011 23:38:54 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 25g2000yqn.googlegroups.com; posting-host=24.230.151.194; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:19689 Date: 2011-06-07T16:38:53-07:00 List-Id: On Jun 7, 10:32=A0am, milouz wrote: > Hi guys, > Sorry with my annoying questions, but it's not easy to program in Ada > after 20 years programming in asm / C ;-) > > Maybe a not so anecdotic question : when using the 'use' clause ? > > My first thought is that using 'use' is not good because it masks the > package tree. While this is true it can be handy for reducing prefix-clutter, as could a rename. So, while you may be hesitant to use them on the package, I find using them in declare-blocks and subprograms to be quite readable and usable. With Ada.Text_IO; Package Body Example is [...] Procedure Something_Interesting is Use Ada.Text_IO; -- We're debugging here. begin [...] Put_Line( "Debugging marker." ); [...] end Something_interesting; End Example; > For example, if I have 2 packages with procedures sharing the same > name, example `P1.Foo' and `P2.Foo', my code won't be very readable if > I only write the short name (`Foo') : > > =A0 =A0with P1; use P1; > =A0 =A0with P2; use P2; [...] > As I'm very new, I'd like to have your opinion about the way to use > 'use'. Ah, I like to use the comma-separated forms of use/with; this can be helpful if you wish to do a quick commenting out of a use or with to pass to the compiler and see if you really need it at all. EX: With Ada.Text_IO, --Ada.Integer_IO, -- Am I even using Ada.Integer_IO? --Ada.Tags, --MY_PARSING_PACKAGE, [...] MY_CONSOLE_MANIPULATION_PACKAGE ; Use Ada.Text_IO, --Ada.Tags, -- Do I really need to USE tags? MY_CONSOLE_MANIPULATION_PACKAGE;