37.5.3 Parameter Passing to New Objects

When new objects are created, it is possible to pass parameters. The following example shows:

In the previous examples one could pass parameters to an object as follows, using the method augment/1.

     | ?- vehicle :: augment({
             new_attrs(Instance, Attribute_list) :-
                     self :: new(Instance),
                     :: assign_list(Attribute_list, Instance) &
     
             assign_list([], Instance) &
             assign_list([Att|List], Instance) :-
                     :: assign(Att, Instance),
                     :: assign_list(List, Instance) &
     
             assign(P, Instance) :-
                     Instance :: assert(P) 
             }).
     
     % create a new 'truck'
     | ?- vehicle :: new_attrs(truck, [capacity([]),total_weight([])]).