3.1. With: Context Clause - JulTob/Ada GitHub Wiki

The With … line is a context clause. They specify the packages that will be used. The context, or conditions where the program is executed and the contract complied.

They provide services to the current package.

In this case we will be using facilities in the child package Ada.Text_IO. The standard library components are in child packages of the package Ada. In this case we will be using facilities in the child package Ada.Text_IO

You can call a clause into scope declaring it’s use, changing the code as follows:


with Ada.Text_IO;    --Input Output Standard Library

procedure Hello is
   use Ada.Text_IO;
   begin 
   Ada.Text_IO.Put_Line(“Hello, Ada!”);
   end Hello;

This makes the library directly visible. With dot notation you can shortcut a name as follows:


with Ada.Text_IO;    --Input Output Standard Library

procedure Hello is
   package IO renames Ada.Text_IO;
begin 
   IO.Put_Line(“Hello, Ada!”);
end Hello;

Other valid uses

with Ada.Text_IO;
procedure Hola is
   begin
   Ada.Text_IO.Put_Line ("Hola");
   end Hola;
with Ada.Text_IO; use Ada.Text_IO;
procedure Hola is
begin
   Put_Line ("Hola");
end Hola;

La palabra reservada private with establece una restricción al alcance de una cláusula with. La restricción private significa que las librerías enumeradas en la cláusula with no son accesibles en la parte pública de la unidad de compilación a la que afecta la cláusula with. La restricción limited se usa para permitir dependencias mutuas.

private with Ada.Strings.Unbounded;

Use

La palabra reservada use se utiliza para construir una cláusula de uso. Una cláusula de uso de paquete hace visibles las declaraciones que aparecen en la parte pública de un paquete.

use Text_IO;
use Ada.Strings, Ada.Strings.Fixed;
with Ada.Text_IO; use Ada.Text_IO;
procedure Hola is
   begin
   Put_Line ("Hola");
   end Hola;
with Ada.Text_IO; 
   procedure Hola is
   use Ada.Text_IO;
   begin
     Put_Line ("Hola");
     end Hola;