prologcategorieslogtalk

Accessing Parametric object from category


how to Access Parametric object from a ategory

:- category(attributes).

    :- public(info/1).
    info(Value) :- arg(1,_Array_,Value).

:- end_category.

:- object(array(_Array_),imports([attributes])).

this does not work ...

 *     Singleton variable: _Array_

Solution

  • As entity parameters are logical variables, simply share them between the object and the category:

    :- category(attributes(_Array_)).
    
        :- public(info/1).
        info(Value) :-
            arg(1, _Array_, Value).
    
    :- end_category.
    
    
    :- object(array(_Array_),
        imports(attributes(_Array_))).
    
    :- end_object.