Section 1.3 - Use Clauses

Some programs might be very wordy if you had to always specify where a procedure is defined in order to use it. Thus, Ada provides the use clause. Whenever you use a procedure (or something else) but do not specify where it is defined, the Ada compiler will search all units listed in applicable use clauses. Use clauses follow the with clause, begin with the keyword use, and then list the library units to be searched. Here's how that first program would look with a use clause:

-- Print a simple message to demonstrate a trivial Ada program.
with Ada.Text_IO;
use Ada.Text_IO;  -- use clause - automatically search Ada.Text_IO.
procedure Hello2 is
 Put_Line("Hello, world!"); -- Note: No longer has "Ada.Text_IO" in front.
end Hello2;


If, in this new version of the program, you changed the second-to-last-line back to:
Ada.Text_IO.Put_Line("Hello, world!");
would the program still work?

  1. Yes
  2. No

You may also:

PREVIOUS Go back to the previous section

NEXT     Skip to the next section

OUTLINE  Go up to lesson 1 outline

David A. Wheeler (

The master copy of this file is at "".