To be able to send or delegate messages to the super-objects in a convenient
way while following the inheritance protocol, the keyword super
is
provided. The calls:
super :: method, or super <: method
mean: send or delegate (respectively) method to the super-objects
according to the inheritance protocol. A simple example illustrates this
concept: assume that john
in the above example has three id-cards, one
stored in his sportsman prototype identifying the club he is member of, one
stored in his professor prototype identifying the university he works in, and
finally one stored locally identifying his social-security number. Given the
following methods in the object john
:
m1(X) :- super <: id_card(X) & m2(X) :- super(S), S <: id_card(X) &
one may ask the following:
| ?- john :: m1(X). % will follow the default inheritance and returns: X = johns_club ; | ?- john :: m2(X). % will backtrack through the possible supers returning: X = johns_club ; X = johns_university ;