Ada Programming/Keywords/use
Use clause
[edit | edit source]There are two versions of use clauses, a use_package_clause and a use_type_clause.
At library level
[edit | edit source]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
Hellois
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
[edit | edit source]The effect is the same as above, but the scope is the directly enclosing declaration region.
with
Ada.Text_IO;procedure
Hellois
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
[edit | edit source]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
[edit | edit source]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
[edit | edit source]Wikibook
[edit | edit source]Ada Reference Manual
[edit | edit source]- 8.3: Visibility [Annotated]
- 8.4: Use Clauses [Annotated]
- 13.3: Operational and Representation Attributes [Annotated]
- 13.4: Enumeration Representation Clauses [Annotated]
- 13.5.1: Record Representation Clauses [Annotated]
Ada Quality and Style Guide
[edit | edit source]
Ada Keywords | ||||
---|---|---|---|---|
abort
|
else
|
new
|
return
|
|
abs
|
elsif
|
not
|
reverse
|
|
abstract (Ada 95)
|
end
|
null
|
||
accept
|
entry
|
select
|
||
access
|
exception
|
of
|
separate
|
|
aliased (Ada 95)
|
exit
|
or
|
some (Ada 2012)
|
|
all
|
others
|
subtype
|
||
and
|
for
|
out
|
synchronized (Ada 2005)
|
|
array
|
function
|
overriding (Ada 2005)
|
||
at
|
tagged (Ada 95)
|
|||
generic
|
package
|
task
|
||
begin
|
goto
|
parallel (Ada 2022)
|
terminate
|
|
body
|
pragma
|
then
|
||
if
|
private
|
type
|
||
case
|
in
|
procedure
|
||
constant
|
interface (Ada 2005)
|
protected (Ada 95)
|
until (Ada 95)
|
|
is
|
use
|
|||
declare
|
raise
|
|||
delay
|
limited
|
range
|
when
|
|
delta
|
loop
|
record
|
while
|
|
digits
|
rem
|
with
|
||
do
|
mod
|
renames
|
||
requeue (Ada 95)
|
xor
|