Logtalk 2.15.5 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@955 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
@@ -1,20 +1,24 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<?xml-stylesheet type="text/css" href="../styles.css" ?>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
|
||||
<head>
|
||||
<title>List predicates</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
|
||||
<title>Logtalk tutorial: list predicates</title>
|
||||
<link rel="stylesheet" href="../styles.css" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<hr />
|
||||
<h1><a class="back" title="Return to index" href="index.html#lists">List predicates</a></h1>
|
||||
<div class="navtop">
|
||||
<a href="../index.html">contents</a> > <a href="index.html">tutorial</a>
|
||||
</div>
|
||||
|
||||
<h1>List predicates</h1>
|
||||
|
||||
<p>
|
||||
In this example, we will illustrate the use of:
|
||||
@@ -27,8 +31,7 @@ In this example, we will illustrate the use of:
|
||||
by using common list utility predicates.
|
||||
</p>
|
||||
|
||||
<hr />
|
||||
<h2><a class="back" title="Return to index" name="object" href="index.html#lists_object">Defining a list object</a></h2>
|
||||
<h2>Defining a list object<a name="object"></a></h2>
|
||||
|
||||
<p>
|
||||
We will start by defining an object, <code>list</code>, containing predicate definitions for some common list predicates like <code>append/3</code>, <code>length/2</code> and <code>member/2</code>:
|
||||
@@ -115,8 +118,7 @@ The infix operator <a title="Consult reference manual" href="../refman/control/t
|
||||
The error term describes the type of error, the message that caused the exeption, and the sender of the message (in this case, the pseudo-object <code>user</code> because we are sending the message from the top-level interpreter).
|
||||
</p>
|
||||
|
||||
<hr />
|
||||
<h2><a class="back" title="Return to index" name="protocol" href="index.html#lists_protocol">Defining a list protocol</a></h2>
|
||||
<h2>Defining a list protocol<a name="protocol"></a></h2>
|
||||
|
||||
<p>
|
||||
As we saw in the above example, a Logtalk object may contain predicate directives and predicate definitions. The set of predicate directives defines what we call the object's <em>protocol</em> or interface. An interface may have several implementations. For instance, we may want to define a new object that implements the list predicates using difference lists. However, we do not want to repeat the predicate directives in the new object. Therefore, what we need is to split the object's protocol from the object's predicate definitions by defining a new Logtalk entity called a protocol. Logtalk protocols are compilations units, at the same level as objects and categories. That said, let us define a <code>listp</code> protocol:
|
||||
@@ -185,8 +187,7 @@ The protocol declared in <code>listp</code> may now be alternatively implemented
|
||||
:- end_object.
|
||||
</pre>
|
||||
|
||||
<hr />
|
||||
<h2><a class="back" title="Return to index" name="summary" href="index.html#lists_summary">Summary</a></h2>
|
||||
<h2>Summary<a name="summary"></a></h2>
|
||||
|
||||
<ul>
|
||||
<li>It is easy to define a simple object: just put your Prolog code inside starting and ending object directives and add the necessary scope directives. The object will be self-defining and ready to use.</li>
|
||||
@@ -195,15 +196,16 @@ The protocol declared in <code>listp</code> may now be alternatively implemented
|
||||
<li>Define a protocol when you may want to provide or enable several alternative definitions to a given set of predicates. This way we avoid needless repetition of predicate directives.</li>
|
||||
</ul>
|
||||
|
||||
<hr />
|
||||
<p class="center">
|
||||
<strong><a href="index.html">Previous</a> | <a href="attributes.html">Next</a> | <a href="index.html">Table of Contents</a> | <a href="../bibliography.html">Bibliography</a> | <a href="../glossary.html">Glossary</a></strong>
|
||||
</p>
|
||||
<p class="center">
|
||||
Last updated on: August 6, 2002
|
||||
</p>
|
||||
<hr />
|
||||
<div class="navbottom">
|
||||
<a href="index.html">previous</a> | <a href="../glossary.html">glossary</a> | <a href="attributes.html">next</a>
|
||||
</div>
|
||||
|
||||
<div class="copyright">
|
||||
Copyright © <a href="mailto:pmoura@logtalk.org">Paulo Moura</a> — <a href="http://www.logtalk.org">Logtalk.org</a>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<p><span class="bleft"><a href="http://validator.w3.org/check/referer">XHTML</a> + <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a></span><span class="bright">Last updated on: December 23, 2003</span></p>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user