If ElemSpec is a compound term, it must specify a visible array element: all its argument must be non negative integers smaller that the bounds specified with make_array/1/2 or make_local_array/1/2.
If Element is a global reference, its value will be restored on backtracking. Otherwise, its value is destructively set to Value; on backtracking the old value is not restored.
If the array has been created with make_array(Array, Type) or make_local_array(Array, Type), then Value is restricted to the type Type; otherwise Value can have any type, including a free variable. Its value can be overwritten any number of time.
% In the following examples, make_array(a(4)) % and make_array(b(4), real) have been called. Success: make_array(a(4,3)), setval(a(0,0), 2), setval(a(1,2), "string"), % overwrite a(0,0) (= 2) with a free variable setval(a(0,0), X). make_array(a(4), real), setval(a(0), 2.0), setval(a(3), -19.6). setval(i, 4). setval(j, 4), setval(j, "string data"). Error: setval(A, 2.0). (Error 4). setval(a(V), 2.0). (Error 4). setval(a(1.0), 2). (Error 5). setval("b(0)", 2.0). (Error 5). make_array(a(4)), setval(a(-2), 2). (Error 6). make_array(a(9), integer) setval(a(9), 4). (Error 6). setval(no_array(1), 2.0). (Error 41).