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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham 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,UTF8 Path: g2news1.google.com!news3.google.com!feeder.news-service.com!feeder.news-service.com!94.75.214.39.MISMATCH!aioe.org!.POSTED!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: using `use' : what is the best practice ? Date: Sun, 12 Jun 2011 07:09:35 +0200 Organization: Ada @ Home Message-ID: References: <57e75a35-058c-4172-9a3d-e11e7c5f7697@l2g2000prg.googlegroups.com> <4DEE60E9.2020408@obry.net> NNTP-Posting-Host: f5R0gSm2zBSnDCiIl1SGIw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/11.11 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: g2news1.google.com comp.lang.ada:19762 Date: 2011-06-12T07:09:35+02:00 List-Id: Le Tue, 07 Jun 2011 19:33:29 +0200, Pascal Obry a =C3=A9= crit: > in this case... Look at this code: > > with Ada.Strings.Unbounded; > procedure Whatever is > S : Ada.Strings.Unbounded.Unbounded_String; > begin > Ada.Strings.Unbounded.Append (S, "toto"); > end Whatever; > > Far better with: > > with Ada.Strings.Unbounded; > procedure Whatever is > use Ada.Strings.Unbounded; > S : Unbounded_String; > begin > Append (S, "toto"); > end Whatever; You could also use package renaming, to access the leaf of a whole branc= h = via a single short name. By the way, subprogram renaming is an option to= o = in some cases (when a subprogram's invocation is very often encountered = in = some package body). > Because Ada.Strings.Unbounded (and all Ada runtime packages) has been = = > designed to be used with a use clause. > > Now I do prefer: > > package Circle is > type Object is... > > And use it as: > > with Circle; > > O : Circle.Object; Good convention indeed. To talk about concrete matters, the name Instanc= e = may also be an option to have in mind along with the name Object (Instan= ce = may be more neutral, depending on one's feeling) -- = =E2=80=9CSyntactic sugar causes cancer of the semi-colons.=E2=80=9D [Ep= igrams on = Programming =E2=80=94 Alan J. =E2=80=94 P. Yale University] =E2=80=9CStructured Programming supports the law of the excluded muddle.= =E2=80=9D [Idem] =E2=80=9Cc++; /* this makes c bigger but returns the old value */=E2=80=9D= [Anonymous]