Logtalk 2.26.2 files.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1488 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
pmoura
2005-12-24 18:26:23 +00:00
parent 3455276aa2
commit 60fbc754f9
123 changed files with 130 additions and 4097 deletions

View File

@@ -1,70 +0,0 @@
/*
This example illustrates the use of the predicate directive alias/3 for
defining alternative names for inherited predicates.
*/
% first, we define a simple parametric object for representing rectangles:
:- object(rectangle(_Width, _Height)).
:- public(width/1).
:- public(height/1).
:- public(area/1).
width(Width) :-
parameter(1, Width).
height(Height) :-
parameter(2, Height).
area(Area) :-
::width(Width),
::height(Height),
Area is Width*Height.
:- end_object.
% next, we define a square object which adds an alias, side/1, for the
% inherited predicate width/1:
:- object(square(Side),
extends(rectangle(Side, Side))).
:- alias(rectangle(_, _), width/1, side/1).
:- end_object.
% a similar example can be defined using ellipses and circles:
:- object(ellipse(_RX, _RY)).
:- public(rx/1).
:- public(ry/1).
:- public(area/1).
rx(Rx) :-
parameter(1, Rx).
ry(Ry) :-
parameter(2, Ry).
area(Area) :-
::rx(Rx),
::ry(Ry),
Area is Rx*Ry*3.1415927.
:- end_object.
% in this case, we define an alias named r/1 for the inherited
% predicate rx/1:
:- object(circle(Radius),
extends(ellipse(Radius, Radius))).
:- alias(ellipse(_, _), rx/1, r/1).
:- end_object.