Logtalk 2.30.2 files.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1908 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
pmoura
2007-06-24 13:27:35 +00:00
parent 628bcbeeb6
commit 9fc2c47d53
261 changed files with 675 additions and 1035 deletions

View File

@@ -1,6 +1,6 @@
================================================================
Logtalk - Open source object-oriented logic programming language
Release 2.30.1
Release 2.30.2
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
================================================================

View File

@@ -1,6 +1,6 @@
================================================================
Logtalk - Open source object-oriented logic programming language
Release 2.30.1
Release 2.30.2
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
================================================================
@@ -71,3 +71,18 @@ NR = rectangle(2, 1, 3, 4)
X2 = 3
Y2 = 4
yes
% some queries with parametric objects that define "setter"
% methods that return updated object identifiers:
| ?- person(sally, 20)::grow_older(NewId).
NewId = person(sally, 21)
yes
| ?- employee(sally, 21, 1200)::give_raise(250, NewId).
NewId = employee(sally, 21, 1450)
yes

View File

@@ -201,7 +201,7 @@
/* The following parametric object illustrates a solution for implementing
modifiable object state. The idea is to represent object state by using
backtracable object state. The idea is to represent object state by using
object parameters, defining "setter" predicates/methods that return the
updated object identifier.
*/
@@ -276,3 +276,74 @@
*/
:- end_object.
/* The following parametric objects show a solution for dealing with inheritance when
defining "setter" predicates/methods that return updated object identifiers.
*/
:- object(person(_Name, _Age)).
:- info([
version is 1.0,
author is 'Paulo Moura',
date is 2007/6/19,
comment is 'A simple representation for people using parametric objects.',
parnames is ['Name', 'Age']]).
:- public(grow_older/1).
:- mode(grow_older(-object_identifier), one).
:- info(grow_older/1,
[comment is 'Increments the person''s age, returning the updated object identifier.',
argnames is ['NewId']]).
grow_older(NewId) :-
::age(OldAge, NewAge, NewId),
NewAge is OldAge + 1.
:- protected(age/3).
:- mode(age(?integer, ?integer, -object_identifier), zero_or_one).
:- info(age/3,
[comment is 'Rectangle area.',
argnames is ['OldAge', 'NewAge', 'NewId']]).
age(OldAge, NewAge, person(Name, NewAge)) :- % this rule is compiled into a fact due to
this(person(Name, OldAge)). % compilation of the this/1 call inline
:- end_object.
:- object(employee(Name, Age, _Salary),
extends(person(Name, Age))).
:- info([
version is 1.0,
author is 'Paulo Moura',
date is 2007/6/19,
comment is 'A simple representation for employees using parametric objects.',
parnames is ['Name', 'Age', 'Salary']]).
:- public(give_raise/2).
:- mode(give_raise(+integer, -object_identifier), one).
:- info(give_raise/2,
[comment is 'Gives a raise to the employee, returning the updated object identifier.',
argnames is ['Amount', 'NewId']]).
give_raise(Amount, NewId) :-
::salary(OldSalary, NewSalary, NewId),
NewSalary is OldSalary + Amount.
:- protected(salary/3).
:- mode(salary(?integer, ?integer, -object_identifier), zero_or_one).
:- info(salary/3,
[comment is 'Rectangle area.',
argnames is ['OldSalary', 'NewSalary', 'NewId']]).
salary(OldSalary, NewSalary, employee(Name, Age, NewSalary)) :-
this(employee(Name, Age, OldSalary)).
age(OldAge, NewAge, employee(Salary, Name, NewAge)) :-
this(employee(Salary, Name, OldAge)).
:- end_object.