comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Ada95 tutorials with sample code.
Date: Tue, 6 Mar 2001 04:38:24 -0600
Date: 2001-03-06T04:38:24-06:00	[thread overview]
Message-ID: <5l3p6.160282$Ch.32975101@newsrump.sjc.telocity.net> (raw)
In-Reply-To: 3AA48DE9.A0650F21@emw.ericsson.se

The "use" clause was desirable in limited circumstances in
Ada83. My personal rule was to use a "use" clause only
to make infix operators visible -- i.i. to avoid having to
write A := My_Package."+"(B, C);
instead of the more readable A := B + C;

With Ada95, even this is not necessary, since one can use
the "use type" clause.

In either Ada83 or Ada95, the use of a renames clause to
abbreviate log names is useful, as you have done in your
example.

The Ada95 Quality and Style Guide (available from
http://www.adaic.org/AdaIC/docs/style-guide/95style/zip/)
has this to say about the "use" clause:

Chapter 5: Programming Practices - TOC - 5.7 VISIBILITY
5.7.1 The Use Clause
guideline
When you need to provide visibility to operators, use the use type clause.
Avoid/minimize the use of the use clause (Nissen and Wallis 1984).
Consider using a package renames clause rather than a use clause for a
package.
Consider using the use clause in the following situations:
- When standard packages are needed and no ambiguous references are
introduced
- When references to enumeration literals are needed
Localize the effect of all use clauses.

"Sven Nilsson" <emwsvni@emw.ericsson.se> wrote in message
news:3AA48DE9.A0650F21@emw.ericsson.se...
> I'm sorry if I disrupt this thread with a slightly off-topic question
> (which I'm sure has been discussed countless times before) BUT
>
> This use-thingy. Is it really ant good? I've only ever used Ada in HUGE
> projects with loads of people writing the code and I've found that the
> use-clause can be a real pain as it dosn't give you a clue as to where
> things are declared. Right now I'm teaching new arrivals about Ada 95
> and I invariably tell them NOT to use the use-clause.
> Now, there're a lot of very clever and skilled people reading this
> news-group and I'd be interested in your feelings on "use". Is it a Do
> or Don't? Generally speaking?
>
> My Hello World would probably look something like this:
>
> -- "Hello, World"
>
> with Ada.Text_IO;
>
> procedure Hello_World is
> package Tio renames Ada.Text_IO; -- Rename common packages so I don't
> have to
>                                  -- type in the whole thing every time I
> use it
> begin
>    Tio.Put_Line("Howdy, World!"); -- Use Tio to access Ada.Text_IO
> end Hello_World;
>
> > -- "Hello, World!" program in Ada
> >
> > with Ada.Text_IO;
> >
> > use Ada.Text_IO;
> > procedure Hello_World is
> >    -- null;
> > begin -- Hello_World
> >    Put_Line (Item => "Hello, World!");
> > end Hello_World;
> >
>
> -Sven




  parent reply	other threads:[~2001-03-06 10:38 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-05 20:40 Ada95 tutorials with sample code mcdoobie
2001-03-05 20:58 ` Erik Sigra
2001-03-06  2:45 ` Jeffrey Carter
2001-03-06  7:12   ` Sven Nilsson
2001-03-06  8:09     ` tmoran
2001-03-06 10:38     ` David C. Hoos, Sr. [this message]
2001-03-06 15:06       ` Ted Dennison
2001-03-06 10:38     ` David C. Hoos, Sr.
2001-03-06 15:29     ` Robert A Duff
2001-03-06 16:54       ` Ted Dennison
2001-03-06 15:48     ` Ted Dennison
2001-03-06 18:19       ` Robert A Duff
2001-03-06 21:19         ` Ted Dennison
2001-03-08  6:13         ` Simon Wright
2001-03-10 16:30           ` Brian Rogoff
2001-03-06 18:20     ` Jean-Pierre Rosen
2001-03-06 20:10       ` Erik Sigra
2001-03-07 14:31         ` Simon Pilgrim
2001-03-06 21:47       ` Ted Dennison
2001-03-07  0:11     ` Robert C. Leif, Ph.D.
2001-03-07  6:44     ` Jeffrey Carter
2001-03-07  6:46     ` use-clause Anders Wirzenius
2001-03-07 18:13       ` use-clause Jean-Pierre Rosen
2001-03-07  7:54     ` Ada95 tutorials with sample code Sven Nilsson
2001-03-07 15:10       ` Marin David Condic
2001-03-08  0:05       ` Mark Lundquist
2001-03-06 15:03   ` Marin David Condic
2001-03-06 14:31 ` BSCrawford
2001-03-06 22:38   ` mcdoobie
  -- strict thread matches above, loose matches on Subject: below --
2001-03-06 23:51 Beard, Frank
2001-03-06 23:58 Beard, Frank
     [not found] <01030621102401.00302@a77>
2001-03-07 12:09 ` Mario Amado Alves
     [not found] <Pine.LNX.4.10.10103071153320.971-100000@lexis.di.fct.unl.pt>
2001-03-07 13:12 ` Erik Sigra
2001-03-07 18:07   ` Jean-Pierre Rosen
replies disabled

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