This commit is contained in:
Ingy döt Net 2013-10-27 22:24:23 +00:00
parent 6f050a029e
commit 776bba907c
3887 changed files with 59894 additions and 7280 deletions

View file

@ -1,27 +1,35 @@
#subject foo.
#define system.
#class FieldContainer
#class Extender
{
#field theValue.
#field theObject.
#field theField.
#method foo'set : anObject
#constructor new : anObject
[
theValue := anObject.
theObject := anObject.
]
#method foo'get = theValue.
#method foo = theField.
#method set &foo : aValue
[
theField := aValue.
]
#method => theObject.
}
#symbol Program =
#symbol program =
[
#var anObject := 234.
// adding a field
anObject := anObject &= FieldContainer.
anObject := Extender new:anObject.
anObject foo'set:"bar".
anObject set &foo:"bar".
'program'Output << anObject << ".foo=" << anObject foo.
console << anObject << ".foo=" << anObject foo.
'program'input get.
console readChar.
].

View file

@ -0,0 +1,18 @@
% we start by defining an empty object
:- object(foo).
% ensure that complementing categories are allowed
:- set_logtalk_flag(complements, allow).
:- end_object.
% define a complementing category, adding a new predicate
:- category(bar,
complements(foo)).
:- public(bar/1).
bar(1).
bar(2).
bar(3).
:- end_category.

View file

@ -0,0 +1,5 @@
| ?- foo::bar(X).
X = 1 ;
X = 2 ;
X = 3
true