This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/Logtalk/examples/diamonds/diamond1.mlgt
pmoura 921e576877 Logtalk 2.21.0 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1138 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2004-09-14 23:11:12 +00:00

58 lines
1.0 KiB
Plaintext

/*
These metafile objects illustrate a variant of the "diamond problem" using
a prototype hierarchy.
In this simple case, the inherited definition which will be used in the
bottom object is determined by the Logtalk predicate lookup algorithm.
*/
% root object, declaring and defining a predicate m/0:
:- object(a1).
:- public(m/0).
m :-
this(This),
write('Default definition of method m/0 in object '),
write(This), nl.
:- end_object.
% an object descending from the root object, which redefines predicate m/0:
:- object(b1,
extends(a1)).
m :-
this(This),
write('Redefinition of method m/0 in object '),
write(This), nl.
:- end_object.
% another object descending from the root object, which also redefines predicate m/0:
:- object(c1,
extends(a1)).
m :-
this(This),
write('Redefinition of method m/0 in object '),
write(This), nl.
:- end_object.
% bottom object, descending from the two previous objects and, as such, inheriting
% two definitions for the predicate m/0:
:- object(d1,
extends(b1, c1)).
:- end_object.