3 Foreign Function Interface

It is possible to call functions written in other programming languages, and also to access variables and constants, using the following form of formal hole:

nest language_indicant "row char denotation"

Where language_indicant is a bold word indicating the programming language we are communicating with and the row char denotation specifies the entity we are accessing. The interpretation of the later depends on the specific language.

The formal hole construction is an unit, and can only appear in a strong context. It’s mode is the mode expected by the strong context. For example, in the following declaration:

int counter = nest C "_counter";

The mode of the formal hole is int, since it is in a strong context (the actual parameter of an identity declaration) in which an integral value is expected. Likewise, in:

proc long int func = nest C "random";

The expected mode is a procedure that gets no arguments and returns a long int.

The set of modes that are accepted in the formal holes depend on the specific language we are communicating to. These are usually restricted because the compiler may not know how to translate certain Algol 68 concepts into the foreign language ones. A compile time error is issued if an invalid mode is required. Specifics are described in the sections below.

It is important to note that the language-indicants like C or Fortran are still available to be used as mode indicants, operators or module indicants: they only qualify as language indicants when they appear in a formal hole (nest) construct.

The following subsections document the specific supported foreign languages.