Logtalk 2.26.2 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1487 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
71
Logtalk/examples/inheritance/classes.lgt
Normal file
71
Logtalk/examples/inheritance/classes.lgt
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
This source file defines the following class-based hierarchy:
|
||||
|
||||
root
|
||||
subclass1
|
||||
instance1
|
||||
subclass2
|
||||
instance2
|
||||
subclass3
|
||||
instance3
|
||||
|
||||
The root object imports the category "predicates", which defines one
|
||||
public predicate, public/0, one protected predicate, protected/0, and
|
||||
one private predicate, private/0.
|
||||
|
||||
All objects import the category "interface", which defines a predicate,
|
||||
interface/0, for listing the object interface.
|
||||
*/
|
||||
|
||||
|
||||
:- object(root,
|
||||
imports(predicates, interface),
|
||||
instantiates(root)).
|
||||
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
% public inheritance:
|
||||
% root predicates will be inherited without scope changes
|
||||
:- object(subclass1,
|
||||
imports(interface),
|
||||
specializes(public::root)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(instance1,
|
||||
instantiates(subclass1)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
% protected inheritance:
|
||||
% root public predicates will be inherited as protected predicates
|
||||
:- object(subclass2,
|
||||
imports(interface),
|
||||
specializes(protected::root)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(instance2,
|
||||
instantiates(subclass2)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
% private inheritance:
|
||||
% root predicates will be inherited as private predicates
|
||||
:- object(subclass3,
|
||||
imports(interface),
|
||||
specializes(private::root)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(instance3,
|
||||
instantiates(subclass3)).
|
||||
|
||||
:- end_object.
|
72
Logtalk/examples/inheritance/prototypes.lgt
Normal file
72
Logtalk/examples/inheritance/prototypes.lgt
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
This source file defines the following prototype-based hierarchy:
|
||||
|
||||
parent
|
||||
prototype1
|
||||
descendant1
|
||||
prototype2
|
||||
descendant2
|
||||
prototype3
|
||||
descendant3
|
||||
|
||||
The root object imports the category "predicates", which defines one
|
||||
public predicate, public/0, one protected predicate, protected/0, and
|
||||
one private predicate, private/0.
|
||||
|
||||
All objects import the category "interface", which defines a predicate,
|
||||
interface/0, for listing the object interface.
|
||||
*/
|
||||
|
||||
|
||||
:- object(parent,
|
||||
imports(predicates, interface)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
% public inheritance:
|
||||
% parent predicates will be inherited without scope changes
|
||||
:- object(prototype1,
|
||||
imports(interface),
|
||||
extends(public::parent)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(descendant1,
|
||||
imports(interface),
|
||||
extends(prototype1)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
% protected inheritance:
|
||||
% parent public predicates will be inherited as protected predicates
|
||||
:- object(prototype2,
|
||||
imports(interface),
|
||||
extends(protected::parent)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(descendant2,
|
||||
imports(interface),
|
||||
extends(prototype2)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
% private inheritance:
|
||||
% parent predicates will be inherited as private predicates
|
||||
:- object(prototype3,
|
||||
imports(interface),
|
||||
extends(private::parent)).
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
||||
:- object(descendant3,
|
||||
imports(interface),
|
||||
extends(prototype3)).
|
||||
|
||||
:- end_object.
|
Reference in New Issue
Block a user