Logtalk reference manual
Built-in method: parameter/2

parameter/2

Description

parameter(Number, Term)

Normally used only in parametric objects, this method returns parameter values by using the parameter position in the object identifier. Note that this predicate implies an instantiation between its second argument and the corresponding implicit context argument in the predicate containing the call. This instantiation occurs at the clause head, not at the clause body. See also this/1.

Template and modes

parameter(+integer, ?term)

Errors

Number is a variable:
instantiation_error
Number is neither a variable nor an integer value:
type_error(integer, Number)
Object identifier is not a compound term:
type_error(compound, Object)
Number is a negative integer value:
domain_error(not_less_than_zero, Number)

Examples

:- object(box(_color, _weight)).

    ...
    
    color(Color) :-              % this clause is translated to a fact upon compilation
        parameter(1, Color).

    heavy :-
        parameter(2, Weight),    % after compilation, the >/2 call will be the first
        Weight > 10.          % condition on the clause body

    ...