root/trunk/examples/diamonds/NOTES.txt

Revision 4662, 2.1 KB (checked in by pmoura, 6 days ago)

Updated copyright notice.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1================================================================
2Logtalk - Open source object-oriented logic programming language
3Release 2.35.0
4
5Copyright (c) 1998-2009 Paulo Moura.        All Rights Reserved.
6Logtalk is free software.  You can redistribute it and/or modify
7it under the terms of the "Artistic License 2.0" as published by
8The Perl Foundation. Consult the "LICENSE.txt" file for details.
9================================================================
10
11
12To load this example and for sample queries, please see the SCRIPT
13file.
14
15This example illustrates some variants of the "diamond problem"
16(multi-inheritance conflicts and ambiguities) and its respective
17solutions on Logtalk.
18
19This classical problem can be simply described by constructing a
20"diamond" of objects and inheritance links as follows:
21
22        A       -- contains default definition for a predicate m/0
23      /   \
24    B       C   -- contains redefinitions of the predicate m/0
25      \   /
26        D       -- inherits both redefinitions of the predicate m/0
27
28As such, the object D inherits two conflicting definitions for the
29predicate m/0, one from object B and one from object C. If we send
30the message m/0 to object D, is ambiguous which inherited definition
31should be used to answer it. Depending on the nature of the objects
32A, B, C, and D, the correct answer can be the redefinition of m/0 in
33object B, the redefinition m/0 in object C, or both redefinitions.
34A programming language supporting multi-inheritance should provide
35programming mechanisms allowing easy implementation of each possible
36solution.
37
38Note that, in the context of Logtalk, the diamond problem may occur with
39prototype hierarchies, class hierarchies, protocol hierarchies, or when
40using category composition.
41
42This example deals with three variants of the diamond problem, illustrated
43using prototype hierarchies:
44
45    diamond1
46        illustrates the inherited definition which is visible due to the
47        Logtalk predicate lookup algorithm
48    diamond2
49        presents a solution for making the overridden inherited definition
50        the visible one
51    diamond3
52        presents a solution which allows both inherited definitions to be
53        used in D
Note: See TracBrowser for help on using the browser.