[ ECLiPSe Term Manipulation built-in.|Group Index| Full Index]

insert_suspension(?Term, +Susp, +Index, +Module)

Insert the suspension Susp into the Index'th suspension list of the attribute Module for all metaterms that occur in Term.

?Term
Any Prolog term.
+Susp
A suspension.
+Index
An integer.
+Module
An atom.

Description

This predicate is used to insert a suspension into a suspension list in an attribute of one or more metaterms. Since Prolog does not allow to insert new elements into a list in constant time, ECLiPSe provides this predicate. It finds all metaterms occuring in the term Term and for each of them, it locates the attribute with the name Module. This attribute must be a structure, otherwise an error is raised, which means that the attribute has to be initialised before calling insert_suspension/3. The Index'th argument of the attribute structure is interpreted as a suspension list and the suspension Susp is inserted at the beginning of this list. insert_suspension/3 also recognises suspension lists which are difference lists. If the suspension list is not instantiated, it will be bound to a usual singleton list, i.e. difference lists have to be explicitly initialised as Empty-Empty.

Fail Conditions

None.

Resatisfiable

No.

Exceptions

(4) Instantiation fault
Susp or Index is not instantiated.
(5) Type error
Susp is not a suspension.
(5) Type error
Index is not an integer.
(6) Range error
The attribute of a metaterm in Term is a structure whose arity is less than Index.
(270)
The current module has no declared metaterm attribute.
(271)
The attribute of a metaterm in Term is uninstantiated or it is not a structure.
(271)
The suspension list in the attribute of a metaterm in Term is neither a list, nor a difference list nor free, or it contains an element which is not a suspension.

Examples


[eclipse 1]: meta_attribute(m, print:(=)/2).

yes.
[eclipse 2]: make_suspension(true, 1, S),
        insert_suspension(X{m:f(_)}, S, 1, m).

X = X{f(['GOAL'(true, eclipse)])}
S = 'GOAL'(true, eclipse)

Delayed goals:
true
yes.
[eclipse 5]: make_suspension(true, 1, S),
        insert_suspension(X{m:f(_, E-E)}, S, 1, m),
insert_suspension(X, S, 2, m).

E = E
X = X{f(['GOAL'(true, eclipse)], ['GOAL'(true, eclipse)|_g837] - _g837)}
S = 'GOAL'(true, eclipse)

Delayed goals:
true
yes.


See Also

insert_suspension / 3, make_suspension / 3, meta_attribute / 2