comp.lang.ada
 help / color / mirror / Atom feed
From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: using `use' : what is the best practice ?
Date: Sun, 12 Jun 2011 07:09:35 +0200
Date: 2011-06-12T07:09:35+02:00	[thread overview]
Message-ID: <op.vwx5x9r9ule2fv@douda-yannick> (raw)
In-Reply-To: 4DEE60E9.2020408@obry.net

Le Tue, 07 Jun 2011 19:33:29 +0200, Pascal Obry <pascal@obry.net> a é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 branch  
via a single short name. By the way, subprogram renaming is an option too  
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 Instance  
may also be an option to have in mind along with the name Object (Instance  
may be more neutral, depending on one's feeling)

-- 
“Syntactic sugar causes cancer of the semi-colons.”  [Epigrams on  
Programming — Alan J. — P. Yale University]
“Structured Programming supports the law of the excluded muddle.” [Idem]
“c++; /* this makes c bigger but returns the old value */” [Anonymous]



  parent reply	other threads:[~2011-06-12  5:09 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-07 15:32 using `use' : what is the best practice ? milouz
2011-06-07 15:59 ` Simon Wright
2011-06-07 16:22 ` Dmitry A. Kazakov
2011-06-07 16:59   ` Simon Wright
2011-06-07 17:25     ` Dmitry A. Kazakov
2011-06-07 17:29       ` Simon Wright
2011-06-07 19:38         ` Dmitry A. Kazakov
2011-06-11 14:11           ` Yannick Duchêne (Hibou57)
2011-06-08  9:07       ` Paul Colin Gloster
2011-06-08 11:20         ` stefan-lucks
2011-06-08 16:45           ` Vinzent Hoefler
2011-06-11 14:05       ` Yannick Duchêne (Hibou57)
2011-06-07 17:33 ` Pascal Obry
2011-06-08  2:42   ` Randy Brukardt
2011-06-12  5:09   ` Yannick Duchêne (Hibou57) [this message]
2011-06-07 18:51 ` Jeffrey Carter
2011-06-08  0:04   ` Peter C. Chapin
2011-06-07 19:32 ` Anders Wirzenius
2011-06-07 23:38 ` Shark8
2011-06-12  5:19   ` Yannick Duchêne (Hibou57)
2011-06-12  7:55   ` Stephen Leake
2011-06-08  4:25 ` Jerry
2011-06-08  9:31   ` milouz
2011-06-08 17:17     ` Ludovic Brenta
2011-06-08 18:43     ` Jeffrey Carter
2011-06-09 10:40       ` Address arithmetic alternatives milouz
2011-06-09 11:25         ` Georg Bauhaus
2011-06-09 18:53         ` Jeffrey Carter
2011-06-08 19:22     ` using `use' : what is the best practice ? Pascal Obry
2011-06-09  1:17     ` Shark8
2011-06-09 10:44       ` milouz
2011-06-08  6:06 ` stefan-lucks
2011-06-15  2:25 ` Adrian Hoe
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox