411 REFERENCE · Wikibooks
Ada Programming/Keywords/use
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Keywords use
__TOC__
Use clause
There are two versions of use clauses, a use_package_clause and a use_type_clause.
At library level
This use_package_clause makes the content of a package directly visible. If applied on the library level, its scope is the complete library unit.
A use clause never hides anything that is already directly visible without it. All use clauses in effect in a certain scope act on the same level: Two homographs in different packages must still be named as selected components.
with Ada Text_IO; use Ada Text_IO;
procedure Hello is
begin
Put_Line("Hello, world!");
New_Line;
Put_Line("I am an Ada program with package use.");
end Hello;
If readability is your main concern then you should avoid this kind of use clause. Either make it more local or use a use_type_clause.
At declaration level
The effect is the same as above, but the scope is the directly enclosing declaration region.
hello_world_3.adb
with Ada Text_IO;
procedure Hello is
use Ada Text_IO;
begin
Put_Line("Hello, world!");
New_Line;
Put_Line("I am an Ada program with package use.");
end Hello;
For types
Use type clauses come in two versions.
use type Type_Name;
makes the operators of the type directly visible.
use all type Type_Name;
makes the primitive operations of the type directly visible.
Representation clauses
The keywords for, use and at are used for representation clauses.
A record representation clause specifies the Layout aspect of a record.
An enumeration representation clause specifies the Coding aspect of an enumeration type.
See Ada Programming/Representation_clauses.
See also
Wikibook
Ada Programming
Ada Programming/Keywords
Ada Reference Manual
2 9 Reserved Words
P (informative) Syntax Summary
8 3 Visibility
8 4 Use Clauses
13 3 Operational and Representation Attributes
13 4 Enumeration Representation Clauses
13 5 1 Record Representation Clauses
Ada Quality and Style Guide
3 1 3 Capitalization
Use
Keywords:use