Contents   Index   Search   Previous   Next


B.2 The Package Interfaces

1
   Package Interfaces is the parent of several library packages that declare types and other entities useful for interfacing to foreign languages. It also contains some implementation-defined types that are useful across more than one language (in particular for interfacing to assembly language).
1.a
Implementation defined: The contents of the visible part of package Interfaces and its language-defined descendants.

Static Semantics

2
   The library package Interfaces has the following skeletal declaration:
3

package Interfaces is
   pragma Pure(Interfaces);
4
   type Integer_n is range -2**(n-1) .. 2**(n-1) - 1;  --2's complement
5
   type Unsigned_n is mod 2**n;
6
   function Shift_Left  (Value : Unsigned_n; Amount : Natural)
      return Unsigned_n;
   function Shift_Right (Value : Unsigned_n; Amount : Natural)
      return Unsigned_n;
   function Shift_Right_Arithmetic (Value : Unsigned_n; Amount : Natural)
      return Unsigned_n;
   function Rotate_Left  (Value : Unsigned_n; Amount : Natural)
      return Unsigned_n;
   function Rotate_Right (Value : Unsigned_n; Amount : Natural)
      return Unsigned_n;
   ...
end Interfaces;

Implementation Requirements

7
   An implementation shall provide the following declarations in the visible part of package Interfaces:
8
8.a
Ramification: For example, for a typical 32-bit machine the corresponding types might be Integer_8, Unsigned_8, Integer_16, Unsigned_16, Integer_32, and Unsigned_32.
8.b
The wording above implies, for example, that Integer_16'Size = Unsigned_16'Size = 16. Unchecked conversions between same-Sized types will work as expected.
9
9.a
Reason: We considered making shifting and rotating be primitive operations of all modular types. However, it is a design principle of Ada that all predefined operations should be operators (not functions named by identifiers). (Note that an early version of Ada had "abs" as an identifier, but it was changed to a reserved word operator before standardization of Ada 83.) This is important because the implicit declarations would hide non-overloadable declarations with the same name, whereas operators are always overloadable. Therefore, we would have had to make shift and rotate into reserved words, which would have been upward incompatible, or else invent new operator symbols, which seemed like too much mechanism.
10
10.a
Implementation Note: The names for these floating point types are not specified. {IEEE floating point arithmetic} However, if IEEE arithmetic is supported, then the names should be IEEE_Float_32 and IEEE_Float_64 for single and double precision, respectively.

Implementation Permissions

11
    An implementation may provide implementation-defined library units that are children of Interfaces, and may add declarations to the visible part of Interfaces in addition to the ones defined above.
11.a
Implementation defined: Implementation-defined children of package Interfaces. The contents of the visible part of package Interfaces.

Implementation Advice

12
    For each implementation-defined convention identifier, there should be a child package of package Interfaces with the corresponding name. This package should contain any declarations that would be useful for interfacing to the language (implementation) represented by the convention. Any declarations useful for interfacing to any language on the given hardware architecture should be provided directly in Interfaces.
12.a
Ramification: For example, package Interfaces.XYZ_Pascal might contain declarations of types that match the data types provided by the XYZ implementation of Pascal, so that it will be more convenient to pass parameters to a subprogram whose convention is XYZ_Pascal.
13
    An implementation supporting an interface to C, COBOL, or Fortran should provide the corresponding package or packages described in the following clauses.
13.a
Implementation Note: The intention is that an implementation might support several implementations of the foreign language: Interfaces.This_Fortran and Interfaces.That_Fortran might both exist. The ``default'' implementation, overridable by the user, should be declared as a renaming:
13.b
package Interfaces.Fortran renames Interfaces.This_Fortran;

Contents   Index   Search   Previous   Next   Legal