| 1 | ================================================================ |
|---|
| 2 | Logtalk - Open source object-oriented logic programming language |
|---|
| 3 | Release 2.31.1 |
|---|
| 4 | |
|---|
| 5 | Copyright (c) 1998-2008 Paulo Moura. All Rights Reserved. |
|---|
| 6 | ================================================================ |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | This folder contains several examples of Logtalk programs. A brief |
|---|
| 10 | description of each example is included below. |
|---|
| 11 | |
|---|
| 12 | Each example folder contains a "NOTES.txt" file and a loader helper |
|---|
| 13 | file that may be used to load all the example entities. In addition, |
|---|
| 14 | most examples contain a "SCRIPT.txt" file with instructions on how to |
|---|
| 15 | load the example and sample queries for your to try. |
|---|
| 16 | |
|---|
| 17 | Most of these examples need objects, protocols, and categories that |
|---|
| 18 | are defined in the Logtalk standard library or in other examples. See |
|---|
| 19 | the "NOTES.txt" files inside the library folder, plus the "NOTES.txt" |
|---|
| 20 | and "SCRIPT.txt" files inside each example folder. |
|---|
| 21 | |
|---|
| 22 | Some examples may redefine objects already loaded from other examples. |
|---|
| 23 | You may want to restart Logtalk after trying each example. |
|---|
| 24 | |
|---|
| 25 | Some of the examples have been adopted from public available Prolog |
|---|
| 26 | code or from known Prolog text books and are copyrighted by the respective |
|---|
| 27 | authors. |
|---|
| 28 | |
|---|
| 29 | These are programming examples, meaning that you should study the source |
|---|
| 30 | files to fully understand them. However, note that some examples purpose |
|---|
| 31 | is to illustrate general principles rather than being adequate, efficient |
|---|
| 32 | solutions for deployment code. |
|---|
| 33 | |
|---|
| 34 | All examples are formatted using four spaces tabs. |
|---|
| 35 | |
|---|
| 36 | By default, compiling an example generates a XML documenting file for |
|---|
| 37 | each compiled entity (object, category, or protocol). See the "xml" |
|---|
| 38 | folder for instructions on how to browse the XML files for on-line |
|---|
| 39 | reading or how to convert the files to a print-ready format such as PDF. |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | Here is a short description of each included example: |
|---|
| 43 | |
|---|
| 44 | aliases |
|---|
| 45 | example of using the alias/3 predicate directive to provide |
|---|
| 46 | alternative names to inherited predicates in order to improve |
|---|
| 47 | readability or to solve multi-inheritance conflicts |
|---|
| 48 | |
|---|
| 49 | assignvars |
|---|
| 50 | example of using assignable variables in the context of parametric |
|---|
| 51 | objects in order to represent object state |
|---|
| 52 | |
|---|
| 53 | benchmarks |
|---|
| 54 | simple benchmarks for helping measuring performance of Logtalk |
|---|
| 55 | message sending between Prolog compilers and for comparing |
|---|
| 56 | performance of message sending calls with predicate calls in |
|---|
| 57 | plain Prolog |
|---|
| 58 | |
|---|
| 59 | birds |
|---|
| 60 | bird identification expert system |
|---|
| 61 | (example adopted from the Adventure in Prolog Amzi! book) |
|---|
| 62 | |
|---|
| 63 | bottles |
|---|
| 64 | 99 bottles of beer on the wall! Sing along! |
|---|
| 65 | |
|---|
| 66 | bricks |
|---|
| 67 | example of representation and handling of relations using events; |
|---|
| 68 | illustrates how to use events to avoid breaking object encapsulation |
|---|
| 69 | |
|---|
| 70 | complements |
|---|
| 71 | example of using a category to explicitly complement an existing |
|---|
| 72 | object |
|---|
| 73 | |
|---|
| 74 | classvars |
|---|
| 75 | example of implementation of class variables |
|---|
| 76 | (as found in Smalltalk; i.e. shared instance variables) |
|---|
| 77 | |
|---|
| 78 | dcgs |
|---|
| 79 | examples of using DCG rules inside objects and categories |
|---|
| 80 | |
|---|
| 81 | diamonds |
|---|
| 82 | examples of problems and solutions for the "diamond problem" |
|---|
| 83 | (multi-inheritance conflicts and ambiguities) |
|---|
| 84 | |
|---|
| 85 | dynpred |
|---|
| 86 | example of using some of the built-in database handling methods |
|---|
| 87 | in order to implement dynamic object state |
|---|
| 88 | |
|---|
| 89 | encodings |
|---|
| 90 | very simple example of using the new, experimental encoding/1 |
|---|
| 91 | directive (requires Logtalk to be run with the SWI-Prolog compiler) |
|---|
| 92 | |
|---|
| 93 | engines |
|---|
| 94 | example of category composition (importation of categories by |
|---|
| 95 | other categories) using car engines |
|---|
| 96 | |
|---|
| 97 | errors |
|---|
| 98 | example showing the Logtalk compiler warning and error reporting |
|---|
| 99 | for common programming errors |
|---|
| 100 | |
|---|
| 101 | hello_world |
|---|
| 102 | the unavoidable "hello world" programming example |
|---|
| 103 | |
|---|
| 104 | hooks |
|---|
| 105 | simple example of using compiler hook objects and predicates |
|---|
| 106 | |
|---|
| 107 | inheritance |
|---|
| 108 | examples of public, protected, and private inheritance using both |
|---|
| 109 | prototypes and classes/instances |
|---|
| 110 | |
|---|
| 111 | instmethods |
|---|
| 112 | example of instance defined methods; also illustrates the use of |
|---|
| 113 | "super calls" to call overridden method definitions |
|---|
| 114 | |
|---|
| 115 | lo |
|---|
| 116 | examples adopted from the Francis G. McCabe L&O system |
|---|
| 117 | |
|---|
| 118 | logic |
|---|
| 119 | example of a translator of first-order predicate logic propositions |
|---|
| 120 | to conjunctive normal form and to clausal form |
|---|
| 121 | |
|---|
| 122 | lpa |
|---|
| 123 | examples adopted from the LPA Prolog++ system |
|---|
| 124 | |
|---|
| 125 | metapredicates |
|---|
| 126 | example of using meta-predicates in Logtalk objects |
|---|
| 127 | |
|---|
| 128 | metainterpreters |
|---|
| 129 | some examples of simple meta-interpreters defined as categories |
|---|
| 130 | that can be imported by "database" objects |
|---|
| 131 | |
|---|
| 132 | mi |
|---|
| 133 | simple multi-inheritance examples |
|---|
| 134 | |
|---|
| 135 | miscellaneous |
|---|
| 136 | unsorted examples |
|---|
| 137 | |
|---|
| 138 | modules |
|---|
| 139 | simple example of compiling Prolog module files as objects |
|---|
| 140 | |
|---|
| 141 | msglog |
|---|
| 142 | example of using events and monitors for recording, replaying, |
|---|
| 143 | and printing user messages |
|---|
| 144 | |
|---|
| 145 | operators |
|---|
| 146 | example of using operators local to objects and categories |
|---|
| 147 | |
|---|
| 148 | parametric |
|---|
| 149 | simple example of parametric objects |
|---|
| 150 | |
|---|
| 151 | poem |
|---|
| 152 | examples adopted from the Ben Staveley-Taylor POEM system |
|---|
| 153 | |
|---|
| 154 | points |
|---|
| 155 | example adopted from SICStus Objects documentation; defines |
|---|
| 156 | a simple class hierarchy of points illustrating how to use |
|---|
| 157 | categories as object components |
|---|
| 158 | |
|---|
| 159 | polygons |
|---|
| 160 | example of representation and handling of relations using events |
|---|
| 161 | |
|---|
| 162 | profiling |
|---|
| 163 | examples of using of events and monitors to implement profilers |
|---|
| 164 | |
|---|
| 165 | proxies |
|---|
| 166 | example of using parametric object proxies for an efficient |
|---|
| 167 | representation of objects with read-only state |
|---|
| 168 | |
|---|
| 169 | puzzles |
|---|
| 170 | several examples of logical puzzles |
|---|
| 171 | |
|---|
| 172 | reflection |
|---|
| 173 | example of a simple class-based reflective system |
|---|
| 174 | |
|---|
| 175 | relations |
|---|
| 176 | objects implementing predicates for dealing with relations and |
|---|
| 177 | constrained relations between objects; used by other examples |
|---|
| 178 | |
|---|
| 179 | roots |
|---|
| 180 | objects, protocols, and categories needed by most of the other |
|---|
| 181 | examples; illustrates how you can define object creation and |
|---|
| 182 | abolishing methods, complete with initialization and termination |
|---|
| 183 | options |
|---|
| 184 | |
|---|
| 185 | searching |
|---|
| 186 | state-space searching framework |
|---|
| 187 | (example adopted from Ivan Bratko's "Prolog Programming for |
|---|
| 188 | Artificial Intelligence" book) |
|---|
| 189 | |
|---|
| 190 | shapes |
|---|
| 191 | simple geometric shapes implemented as both a prototype hierarchy |
|---|
| 192 | and a class hierarchy |
|---|
| 193 | |
|---|
| 194 | sicstus |
|---|
| 195 | examples adopted from SICStus Objects documentation |
|---|
| 196 | |
|---|
| 197 | symdiff |
|---|
| 198 | example of using parametric objects to implement symbolic |
|---|
| 199 | expression differentiation and simplification |
|---|
| 200 | |
|---|
| 201 | tabling |
|---|
| 202 | simple example of using tabling directives within objects |
|---|
| 203 | |
|---|
| 204 | testing |
|---|
| 205 | some examples of writing unit tests |
|---|
| 206 | |
|---|
| 207 | threads |
|---|
| 208 | several simple examples of multi-threading programming, some of |
|---|
| 209 | them intended only for benchmarking multi-threading Prolog compilers |
|---|
| 210 | (requires Logtalk to be run with either YAP, SWI-Prolog, or XSB) |
|---|
| 211 | |
|---|
| 212 | viewpoints |
|---|
| 213 | example on how to implement property sharing and value sharing |
|---|
| 214 | with prototypes |
|---|