~ubuntu-branches/ubuntu/hardy/swi-prolog/hardy

« back to all changes in this revision

Viewing changes to man/Manual/usingmodules.html

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2007-12-02 23:26:00 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20071202232600-b7d3d1i4kzfqmipf
Tags: 5.6.47-1
* New upstream version (Closes: #295209, #308325, #425580)
* New maintainer (Closes: #422576)
* Bump Debhelper compatibility to 5
* debian/rules:
   * Update config.sub and config.guess from autotools-dev
       (Closes: #408076, #414181)
   * Desist from blindly ignoring "clean" target
* debian/control:
   * Use ${binary:Version} instead of ${Source-Version}
   * Add new Homepage: field
   * Add XS-Vcs-* fields
* Change ".menu" sections from
     "Apps/Programming" -> "Applications/Programming"
* Documentation:
   * Remove some SGML documentation now missing from upstream
   * Add Sicstus and SWI-Prolog v4.8 -related XPCE documentation

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 
2
 
 
3
<HTML>
 
4
<HEAD>
 
5
<TITLE>SWI-Prolog 5.6.47 Reference Manual: Section 3.2</TITLE><LINK REL=home HREF="index.html">
 
6
<LINK REL=contents HREF="Contents.html">
 
7
<LINK REL=index HREF="DocIndex.html">
 
8
<LINK REL=previous HREF="projectfiles.html">
 
9
<LINK REL=next HREF="editreload.html">
 
10
<STYLE type="text/css">
 
11
/* Style sheet for SWI-Prolog latex2html
 
12
*/
 
13
 
 
14
dd.defbody
 
15
{ margin-bottom: 1em;
 
16
}
 
17
 
 
18
dt.pubdef
 
19
{ background-color: #c5e1ff;
 
20
}
 
21
 
 
22
pre.code
 
23
{ margin-left: 1.5em;
 
24
margin-right: 1.5em;
 
25
border: 1px dotted;
 
26
padding-top: 5px;
 
27
padding-left: 5px;
 
28
padding-bottom: 5px;
 
29
background-color: #f8f8f8;
 
30
}
 
31
 
 
32
div.navigate
 
33
{ text-align: center;
 
34
background-color: #f0f0f0;
 
35
border: 1px dotted;
 
36
padding: 5px;
 
37
}
 
38
 
 
39
div.title
 
40
{ text-align: center;
 
41
padding-bottom: 1em;
 
42
font-size: 200%;
 
43
font-weight: bold;
 
44
}
 
45
 
 
46
div.author
 
47
{ text-align: center;
 
48
font-style: italic;
 
49
}
 
50
 
 
51
div.abstract
 
52
{ margin-top: 2em;
 
53
background-color: #f0f0f0;
 
54
border: 1px dotted;
 
55
padding: 5px;
 
56
margin-left: 10%; margin-right:10%;
 
57
}
 
58
 
 
59
div.abstract-title
 
60
{ text-align: center;
 
61
padding: 5px;
 
62
font-size: 120%;
 
63
font-weight: bold;
 
64
}
 
65
 
 
66
div.toc-h1
 
67
{ font-size: 200%;
 
68
font-weight: bold;
 
69
}
 
70
 
 
71
div.toc-h2
 
72
{ font-size: 120%;
 
73
font-weight: bold;
 
74
margin-left: 2em;
 
75
}
 
76
 
 
77
div.toc-h3
 
78
{ font-size: 100%;
 
79
font-weight: bold;
 
80
margin-left: 4em;
 
81
}
 
82
 
 
83
div.toc-h4
 
84
{ font-size: 100%;
 
85
margin-left: 6em;
 
86
}
 
87
 
 
88
span.sec-nr
 
89
 
90
}
 
91
 
 
92
span.sec-title
 
93
 
94
}
 
95
 
 
96
span.pred-ext
 
97
{ font-weight: bold;
 
98
}
 
99
 
 
100
span.pred-tag
 
101
{ float: right;
 
102
font-size: 80%;
 
103
font-style: italic;
 
104
color: #202020;
 
105
}
 
106
 
 
107
/* Footnotes */
 
108
 
 
109
sup.fn { color: blue; text-decoration: underline; }
 
110
span.fn-text: { display: none; }
 
111
sup.fn span {display: none;}
 
112
sup:hover span 
 
113
{ display: block !important;
 
114
position: absolute; top: auto; left: auto; width: 80%;
 
115
color: #000; background: white;
 
116
border: 2px solid;
 
117
padding: 5px; margin: 10px; z-index: 100;
 
118
font-size: smaller;
 
119
}
 
120
</STYLE>
 
121
</HEAD>
 
122
<BODY BGCOLOR="white">
 
123
<DIV class="navigate"><A class="nav" href="index.html"><IMG SRC="home.gif" BORDER=0 ALT="Home"></A>
 
124
<A class="nav" href="Contents.html"><IMG SRC="index.gif" BORDER=0 ALT="Contents"></A>
 
125
<A class="nav" href="DocIndex.html"><IMG SRC="yellow_pages.gif" BORDER=0 ALT="Index"></A>
 
126
<A class="nav" href="projectfiles.html"><IMG SRC="prev.gif" BORDER=0 ALT="Previous"></A>
 
127
<A class="nav" href="editreload.html"><IMG SRC="next.gif" BORDER=0 ALT="Next"></A>
 
128
</DIV>
 
129
 
 
130
<H2><A NAME="sec:3.2"><SPAN class="sec-nr">3.2</SPAN> <SPAN class="sec-title">Using 
 
131
modules</SPAN></A></H2>
 
132
 
 
133
<A NAME="sec:usingmodules"></A>
 
134
 
 
135
<P>Modules have been debated fiercely in the Prolog world. Despite all 
 
136
counter-arguments we feel they are extremely useful because
 
137
 
 
138
<P>
 
139
<UL>
 
140
<LI><I>They hide local predicates</I><BR>
 
141
This is the reason they have been invented in the first place. Hiding 
 
142
provides two features. They allow for short predicate names without 
 
143
worrying about conflicts. Given the flat name-space introduced by 
 
144
modules, they still require meaningful module names as well as 
 
145
meaningful names for exported predicates.
 
146
 
 
147
<P>
 
148
<LI><I>They document the interface</I><BR>
 
149
Possibly more important then avoiding name-conflicts is their role in 
 
150
documenting which part of the file is for public usage and which is 
 
151
private. When editing a module you may assume you can reorganise 
 
152
anything but the name and semantics of the exported predicates without 
 
153
worrying.
 
154
 
 
155
<P>
 
156
<LI><I>They help the editor</I><BR>
 
157
The PceEmacs built-in editor does on-the-fly cross-referencing of the 
 
158
current module, colouring predicates based on their origin and usage. 
 
159
Using modules, the editor can quickly find out what is provided by the 
 
160
imported modules by reading just the first term. This allows it to 
 
161
indicate real-time which predicates are not used or not defined.
 
162
</UL>
 
163
 
 
164
<P>Using modules is generally easy. Only if you write meta-predicates 
 
165
(predicates reasoning about other predicates) that are exported from a 
 
166
module good understanding of resolution of terms to predicates inside a 
 
167
module is required. Here is a typical example from <CODE>library(readutil)</CODE>.
 
168
 
 
169
<PRE class="code">
 
170
:- module(read_util,
 
171
          [ read_line_to_codes/2,       % +Fd, -Codes
 
172
            read_line_to_codes/3,       % +Fd, -Codes, ?Tail
 
173
            read_stream_to_codes/2,     % +Fd, -Codes
 
174
            read_stream_to_codes/3,     % +Fd, -Codes, ?Tail
 
175
            read_file_to_codes/3,       % +File, -Codes, +Options
 
176
            read_file_to_terms/3        % +File, -Terms, +Options
 
177
          ]).
 
178
</PRE>
 
179
 
 
180
<P></BODY></HTML>
 
 
b'\\ No newline at end of file'