Changeset 4561 for trunk/manuals

Show
Ignore:
Timestamp:
11/02/08 09:20:29 (2 months ago)
Author:
pmoura
Message:

Minor documentation improvements.

Location:
trunk/manuals/userman
Files:
1 removed
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/manuals/userman/documenting.html

    r3545 r4561  
    140140</p> 
    141141<p> 
    142 There is a set of compilers options, used with the Logtalk <a title="Consult reference manual" href="../refman/builtins/logtalk_load2.html"><code>logtalk_load/2</code></a> or the <a title="Consult reference manual" href="../refman/builtins/logtalk_compile2.html"><code>logtalk_compile/2</code></a> built-in predicates, that can be used to control the generation of the XML documentation files. Please see the <a href="running.html#options">Running Logtalk</a> section of this manual for details. 
     142There is a set of compilers options, used with the Logtalk <a title="Consult reference manual" href="../refman/builtins/logtalk_load2.html"><code>logtalk_load/2</code></a> or the <a title="Consult reference manual" href="../refman/builtins/logtalk_compile2.html"><code>logtalk_compile/2</code></a> built-in predicates, that can be used to control the generation of the XML documentation files. Please see the <a href="programming.html#options">Running Logtalk</a> section of this manual for details. 
    143143</p> 
    144144 
  • trunk/manuals/userman/features.html

    r3830 r4561  
    4444<blockquote> 
    4545<p> 
    46 Event-driven programming enables the building of reactive systems, where computing which takes place at each moment is a result of the observation of occurring events. This integration complements object-oriented programming, in which each computing is initiated by the explicit sending of a message to an object. The user dynamically defines what events are to be observed and establishes monitors for these events. This is specially useful when representing relationships between objects that imply constraints in the state of participating objects <a href="../bibliography.html#Rumbaugh87">[Rumbaugh 87</a>, <a href="../bibliography.html#Rumbaugh88">Rumbaugh 88</a>, <a href="../bibliography.html#Fornarino89">Fornarino 89</a>, <a href="../bibliography.html#Razek92">Razek 92]</a>. Other common uses are reflective applications like code debugging or profiling <a href="../bibliography.html#Maes87">[Maes 87]</a>. 
     46Event-driven programming enables the building of reactive systems, where computing which takes place at each moment is a result of the observation of occurring events. This integration complements object-oriented programming, in which each computing is initiated by the explicit sending of a message to an object. The user dynamically defines what events are to be observed and establishes monitors for these events. This is specially useful when representing relationships between objects that imply constraints in the state of participating objects <a href="../bibliography.html#Rumbaugh87">[Rumbaugh 87</a>, <a href="../bibliography.html#Rumbaugh88">Rumbaugh 88</a>, <a href="../bibliography.html#Fornarino89">Fornarino 89</a>, <a href="../bibliography.html#Razek92">Razek 92]</a>. Other common uses are reflective applications like code debugging or profiling <a href="../bibliography.html#Maes87">[Maes 87]</a>. Predicates can be implicitly called when a spied event occurs, allowing programming solutions which minimize object coupling. In addition, events provide support for behavioral reflection and can be used to implement the concepts of <em>pointcut</em> and <em>advice</em> found on Aspect-Oriented Programming.</dd> 
    4747</p> 
    4848</blockquote> 
     
    5252<blockquote> 
    5353<p> 
    54 Predicates can be encapsulated inside <em>categories</em> which can be imported by any object. A category is a first-class encapsulation entity, at the same level as objects and protocols, which can be used as a component when building new objects. Categories allows for code reuse between non-related objects, independent of hierarchy relations, in the same vein as protocols allow for interface reuse. 
     54Predicates can be encapsulated inside <em>categories</em> which can be imported by any object, without any code duplication and irrespective of object hierarchies. A category is a first-class encapsulation entity, at the same level as objects and protocols, which can be used as a component when building new objects. Thus, objects may be defined through composition of categories, which act as fine-grained units of code reuse. Categories may also extend existing objects. Categories can be used to implement <em>mixins</em> and <em>aspects</em>. Categories allows for code reuse between non-related objects, independent of hierarchy relations, in the same vein as protocols allow for interface reuse. 
    5555</p> 
    5656</blockquote> 
     
    100100<blockquote> 
    101101<p> 
    102 Object names can be compound terms (instead of atoms), providing a way to parameterize object predicates. Parametric objects are implemented in a similar way to <code>L&amp;O</code> <a href="../bibliography.html#McCabe92">[McCabe 92]</a>, <code>OL(P)</code> <a href="../bibliography.html#Fromherz93">[Fromherz 93]</a> or <code>SICStus Objects</code> <a href="../bibliography.html#SICStus95">[SICStus 95]</a>. However, access to parameter values is done via a built-in method instead of making the parameters scope global over the whole object. 
     102Object names can be compound terms (instead of atoms), providing a way to parameterize object predicates. Parametric objects are implemented in a similar way to <code>L&amp;O</code> <a href="../bibliography.html#McCabe92">[McCabe 92]</a>, <code>OL(P)</code> <a href="../bibliography.html#Fromherz93">[Fromherz 93]</a> or <code>SICStus Objects</code> <a href="../bibliography.html#SICStus95">[SICStus 95]</a> (however, access to parameter values is done via a built-in method instead of making the parameters scope global over the whole object). Parametric objects allows us to treat any predicate clause as defining an <em>instantiation</em> of a parametric object. Thus, a parametric object allows us to  encapsulate and associate any number of predicates with a compound term.</dd> 
    103103</p> 
    104104</blockquote> 
     
    142142</blockquote> 
    143143 
     144<h2 id="features_scope">Logtalk scope</h2> 
     145 
     146<p> 
     147Logtalk, being a superset of Prolog, shares with it the same preferred areas of application but also extends them with those areas where object-oriented features provide an advantage compared to plain Prolog. Among these areas we have: 
     148</p> 
     149<dl> 
     150    <dt><strong>Logic and object-oriented programming teaching and researching</strong></dt> 
     151        <dd>Logtalk smooth learning curve, combined with support for both prototype and class-based programming, protocols, components or aspects via category-based composition, and other advanced object-oriented features allow a smooth introduction to object-oriented programming to people with a background in Prolog programming. The distribution of Logtalk source code using an open-source license provides a framework for people to learn and then modify to try out new ideas on object-oriented programming research. In addition, the Logtalk distribution includes plenty of programming examples that can be used in the classroom for teaching logic and object-oriented programming concepts.</dd> 
     152</dl> 
     153<dl> 
     154    <dt><strong>Structured knowledge representations and knowledge-based systems</strong></dt> 
     155        <dd>Logtalk objects, coupled with event-driven programming features, enable easy implementation of frame-like systems and similar structured knowledge representations.</dd> 
     156</dl> 
     157<dl> 
     158    <dt><strong>Blackboard systems, agent-based systems and systems with complex object relationships</strong></dt> 
     159        <dd>Logtalk support for event-driven programming can provide a basis for the dynamic and reactive nature of blackboard type applications.</dd> 
     160</dl> 
     161<dl> 
     162    <dt><strong>Highly portable applications</strong></dt> 
     163        <dd>Logtalk is compatible with almost any modern Prolog compiler. Used as a way to provide Prolog with namespaces, it avoids the porting problems of most Prolog module systems. Platform, operating system, or compiler specific code can be isolated from the rest of the code by encapsulating it in objects with well defined interfaces.</dd> 
     164</dl> 
     165<dl> 
     166    <dt><strong>Alternative to a Prolog module system</strong></dt> 
     167        <dd>Logtalk can be used as an alternative to a Prolog compiler module system. Any Prolog application that use modules can be converted to a Logtalk application, improving portability across Prolog compilers and taking advantage of the stronger encapsulation and reuse framework provided by Logtalk object-oriented features.</dd> 
     168</dl> 
     169<dl> 
     170    <dt><strong>Integration with other programming languages</strong></dt> 
     171        <dd>Logtalk support for most key object-oriented features helps users integrating Prolog with object-oriented languages like C++, Java, or Smalltalk by providing an high-level mapping between the two languages.</dd> 
     172</dl> 
     173 
    144174<div class="footer"> 
    145175    <div class="copyright"> 
    146176        <span>Copyright &copy; <a href="mailto:pmoura@logtalk.org">Paulo Moura</a> &mdash; <a href="http://logtalk.org">Logtalk.org</a></span><br/>  
    147         <span>Last updated on: June 8, 2007</span> 
     177        <span>Last updated on: October 31, 2008</span> 
    148178    </div> 
    149179    <div class="navbottom"> 
  • trunk/manuals/userman/index.html

    r4556 r4561  
    2323 
    2424<dl class="toc-entries"> 
    25     <dt><a href="#features">Logtalk features</a><span class="leader"></span><span class="page-ref"><span class="features_features"></span></span></dt> 
    26     <dt><a href="#nomenclature">Logtalk nomenclature</a><span class="leader"></span><span class="page-ref"><span class="nomenclature_nomenclature"></span></span></dt> 
    27 </dl> 
    28 <dl class="toc-entries"> 
    29     <dt><a href="#messages">Message sending</a><span class="leader"></span><span class="page-ref"><span class="messages_messages"></span></span></dt> 
     25    <dt><a href="#features">Logtalk Features</a><span class="leader"></span><span class="page-ref"><span class="features_features"></span></span></dt> 
     26    <dt><a href="#nomenclature">Logtalk Nomenclature</a><span class="leader"></span><span class="page-ref"><span class="nomenclature_nomenclature"></span></span></dt> 
     27</dl> 
     28<dl class="toc-entries"> 
     29    <dt><a href="#messages">Message Sending</a><span class="leader"></span><span class="page-ref"><span class="messages_messages"></span></span></dt> 
    3030    <dt><a href="#objects">Objects</a><span class="leader"></span><span class="page-ref"><span class="objects_objects"></span></span></dt> 
    3131    <dt><a href="#protocols">Protocols</a><span class="leader"></span><span class="page-ref"><span class="protocols_protocols"></span></span></dt> 
     
    3333    <dt><a href="#predicates">Predicates</a><span class="leader"></span><span class="page-ref"><span class="predicates_predicates"></span></span></dt> 
    3434    <dt><a href="#inheritance">Inheritance</a><span class="leader"></span><span class="page-ref"><span class="inheritance_inheritance"></span></span></dt> 
    35     <dt><a href="#events">Event-driven programming</a><span class="leader"></span><span class="page-ref"><span class="events_events"></span></span></dt> 
    36     <dt><a href="#threads">Multi-threading programming</a><span class="leader"></span><span class="page-ref"><span class="threads_threads"></span></span></dt> 
    37     <dt><a href="#errors">Error handling</a><span class="leader"></span><span class="page-ref"><span class="errors_errors"></span></span></dt> 
    38 </dl> 
    39 <dl class="toc-entries"> 
    40     <dt><a href="#documenting">Documenting Logtalk programs</a><span class="leader"></span><span class="page-ref"><span class="documenting_documenting"></span></span></dt> 
     35    <dt><a href="#events">Event-driven Programming</a><span class="leader"></span><span class="page-ref"><span class="events_events"></span></span></dt> 
     36    <dt><a href="#threads">Multi-threading Programming</a><span class="leader"></span><span class="page-ref"><span class="threads_threads"></span></span></dt> 
     37    <dt><a href="#errors">Error Handling</a><span class="leader"></span><span class="page-ref"><span class="errors_errors"></span></span></dt> 
     38</dl> 
     39<dl class="toc-entries"> 
     40    <dt><a href="#documenting">Documenting Logtalk Programs</a><span class="leader"></span><span class="page-ref"><span class="documenting_documenting"></span></span></dt> 
    4141</dl> 
    4242<dl class="toc-entries"> 
    4343    <dt><a href="#installing">Installing Logtalk</a><span class="leader"></span><span class="page-ref"><span class="installing_installing"></span></span></dt> 
    44     <dt><a href="#running">Running and debugging Logtalk programs</a><span class="leader"></span><span class="page-ref"><span class="running_running"></span></span></dt> 
    45     <dt><a href="#programming">Programming in Logtalk</a><span class="leader"></span><span class="page-ref"><span class="programming_programming"></span></span></dt> 
    46 </dl> 
    47  
    48 <h2><a id="features" href="features.html">Logtalk features</a></h2> 
     44    <dt><a href="#programming">Writing, Running, and Debugging Logtalk Programs</a><span class="leader"></span><span class="page-ref"><span class="programming_programming"></span></span></dt> 
     45</dl> 
     46 
     47<h2><a id="features" href="features.html">Logtalk Features</a></h2> 
    4948 
    5049<dl class="toc-entries"> 
     
    6261    <dt><a href="features.html#features_compatibility">Compatibility with most Prologs and the ISO standard</a><span class="leader"></span><span class="page-ref"><span class="features_compatibility"></span></span></dt> 
    6362    <dt><a href="features.html#features_performance">Performance</a><span class="leader"></span><span class="page-ref"><span class="features_performance"></span></span></dt> 
    64 </dl> 
    65  
    66 <h2><a id="nomenclature" href="nomenclature.html">Logtalk nomenclature</a></h2> 
     63    <dt><a href="features.html#features_scope">Logtalk scope</a><span class="leader"></span><span class="page-ref"><span class="features_scope"></span></span></dt> 
     64</dl> 
     65 
     66<h2><a id="nomenclature" href="nomenclature.html">Logtalk Nomenclature</a></h2> 
    6767 
    6868<dl class="toc-entries"> 
     
    7171</dl> 
    7272 
    73 <h2><a id="messages" href="messages.html">Message sending</a></h2> 
     73<h2><a id="messages" href="messages.html">Message Sending</a></h2> 
    7474 
    7575<dl class="toc-entries"> 
     
    192192</dl> 
    193193 
    194 <h2><a id="events" href="events.html">Event-driven programming</a></h2> 
     194<h2><a id="events" href="events.html">Event-driven Programming</a></h2> 
    195195 
    196196<dl class="toc-entries"> 
     
    210210</dl> 
    211211 
    212 <h2><a id="threads" href="threads.html">Multi-threading programming</a></h2> 
     212<h2><a id="threads" href="threads.html">Multi-threading Programming</a></h2> 
    213213 
    214214<dl class="toc-entries"> 
     
    224224</dl> 
    225225 
    226 <h2><a id="errors" href="errors.html">Error handling</a></h2> 
     226<h2><a id="errors" href="errors.html">Error Handling</a></h2> 
    227227 
    228228<dl class="toc-entries"> 
     
    242242</dl> 
    243243 
    244 <h2><a id="documenting" href="documenting.html">Documenting Logtalk programs</a></h2> 
     244<h2><a id="documenting" href="documenting.html">Documenting Logtalk Programs</a></h2> 
    245245 
    246246<dl class="toc-entries"> 
     
    268268</dl> 
    269269 
    270 <h2><a id="running" href="running.html">Running and debugging Logtalk programs</a></h2> 
    271  
    272 <dl class="toc-entries"> 
    273     <dt><a href="running.html#running_session">Running a Logtalk session</a><span class="leader"></span><span class="page-ref"><span class="running_session"></span></span></dt> 
    274         <dd><a href="running.html#running_starting">Starting Logtalk</a><span class="leader"></span><span class="page-ref"><span class="running_starting"></span></span></dd> 
    275         <dd><a href="running.html#running_compiling">Compiling and loading your programs</a><span class="leader"></span><span class="page-ref"><span class="running_compiling"></span></span></dd> 
    276         <dd><a href="running.html#running_flags">Compiler flags</a><span class="leader"></span><span class="page-ref"><span class="running_flags"></span></span></dd> 
    277         <dd><a href="running.html#running_smart">Realoding and smart compilation of source files</a><span class="leader"></span><span class="page-ref"><span class="running_smart"></span></span></dd> 
    278     <dt><a href="running.html#running_batch">Using Logtalk for batch processing</a><span class="leader"></span><span class="page-ref"><span class="running_batch"></span></span></dt> 
    279     <dt><a href="running.html#running_debugging">Debugging Logtalk programs</a><span class="leader"></span><span class="page-ref"><span class="running_debugging"></span></span></dt> 
    280         <dd><a href="running.html#running_debugmode">Compiling objects in debug mode</a><span class="leader"></span><span class="page-ref"><span class="running_debugmode"></span></span></dd> 
    281         <dd><a href="running.html#running_boxmodel">Logtalk Procedure Box model</a><span class="leader"></span><span class="page-ref"><span class="running_boxmodel"></span></span></dd> 
    282         <dd><a href="running.html#running_spypoints">Defining spy points</a><span class="leader"></span><span class="page-ref"><span class="running_spypoints"></span></span></dd> 
    283         <dd><a href="running.html#running_trace">Tracing program execution</a><span class="leader"></span><span class="page-ref"><span class="running_trace"></span></span></dd> 
    284         <dd><a href="running.html#running_debug">Debugging using spy points</a><span class="leader"></span><span class="page-ref"><span class="running_debug"></span></span></dd> 
    285         <dd><a href="running.html#running_commands">Debugging commands</a><span class="leader"></span><span class="page-ref"><span class="running_commands"></span></span></dd> 
    286         <dd><a href="running.html#running_context">Context-switching calls</a><span class="leader"></span><span class="page-ref"><span class="running_context"></span></span></dd> 
    287         <dd><a href="running.html#running_hooks">Using compilation hooks and term expansion for debugging</a><span class="leader"></span><span class="page-ref"><span class="running_hooks"></span></span></dd> 
    288 </dl> 
    289  
    290 <h2><a id="programming" href="programming.html">Programming in Logtalk</a></h2> 
     270<h2><a id="programming" href="programming.html">Writing, Running, and Debugging Logtalk programs</a></h2> 
    291271 
    292272<dl class="toc-entries"> 
     
    298278        <dd><a href="programming.html#programming_errors">Avoiding common errors</a><span class="leader"></span><span class="page-ref"><span class="programming_errors"></span></span></dd> 
    299279        <dd><a href="programming.html#programming_style">Coding style guidlines</a><span class="leader"></span><span class="page-ref"><span class="programming_style"></span></span></dd> 
    300     <dt><a href="programming.html#programming_scope">Logtalk scope</a><span class="leader"></span><span class="page-ref"><span class="programming_scope"></span></span></dt> 
     280    <dt><a href="programming.html#programming_session">Running a Logtalk session</a><span class="leader"></span><span class="page-ref"><span class="programming_session"></span></span></dt> 
     281        <dd><a href="programming.html#programming_starting">Starting Logtalk</a><span class="leader"></span><span class="page-ref"><span class="programming_starting"></span></span></dd> 
     282        <dd><a href="programming.html#programming_compiling">Compiling and loading your programs</a><span class="leader"></span><span class="page-ref"><span class="programming_compiling"></span></span></dd> 
     283        <dd><a href="programming.html#programming_flags">Compiler flags</a><span class="leader"></span><span class="page-ref"><span class="programming_flags"></span></span></dd> 
     284        <dd><a href="programming.html#programming_smart">Realoding and smart compilation of source files</a><span class="leader"></span><span class="page-ref"><span class="programming_smart"></span></span></dd> 
     285        <dd><a href="programming.html#programming_batch">Using Logtalk for batch processing</a><span class="leader"></span><span class="page-ref"><span class="programming_batch"></span></span></dd> 
     286    <dt><a href="programming.html#programming_debugging">Debugging Logtalk programs</a><span class="leader"></span><span class="page-ref"><span class="programming_debugging"></span></span></dt> 
     287        <dd><a href="programming.html#programming_debugmode">Compiling objects in debug mode</a><span class="leader"></span><span class="page-ref"><span class="programming_debugmode"></span></span></dd> 
     288        <dd><a href="programming.html#programming_boxmodel">Logtalk Procedure Box model</a><span class="leader"></span><span class="page-ref"><span class="programming_boxmodel"></span></span></dd> 
     289        <dd><a href="programming.html#programming_spypoints">Defining spy points</a><span class="leader"></span><span class="page-ref"><span class="programming_spypoints"></span></span></dd> 
     290        <dd><a href="programming.html#programming_trace">Tracing program execution</a><span class="leader"></span><span class="page-ref"><span class="programming_trace"></span></span></dd> 
     291        <dd><a href="programming.html#programming_debug">Debugging using spy points</a><span class="leader"></span><span class="page-ref"><span class="programming_debug"></span></span></dd> 
     292        <dd><a href="programming.html#programming_commands">Debugging commands</a><span class="leader"></span><span class="page-ref"><span class="programming_commands"></span></span></dd> 
     293        <dd><a href="programming.html#programming_context">Context-switching calls</a><span class="leader"></span><span class="page-ref"><span class="programming_context"></span></span></dd> 
     294        <dd><a href="programming.html#programming_hooks">Using compilation hooks and term expansion for debugging</a><span class="leader"></span><span class="page-ref"><span class="programming_hooks"></span></span></dd> 
    301295</dl> 
    302296 
  • trunk/manuals/userman/installing.html

    r4530 r4561  
    168168</p> 
    169169<p> 
    170 The configuration files specifies default values for all the Logtalk compiler flags. Most of these compiler flags are described in the <a href="running.html#options">next</a> section. A few of these flags have read-only values which cannot be changed at runtime. These are: 
     170The configuration files specifies default values for all the Logtalk compiler flags. Most of these compiler flags are described in the <a href="programming.html#options">next</a> section. A few of these flags have read-only values which cannot be changed at runtime. These are: 
    171171</p> 
    172172<dl> 
     
    229229    </div> 
    230230    <div class="navbottom"> 
    231         <span><a href="documenting.html">previous</a> | <a href="../glossary.html">glossary</a> | <a href="running.html">next</a></span><br/> 
     231        <span><a href="documenting.html">previous</a> | <a href="../glossary.html">glossary</a> | <a href="programming.html">next</a></span><br/> 
    232232        <span><a href="http://validator.w3.org/check/referer">XHTML</a> + <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a></span> 
    233233    </div> 
  • trunk/manuals/userman/messages.html

    r4393 r4561  
    150150    ... .</pre> 
    151151<p> 
    152 When events are not used, is possible to turn off event generation on a per object basis by using the <a title="Consult user manual" href="running.html#running_flags"><code>events/1</code></a> compiler option. See the session on <a href="events.html">event-driven programming</a> for more details. 
     152When events are not used, is possible to turn off event generation on a per object basis by using the <a title="Consult user manual" href="programming.html#programming_flags"><code>events/1</code></a> compiler option. See the session on <a href="events.html">event-driven programming</a> for more details. 
    153153</p> 
    154154 
     
    183183</dl> 
    184184<p> 
    185 Given that events can be dynamically defined at runtime, there is no room for reducing the number of predicate calls without turning off support for event-driven programming. When events are defined, the number of predicate calls grows proportional to the number of events and event handlers (monitors). Event-driven programming support can be switched off for specific object using the compiler flag <a title="Consult compiler flag details" href="running.html#running_flags"><code>events/1</code></a>. Doing so, reduces the number of predicate calls from six to just two. 
     185Given that events can be dynamically defined at runtime, there is no room for reducing the number of predicate calls without turning off support for event-driven programming. When events are defined, the number of predicate calls grows proportional to the number of events and event handlers (monitors). Event-driven programming support can be switched off for specific object using the compiler flag <a title="Consult compiler flag details" href="programming.html#programming_flags"><code>events/1</code></a>. Doing so, reduces the number of predicate calls from six to just two. 
    186186</p> 
    187187<p> 
  • trunk/manuals/userman/objects.html

    r4530 r4561  
    431431 
    432432<p> 
    433 Logtalk defines a built-in object named <code>debugger</code> which implements the Logtalk built-in debugger (see the section on <a href="running.html#debugging">debugging Logtalk programs</a> for details). This object is virtually compiled as a prototype. Programmers may define new prototypes extending <code>debugger</code> in order to implement custom debuggers. 
     433Logtalk defines a built-in object named <code>debugger</code> which implements the Logtalk built-in debugger (see the section on <a href="programming.html#programming_debugging">debugging Logtalk programs</a> for details). This object is virtually compiled as a prototype. Programmers may define new prototypes extending <code>debugger</code> in order to implement custom debuggers. 
    434434</p> 
    435435 
  • trunk/manuals/userman/programming.html

    r4447 r4561  
    77<head> 
    88    <meta http-equiv="content-type" content="application/xml+xhtml; charset=utf-8" /> 
    9     <title>Logtalk user manual: programming</title> 
     9    <title>Logtalk user manual: writing, running, and debugging programs</title> 
    1010    <link rel="stylesheet" href="../screen.css" type="text/css" media="screen"/> 
    1111    <link rel="stylesheet" href="../print.css" type="text/css" media="print"/> 
     
    1515 
    1616<div class="top-left">Logtalk user manual</div>  
    17 <div class="top-right">Programming in Logtalk</div> 
     17<div class="top-right">Writing, running, and debugging programs</div> 
    1818<div class="bottom-left"><span class="page"/></div>  
    1919<div class="bottom-right"><span class="page"/></div> 
    2020<div class="navtop"><a href="../index.html">contents</a> &gt; <a href="index.html">user manual</a></div> 
    2121 
    22 <h1 id="programming_programming">Programming in Logtalk</h1> 
     22<h1 id="programming_running">Writing, running, and debugging programs</h1> 
     23 
    2324 
    2425<h2 id="programming_writing">Writing programs</h2> 
     
    4142<p> 
    4243The text encoding used in a source file may be declared using the <a title="Consult reference manual" href="../refman/directives/encoding1.html"><code>encoding/1</code></a> directive when running Logtalk with some back-end Prolog compilers that support multiple encodings (check the <code>encoding_directive</code> flag in the configuration file of your Prolog compiler). The encoding used (and, in the case of a Unicode encoding, any BOM present) in a source file will be used for the generated Prolog and XML files. Logtalk uses the encoding names specified by <a title="" href="http://www.iana.org/assignments/character-sets">IANA</a> (in those cases where a preferred MIME name alias is specified, the alias is used instead). 
     44</p> 
     45 
     46<h3 id="programming_portability">Portable programs</h3> 
     47 
     48<p> 
     49Logtalk is compatible with almost all modern Prolog compilers. However, this does not necessarily imply that your Logtalk programs will have the same level of portability. If possible, you should only use in your programs Logtalk built-in predicates and ISO Prolog specified built-in predicates and arithmetic functions. If you need to use built-in predicates (or built-in arithmetic functions) that may not be available in other Prolog compilers, you should try to encapsulate the non-portable code in a small number of objects and provide a portable <strong>interface</strong> for that code through the use of Logtalk protocols. An example will be code that access operating-system specific features. The Logtalk compiler can warn you of the use of non-ISO specified built-in predicates and arithmetic functions by using the <code>portability/1</code> compiler flag. 
     50</p> 
     51 
     52<h3 id="programming_errors">Avoiding common errors</h3> 
     53 
     54<p> 
     55Try to write objects and protocol documentation <strong>before</strong> writing any other code; if you are having trouble documenting a predicate perhaps we need to go back to the design stage. 
     56</p> 
     57<p> 
     58Try to avoid lengthy hierarchies. Besides performance penalties, composition is often a better choice over inheritance for defining new objects (Logtalk supports component-based programming through the use of categories). In addition, prototype-based hierarchies are conceptually simpler and more efficient than class-based hierarchies. 
     59</p> 
     60<p> 
     61Dynamic predicates or dynamic entities are sometimes needed, but we should always try to minimize the use of non-logical features like destructive assignment (asserts and retracts). 
     62</p> 
     63<p> 
     64Since each Logtalk entity is independently compiled, if an object inherits a dynamic or a meta-predicate predicate, then we must repeat the respective directives in order to ensure a correct compilation.  
     65</p> 
     66<p> 
     67In general, Logtalk does not verify if a user predicate call/return arguments comply with the declared modes. On the other hand, Logtalk built-in predicates, built-in methods, and message sending control structures are carefully checked for calling mode errors. 
     68</p> 
     69<p> 
     70Logtalk error handling strongly depends on the ISO compliance of the chosen Prolog compiler. For instance, the error terms that are generated by some Logtalk built-in predicates assume that the Prolog built-in predicates behave as defined in the ISO standard regarding error conditions. In particular, if your Prolog compiler does not support a <code>read_term/3</code> built-in predicate compliant with the ISO Prolog Standard definition, then the current version of the Logtalk compiler may not be able to detect misspell variables in your source code. 
     71</p> 
     72 
     73<h3 id="programming_style">Coding style guidelines</h3> 
     74 
     75<p> 
     76It is suggested that all code between an entity opening and closing directives be indented by one tab stop. When defining entity code, both directives and predicates, Prolog coding style guidelines may be applied. All Logtalk source files, examples, and standard library entities use four-space tabs for laying out code. Closed related entities should be defined in the same source file. Entities that might be useful in different contexts (such as library entities) are best defined in their own source files. 
     77</p> 
     78 
     79 
     80<h2 id="programming_session">Running a Logtalk session</h2> 
     81 
     82<p> 
     83We run Logtalk inside a normal Prolog session, after loading the necessary files. Logtalk extends but does not modify your Prolog compiler. We can freely mix Prolog queries with the sending of messages and our programs can be made of both normal Prolog clauses and object definitions. 
     84</p> 
     85 
     86<h3 id="programming_starting">Starting Logtalk</h3> 
     87 
     88<p> 
     89Depending on your Logtalk installation, you may use a script or a shortcut to start Logtalk with your chosen Prolog compiler. On POSIX operating systems, the scripts should be available from the command-line; scripts are named upon the used Prolog compilers. On Windows, the shortcuts should be available from the Start Menu. If no scripts or shortcuts are available for your installation, operating-system, or Prolog compiler, you can always start a Logtalk session by performing the following steps: 
     90</p> 
     91<ol> 
     92    <li>Start your Prolog compiler.</li> 
     93    <li>Load the appropriate configuration file for your compiler. Configuration files for most common Prolog compilers can be found in the <code>configs</code> subdirectory.</li> 
     94    <li>Load the Logtalk compiler/runtime files contained in the <code>compiler</code> subdirectory.</li> 
     95    <li>Load the library paths configuration file corresponding to your Logtalk installation contained in the <code>libpaths</code> subdirectory.</li> 
     96</ol> 
     97<p> 
     98Note that the configuration files, compiler/runtime files, and library paths file are Prolog source files. The predicate called to load (and compile) them depends on your Prolog compiler. In case of doubt, consult your Prolog compiler reference manual or take a look at the definition of the predicate <code>'$lgt_load_prolog_code'/3</code> in the corresponding configuration file. 
     99</p> 
     100<p> 
     101Most Prolog compilers support automatic loading of an initialization file, which can include the necessary directives to load both the Prolog configuration file and the Logtalk compiler. This feature, when available, allows automatic loading of Logtalk when you start your Prolog compiler. 
     102</p> 
     103 
     104<h3 id="programming_compiling">Compiling and loading your programs</h3> 
     105 
     106<p> 
     107Your programs will be made of source files containing your objects, protocols, and categories. After changing the Prolog working directory to the one containing your files, you can compile them to disk by calling the Logtalk built-in predicate   
     108<a title="Consult reference manual" href="../refman/builtins/logtalk_compile1.html"><code>logtalk_compile/1</code></a>: 
     109</p> 
     110<pre>| ?- logtalk_compile([source_file1, source_file2, ...]).</pre> 
     111<p> 
     112This predicate runs the compiler on each argument file and, if no fatal errors are found, outputs Prolog source files that can then be consulted or compiled in the usual way by your Prolog compiler. 
     113</p> 
     114<p> 
     115To compile to disk and also load into memory the source files we can use the Logtalk built-in predicate <a title="Consult reference manual" href="../refman/builtins/logtalk_load1.html"><code>logtalk_load/1</code></a>: 
     116</p> 
     117<pre>| ?- logtalk_load([source_file1, source_file2, ...]).</pre> 
     118<p> 
     119This predicate works in the same way of the predicate <code>logtalk_compile/1</code> but also loads the compiled files to memory.  
     120</p> 
     121<p> 
     122Both predicates expect a source name name or a list of source name names as an argument. The Logtalk source file name extension, as defined in the configuration file, must be omitted. 
     123</p> 
     124<p> 
     125If you have more than a few source files then you may want to use a loader helper file containing the calls to the <code>logtalk_load/1-2</code> predicates. Consulting or compiling the loader file will then compile and load all your Logtalk entities into memory (see below for details). 
     126</p> 
     127<p> 
     128With most Prolog back-end compilers, you can use the shorthand <code>{File}</code> for <code>logtalk_load(File)</code>. The use this shorthand should be restricted to the Logtak/Prolog top-level; do not use it from within source files. 
    43129</p> 
    44130 
     
    96182</p> 
    97183 
    98 <h3 id="programming_portability">Portable programs</h3> 
    99  
    100 <p> 
    101 Logtalk is compatible with almost all modern Prolog compilers. However, this does not necessarily imply that your Logtalk programs will have the same level of portability. If possible, you should only use in your programs Logtalk built-in predicates and ISO Prolog specified built-in predicates and arithmetic functions. If you need to use built-in predicates (or built-in arithmetic functions) that may not be available in other Prolog compilers, you should try to encapsulate the non-portable code in a small number of objects and provide a portable <strong>interface</strong> for that code through the use of Logtalk protocols. An example will be code that access operating-system specific features. The Logtalk compiler can warn you of the use of non-ISO specified built-in predicates and arithmetic functions by using the <code>portability/1</code> compiler flag. 
    102 </p> 
    103  
    104 <h3 id="programming_errors">Avoiding common errors</h3> 
    105  
    106 <p> 
    107 Try to write objects and protocol documentation <strong>before</strong> writing any other code; if you are having trouble documenting a predicate perhaps we need to go back to the design stage. 
    108 </p> 
    109 <p> 
    110 Try to avoid lengthy hierarchies. Besides performance penalties, composition is often a better choice over inheritance for defining new objects (Logtalk supports component-based programming through the use of categories). In addition, prototype-based hierarchies are conceptually simpler and more efficient than class-based hierarchies. 
    111 </p> 
    112 <p> 
    113 Dynamic predicates or dynamic entities are sometimes needed, but we should always try to minimize the use of non-logical features like destructive assignment (asserts and retracts). 
    114 </p> 
    115 <p> 
    116 Since each Logtalk entity is independently compiled, if an object inherits a dynamic or a meta-predicate predicate, then we must repeat the respective directives in order to ensure a correct compilation.  
    117 </p> 
    118 <p> 
    119 In general, Logtalk does not verify if a user predicate call/return arguments comply with the declared modes. On the other hand, Logtalk built-in predicates, built-in methods, and message sending control structures are carefully checked for calling mode errors. 
    120 </p> 
    121 <p> 
    122 Logtalk error handling strongly depends on the ISO compliance of the chosen Prolog compiler. For instance, the error terms that are generated by some Logtalk built-in predicates assume that the Prolog built-in predicates behave as defined in the ISO standard regarding error conditions. In particular, if your Prolog compiler does not support a <code>read_term/3</code> built-in predicate compliant with the ISO Prolog Standard definition, then the current version of the Logtalk compiler may not be able to detect misspell variables in your source code. 
    123 </p> 
    124  
    125 <h3 id="programming_style">Coding style guidelines</h3> 
    126  
    127 <p> 
    128 It is suggested that all code between an entity opening and closing directives be indented by one tab stop. When defining entity code, both directives and predicates, Prolog coding style guidelines may be applied. All Logtalk source files, examples, and standard library entities use four-space tabs for laying out code. Closed related entities should be defined in the same source file. Entities that might be useful in different contexts (such as library entities) are best defined in their own source files. 
    129 </p> 
    130  
    131  
    132 <h2 id="programming_scope">Logtalk scope</h2> 
    133  
    134 <p> 
    135 Logtalk, being a superset of Prolog, shares with it the same preferred areas of application but also extends them with those areas where object-oriented features provide an advantage compared to plain Prolog. Among these areas we have: 
     184<h3 id="programming_flags">Compiler flags</h3> 
     185 
     186<p> 
     187The <a title="Consult reference manual" href="../refman/builtins/logtalk_load1.html"><code>logtalk_load/1</code></a> and <a title="Consult reference manual" href="../refman/builtins/logtalk_compile1.html"><code>logtalk_compile/1</code></a> always use the current set of default compiler flags as specified in the Logtalk configuration files or changed for the current session using the built-in predicate <a title="Consult reference manual" href="../refman/builtins/set_logtalk_flag2.html"><code>set_logtalk_flag/2</code></a>. Although the default flag values cover the usual cases, you may want to use a different set of flag values while compiling or loading some of your Logtalk source files. This can be accomplished by using the <a title="Consult reference manual" href="../refman/builtins/logtalk_load2.html"><code>logtalk_load/2</code></a> or the <a title="Consult reference manual" href="../refman/builtins/logtalk_compile2.html"><code>logtalk_compile/2</code></a> built-in predicates. These two predicates accept a list of flag values affecting how a Logtalk source file is compiled and loaded: 
     188</p> 
     189<pre>| ?- logtalk_compile(Files, Flags).</pre> 
     190<p> 
     191or: 
     192</p> 
     193<pre>| ?- logtalk_load(Files, Flags).</pre> 
     194<p> 
     195In fact, the <code>logtalk_load/1</code> and <code>logtalk_compile/1</code> predicates are just shortcuts to the extended versions called with the default compiler flag values. 
     196</p> 
     197<p> 
     198We may also change the default flag values from the ones loaded from the config file by using the <a title="Consult reference manual" href="../refman/builtins/set_logtalk_flag2.html"><code>set_logtalk_flag/2</code></a> built-in predicate. For example: 
     199</p> 
     200<pre>| ?- set_logtalk_flag(xmldocs, off).</pre> 
     201<p> 
     202The current default flags values can be enumerated using the <a title="Consult reference manual" href="../refman/builtins/current_logtalk_flag2.html"><code>current_logtalk_flag/2</code></a> built-in predicate: 
     203</p> 
     204<pre>| ?- current_logtalk_flag(xmldocs, Value). 
     205 
     206Value = off 
     207yes</pre> 
     208<p> 
     209Logtalk also implements a <a title="Consult reference manual" href="../refman/directives/set_logtalk_flag2.html"><code>set_logtalk_flag/2</code></a> directive, which can be used to set flags within a source file. For example, assuming a source file defining several entities, you may want to use different settings for compiling each entity. This can be easily accomplished by preceding each entity with the necessary <code>set_logtalk_flag/2</code> directives. Note that the scope of this directive is local to the source file containing it. 
     210<p> 
     211 
     212<h4>Lint flags</h4> 
     213 
     214    <dl> 
     215        <dt><code>unknown(Option)</code></dt> 
     216            <dd>Controls the unknown entity warnings, resulting from loading an entity that references some other entity that is not currently loaded. Possible option values are <code>warning</code> (the usual default) and <code>silent</code>. Note that these warnings are not always avoidable, specially when using reflective designs of class-based hierarchies.</dd> 
     217    </dl> 
     218    <dl> 
     219        <dt><code>misspelt(Option)</code></dt> 
     220            <dd>Controls the misspelt predicate call warnings. A misspelt call is a call to a predicate which is not defined in the object or category containing the call, is not declared as dynamic, and is not a Logtalk/Prolog built-in predicate. Possible option values are <code>error</code>, <code>warning</code> (the usual default), and <code>silent</code> (not recommended).</dd> 
     221    </dl> 
     222    <dl> 
     223        <dt><code>lgtredef(Option)</code></dt> 
     224            <dd>Controls the Logtalk built-in predicate redefinition warnings. Possible option values are <code>warning</code> (the usual default) and <code>silent</code>. These warnings are almost always programming errors.</dd> 
     225    </dl> 
     226    <dl> 
     227        <dt><code>plredef(Option)</code></dt> 
     228            <dd>Controls the Prolog built-in predicate redefinition warnings. Possible option values are <code>warning</code> (can be very verbose if your code redefines a lot of Prolog built-in predicates) and <code>silent</code> (the usual default). When running a Logtalk application on several Prolog compilers, is possible to get different sets of warnings due to different sets of built-in predicates implemented by each Prolog compiler.</dd> 
     229    </dl> 
     230    <dl> 
     231        <dt><code>portability(Option)</code></dt> 
     232            <dd>Controls the non-ISO specified built-in predicate and non-ISO specified built-in arithmetic function calls warnings. Possible option values are <code>warning</code> and <code>silent</code> (the usual default).</dd> 
     233    </dl> 
     234    <dl> 
     235        <dt><code>singletons(Option)</code></dt> 
     236            <dd>Controls the singleton variable warnings. Possible option values are <code>warning</code> (the usual default) and <code>silent</code> (not recommended).</dd> 
     237    </dl> 
     238    <dl> 
     239        <dt><code>underscore_variables(Option)</code></dt> 
     240            <dd>Controls the interpretation of variables that start with an underscore (excluding the anonymous variable) that occur once in a term as either don't care variables or singleton variables. Possible option values are <code>dont_care</code> and <code>singletons</code> (the usual default). Note that, depending on your Prolog compiler, the <code>read_term/3</code> built-in predicate may report variables that start with an underscore as singleton variables. There is no standard behavior, hence this option.</dd> 
     241    </dl> 
     242 
     243 
     244<h4>Documenting flags</h4> 
     245 
     246    <dl> 
     247        <dt><code>xmldocs(Option)</code></dt> 
     248            <dd>Controls the automatic generation of documenting files in XML format. Possible option values are <code>on</code> (the usual default) and <code>off</code>.</dd> 
     249    </dl> 
     250    <dl>