Module array

This module provides delegates that allow to access and modify Java arrays. Foreign predicates can be registered by one of the directives foreign_dimension/2, foreign_element/2 and foreign_update/2. Foreign evaluable functions can be registered by one of the directives foreign_length/2 or foreign_member/2.

Syntax:
directive --> "foreign_dimension(" indicator "," module ")"
            | "foreign_element(" indicator "," module ")"
            | "foreign_update(" indicator "," module ")"
            | "foreign_length(" indicator "," module ")"
            | "foreign_member(" indicator "," module ")".
Example:
:- foreign_dimension(new/2, int[]).

As a convenience we have defined the postfix operator [] and the path resolution understands this syntax to find Java array classes. When accessing or modifying array elements the delegates will see to it that the values are automatically normalized or de-normalized Prolog terms. The supported data types are the same as in the ordinary foreign function interface.

The following array predicates are provided:

foreign_dimension(I, C):
Succeeds with registering the predicate indicator I as a foreign array constructor for the array class C.
foreign_element(I, C):
Succeeds with registering the predicate indicator I as a foreign array element getter for the array class C.
foreign_update(I, C):
Succeeds with registering the predicate indicator I as a foreign array element setter for the array class C.
foreign_length(I, C):
Succeeds with registering the predicate indicator I as a foreign array length getter for the array class C.
foreign_member(I, C):
Succeeds with registering the predicate indicator I as a foreign array numeric element getter for the array class C.

Kommentare