[ Obsolete | Reference Manual | Alphabetic Index ]

make_local_array(++Array, +Type)

Creates an array or global variable Array of type Type visible only in the context module.
Array
Atom or ground compound term with integer arguments.
Type
Atom, one of float, integer, byte, prolog, global_reference.

This built-in predicate is obsolete!

Description

If Array is an atom, a global variable only visible from the context module is created. The only type allowed for a global variable is prolog or global_reference. However a typed gobal variable can be create with make_local_array(a(1), Type) (accessed a a(0)).

If Array is a compound term, a local array of type Type is created, its dimension is the arity of the term Array and the size of each dimension is specified by the corresponding argument of the term Array. The sizes must be greater than 0, Type must not be global_reference.

The elements of Prolog arrays are initialised depending on the type: float, integer, byte and global_reference arrays are initialised with 0 values, prolog arrays are initialised with free variables.

The array indexes in the array range from 0 to the dimension minus one. For example myarray create with make_local_array(myarray(3,4,5), integer) contains 60 integers that may be accessed from myarray(0,0,0) to myarray(2,3,4).

Global references access the original term with is variables, other array types store a copy of the term.

Modes and Determinism

Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

Exceptions

(4) instantiation fault
Either or both of the arguments are not ground.
(5) type error
Array is not an atom or a compound term with integer arguments.
(5) type error
Type is not an atom.
(6) out of range
The ground compound term Array has arguments that are integers not greater than 0.
(6) out of range
Type is not an atom in the above set.
(42) redefining an existing array
An array with the same name and dimension as Array already exists.

Examples

Success:
      make_local_array(a, prolog).
      make_local_array(a(1), integer).
      make_local_array(a(4), prolog).
      make_local_array(b(2,3), float).
      make_local_array(a(2), float),
          make_local_array(a(3,2), byte).
      make_array(a(2,3), integer),
          make_local_array(a(2,3), integer).

Error:
      make_local_array(a(7), X).                     (Error 4).
      make_local_array(a(6.0), float).               (Error 5).
      make_local_array(a(0), float).                 (Error 6).
      make_local_array(a(2), atom).                  (Error 6).
      make_local_array(a(4), float),
          make_local_array(a(5), byte).              (Error 42).



See Also

array / 2, current_array / 2, getval / 2, make_array / 1, make_array / 2, make_local_array / 1, setval / 2