comp.lang.ada
 help / color / mirror / Atom feed
From: Pascal Obry <pascal@obry.net>
To: milouz <a.michelizza@gmail.com>
Subject: Re: using `use' : what is the best practice ?
Date: Tue, 07 Jun 2011 19:33:29 +0200
Date: 2011-06-07T19:33:29+02:00	[thread overview]
Message-ID: <4DEE60E9.2020408@obry.net> (raw)
In-Reply-To: <57e75a35-058c-4172-9a3d-e11e7c5f7697@l2g2000prg.googlegroups.com>

Le 07/06/2011 17:32, milouz a �crit :
> But always avoiding 'use' give some rather obfuscated code, especially
> when using some specific arithmetic operator. For example, playing
> with Address arithmetic without 'use' :

I don't like use so when *I* design a package I prefer to take a 
convention where use is not necessary. But when you want to use an 
already built API you must often use it the way it has been designed to 
be used. Take for example Unbounded_String, nobody will avoid using use 
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;

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;

To

    package Circle is
       type Circle_Type is...

And use it as:

    with Circle; use Circle;

    O : Circle_Type;

But all styles are around...

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B




  parent reply	other threads:[~2011-06-07 17:33 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 [this message]
2011-06-08  2:42   ` Randy Brukardt
2011-06-12  5:09   ` Yannick Duchêne (Hibou57)
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