diff --git a/Logtalk/BIBLIOGRAPHY.bib b/Logtalk/BIBLIOGRAPHY.bib deleted file mode 100644 index 9b0437ebe..000000000 --- a/Logtalk/BIBLIOGRAPHY.bib +++ /dev/null @@ -1,97 +0,0 @@ - -@misc{logtalkweb, - author = "Paulo Moura", - title = "Logtalk web site", - howpublished = "\url{http://logtalk.org/}" -} - - -@inproceedings{pmoura07, - author = "Paulo Moura and Paul Crocker and Paulo Nunes", - title = "{Multi-threading programming in Logtalk}", - crossref = "ciclops07", - pages = "87--101", -} - - -@proceedings{ciclops07, - title = "7th Colloquium on Implementation of Constraint LOgic Programming Systems", - publisher = "University of Oporto", - address = "Oporto, Portugal", - editor = "Salvador Abreu and Vitor Santos Costa", - month = sep, - year = 2007 -} - - -@inproceedings{pmoura06, - author = "Paulo Moura and Vincent Marchetti", - title = "{Logtalk Processing of STEP Part 21 Files}", - crossref = "iclp06", - pages = "453--454", -} - - -@proceedings{iclp06, - title = "International Conference on Logic Programming 2006", - booktitle = "International Conference on Logic Programming 2006", - series = "Lecture Notes in Computer Science", - publisher = "Springer-Verlag", - address = "Berlin Heidelberg", - editor = "S. Etalle and M. Truszczy\'nski", - number = 4079, - month = aug, - year = 2006 -} - - -@phdthesis{pmoura03, - author = "Paulo Moura", - title = "{Logtalk - Design of an Object-Oriented Logic Programming Language}", - school = "Department of Computer Science, University of Beira Interior, Portugal", - month = sep, - year = 2003, - howpublished = "\url{http://logtalk.org/papers/thesis.pdf}" -} - - -@unpublished{pmoura00c, - Author = "Paulo Moura", - Title = "{Category-Based Composition in Object-Oriented Languages}", - month = nov, - year = 2000, - howpublished = "\url{http://logtalk.org/papers/categories_ecoop.pdf}", - annote = "Submitted to ECOOP 2001" -} - - -@techreport{pmoura00b, - author = "Paulo Moura", - title = "{Logtalk 2.6 Documentation}", - institution = "University of Beira Interior, Portugal", - number = "DMI 2000/1", - month = jul, - year = 2000, - howpublished = "\url{http://logtalk.org/files/trdmi20001a4.pdf.gz}" -} - - -@unpublished{pmoura00a, - Author = "Paulo Moura", - Title = "{Category-Based Composition in Object-Oriented Languages}", - month = apr, - year = 2000, - howpublished = "\url{http://logtalk.org/papers/categories_oopsla.pdf}", - annote = "Submitted to OOPSLA 2000" -} - - -@article{pmoura99, - author = "Paulo Moura", - title = "{Porting Prolog: Notes on porting a Prolog program to 22 Prolog compilers or the relevance of the ISO Prolog standard}", - journal = "Association of Logic Programming Newsletter", - volume = 12, - number = 2, - month = may, - year = 1999 -} diff --git a/Logtalk/CUSTOMIZE.txt b/Logtalk/CUSTOMIZE.txt deleted file mode 100644 index a7ffb2768..000000000 --- a/Logtalk/CUSTOMIZE.txt +++ /dev/null @@ -1,63 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.8 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This file contains detailed instructions for customizing your Logtalk -installation and working environment. Customization is mostly done on -a per-user basis by editing files on the Logtalk user folder (whose -path is stored on the LOGTALKUSER environment variable; the folder itself -can be created by running the "cplgtdirs" shell command). - - -1. SETTING LIBRARY PATHS - -In Logtalk, a library is simply a directory containing source files. Library -paths can be declared using a dynamic predicate. This allows compiling and -loading of libraries and library files to be performed without worries about -library paths. - -Inside your Logtalk user folder, you will find a "libpaths" folder containing -a sample file which, when loaded, defines the library paths for the Logtalk -standard library and for all the supplied examples. This file may need to be -edited to match both your Logtalk installation and your Prolog compiler and -operating-system requirements. For details, see the "libpaths/NOTES.txt" file. - - -2. CUSTOMIZING PROLOG CONFIGURATION FILES - -Logtalk interfaces with a specific Prolog compiler via a configuration file -that can be found on the "configs" folder inside your Logtalk user folder. -These configuration files can be customized by changing the default values -of the flags that are used by Logtalk when compiling source files. For a -full description of these flags, consult the "Running and debugging Logtalk -programs" section of the User Manual. Some of the default flags that you may -want to change include: "smart_compilation", "startup_message", "altdirs", -"tmpdir", "portability", "underscore_variables", and the documentation-related -flags ("xmldocs", "xmldir", "xslfile", "xmlspec", and "xmlsref"). Be sure -to read the "configs/NOTES.txt" file for Prolog specific notes; some Prolog -compilers do not support the whole range of compilation flag values. - - -3. CUSTOMIZING DOCUMENTATION PROCESSING SCRIPTS AND SUPPORTING FILES - -Inside your Logtalk user folder, you will find a "xml" folder containing a -set of shell scripts, CSS and XSLT style-sheets, and DTD and XML Schema files -for processing the XML documenting files that are automatically generated -when you compile source files. You may want to customize the CSS and XSLT -files to modify the layout or style of the resulting PDF/(X)HTML files or to -write new scripts and transformations to generate other formats. You may also -edit the file "custom.ent" in order to specify XML entities for your personal -data that can be used on Logtalk documenting directives. For details, see the -"xml/NOTES.txt" file. - - -4. ADDING SUPPORT FOR EDITING LOGTALK SOURCE FILES TO TEXT EDITORS - -Inside your Logtalk user folder, you will find a "wenv" folder, containing -configuration files for several text editors, which add support for syntax -highlighting and other text editing services for Logtalk source files. -For details, see the "wenv/NOTES.txt" file. diff --git a/Logtalk/INSTALL.txt b/Logtalk/INSTALL.txt deleted file mode 100644 index 6d6a184dd..000000000 --- a/Logtalk/INSTALL.txt +++ /dev/null @@ -1,153 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.8 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -The recommended way of installing Logtalk is to use, whenever possible, one -of the provided installers. This file contains detailed instructions for -manual installation and configuration of Logtalk. You should also consult -the "scripts/NOTES.txt" and "integration/NOTES.txt" files for a description -of a set of shell scripts that might be used for Logtalk installation on -some operating-systems and for easy Logtalk integration with popular Prolog -compilers. - -Note that the broad compatibility of Logtalk, both with Prolog compilers and -operating-systems, together with all the possible user scenarios, means that -installation can vary from very simple by running a couple of scripts to the -need of patching both Logtalk and Prolog compilers to workaround the lack of -strong Prolog standards. - - -1. LOGTALK BASIC INSTALLATION - -Installing Logtalk can be as simple as decompressing the downloaded archive -and copying the resulting directory to a suitable location. This location -depends on the working environment and on the number of users. The Logtalk -directory can reside in any user accessible location. Whenever possible, it -is recommended that Logtalk be installed by a user with administrative rights, -as described below. This leads to a setup where each Logtalk user may freely -try and modify the provided examples, library, and configuration files with -the option of, at any time, restoring the files to its original state by -simply running one of the provided scripts. - - -* Installing for a single user with no administrative rights: - -In the case of a single user with no administrative rights, the Logtalk -directory may simply be copied to the user home directory. - - -* Installing for one or more users by a user with administrative rights: - -In the case of installation by a user with administrative rights, the Logtalk -directory can be copied to any location that its accessible by all the users -(assuming that copying the Logtalk directory to each user home directory is, -for some reason, not feasible or desired). - -The "scripts" sub-directory contains shell scripts for easy installation of -Logtalk on POSIX operating systems (see the "scripts/NOTES.txt" file for -details). Starting from the Logtalk directory, type: - - % cd scripts - % sudo ./install.sh - -This installation script makes all files read-only for non-admin users in -order to avoid user tempering. This is a convenient setup for computer labs, -given that making directories world-writable is a security risk. - - -2. SETTING LOGTALK ENVIRONMENT VARIABLES - -You need to set two environment variables, LOGTALKHOME and LOGTALKUSER. The -environment variable LOGTALKHOME should be set to the Logtalk installation -directory. The environment variable LOGTALKUSER should point to a directory -in your home directory where you want to store the user-specific Logtalk files -(by default, ~/logtalk). Both environment variables may be set for all users -by a user with administration privileges. The two environment variables can -have the same value if you are the only Logtalk user on your computer and if -you have full permissions to the Logtalk installation directory. In addition, -you may want to add the Logtalk sub-directory "xml", which contains useful -scripts for processing XML documenting files, to your execution path. - ->> POSIX systems: - -If you use a csh shell, add the following line to your ~/.cshrc file: - - setenv LOGTALKHOME /your/logtalk/installation/directory - setenv LOGTALKUSER $HOME/logtalk - setenv PATH $PATH:$LOGTALKHOME/xml:$LOGTALKHOME/scripts - -If you use a bash shell, add the following lines to your ~/.profile file: - - LOGTALKHOME=/your/logtalk/installation/directory - LOGTALKUSER=$HOME/logtalk - PATH=$PATH:$LOGTALKHOME/xml:$LOGTALKHOME/scripts - export PATH LOGTALKHOME LOGTALKUSER - -When using the provided shell script for installing Logtalk, a symbolic link -to the Logtalk installation directory is automatically created. The link is -named "logtalk". In this case, you may use this symbolic link to define the -LOGTALKHOME environment variable in order to avoid breaking it when upgrading -Logtalk. - ->> Windows systems: - -In Windows 2000/XP, environment variables are defined using the System -properties control panel. If you are a system administrator, the Windows -GUI installer sets the LOGTALKHOME environment variable for all users and -also sets the LOGTALKUSER environment variable for the administrator user -running the installer. - - -3. END-USER SETUP (COPYING LOGTALK USER-MODIFIABLE FILES TO USERS HOME DIRS) - -If you installed Logtalk on your home directory, then skip this step if you -have set both Logtalk environment variables (LOGTALKHOME and LOGTALKUSER) to -point to the same directory. - -Each user must make a local copy of the Logtalk user-modifiable files to its -home directory. This setup allows each user to easily and independently -customize Logtalk to its needs. These copies can be easily made by instructing -end-users to simply run the shell scripts "cplgtdirs.*" (which are described -in the "scripts/NOTES.txt" file). - ->> POSIX systems: - - % cplgtdirs - ->> Windows: - - C:\> cplgtdirs - -The local copies made by the "cplgtdirs" scripts have both read and write -permissions for the user running the script. When used with one of the -back-end Prolog compilers for which an integration script is provided on -the "integration" directory, this setup as the advantage of allowing each -end-user to independently customize default compilation options and library -paths. - -Windows (non-admin) users may also use the Logtalk GUI installer to setup -their Logtalk user folder and the LOGTALKUSER environment variable. - - -4. CREATING NEW PROLOG TOP-LEVELS FOR AUTOMATIC LOADING OF LOGTALK - -Most Prolog compilers allows the user to define an initialization file -that is automatically consulted at startup. These initialization files -may contain directives for loading other files, such as the Logtalk -configuration file and the Logtalk compiler. The "$LOGTALKHOME/integration" -sub-directory contains several pre-made scripts (named "*lgt.*") for running -Logtalk with selected back-end Prolog compilers. You can use these scripts -as examples when creating initialization files for other Prolog compilers. -Be sure to read the "configs/NOTES.txt" file notes on the Prolog compilers -that you intend to use. You may also simply follow the steps described in -the "QUICK_START.txt" file. - - -5. CUSTOMIZING LOGTALK - -Please see the file "CUSTOMIZE.txt" for details on how to customize your -Logtalk installation and working environment. \ No newline at end of file diff --git a/Logtalk/LICENSE.txt b/Logtalk/LICENSE.txt deleted file mode 100644 index ddb9a463f..000000000 --- a/Logtalk/LICENSE.txt +++ /dev/null @@ -1,201 +0,0 @@ - The Artistic License 2.0 - - Copyright (c) 2000-2006, The Perl Foundation. - - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -Preamble - -This license establishes the terms under which a given free software -Package may be copied, modified, distributed, and/or redistributed. -The intent is that the Copyright Holder maintains some artistic -control over the development of that Package while still keeping the -Package available as open source and free software. - -You are always permitted to make arrangements wholly outside of this -license directly with the Copyright Holder of a given Package. If the -terms of this license do not permit the full use that you propose to -make of the Package, you should contact the Copyright Holder and seek -a different licensing arrangement. - -Definitions - - "Copyright Holder" means the individual(s) or organization(s) - named in the copyright notice for the entire Package. - - "Contributor" means any party that has contributed code or other - material to the Package, in accordance with the Copyright Holder's - procedures. - - "You" and "your" means any person who would like to copy, - distribute, or modify the Package. - - "Package" means the collection of files distributed by the - Copyright Holder, and derivatives of that collection and/or of - those files. A given Package may consist of either the Standard - Version, or a Modified Version. - - "Distribute" means providing a copy of the Package or making it - accessible to anyone else, or in the case of a company or - organization, to others outside of your company or organization. - - "Distributor Fee" means any fee that you charge for Distributing - this Package or providing support for this Package to another - party. It does not mean licensing fees. - - "Standard Version" refers to the Package if it has not been - modified, or has been modified only in ways explicitly requested - by the Copyright Holder. - - "Modified Version" means the Package, if it has been changed, and - such changes were not explicitly requested by the Copyright - Holder. - - "Original License" means this Artistic License as Distributed with - the Standard Version of the Package, in its current version or as - it may be modified by The Perl Foundation in the future. - - "Source" form means the source code, documentation source, and - configuration files for the Package. - - "Compiled" form means the compiled bytecode, object code, binary, - or any other form resulting from mechanical transformation or - translation of the Source form. - - -Permission for Use and Modification Without Distribution - -(1) You are permitted to use the Standard Version and create and use -Modified Versions for any purpose without restriction, provided that -you do not Distribute the Modified Version. - - -Permissions for Redistribution of the Standard Version - -(2) You may Distribute verbatim copies of the Source form of the -Standard Version of this Package in any medium without restriction, -either gratis or for a Distributor Fee, provided that you duplicate -all of the original copyright notices and associated disclaimers. At -your discretion, such verbatim copies may or may not include a -Compiled form of the Package. - -(3) You may apply any bug fixes, portability changes, and other -modifications made available from the Copyright Holder. The resulting -Package will still be considered the Standard Version, and as such -will be subject to the Original License. - - -Distribution of Modified Versions of the Package as Source - -(4) You may Distribute your Modified Version as Source (either gratis -or for a Distributor Fee, and with or without a Compiled form of the -Modified Version) provided that you clearly document how it differs -from the Standard Version, including, but not limited to, documenting -any non-standard features, executables, or modules, and provided that -you do at least ONE of the following: - - (a) make the Modified Version available to the Copyright Holder - of the Standard Version, under the Original License, so that the - Copyright Holder may include your modifications in the Standard - Version. - - (b) ensure that installation of your Modified Version does not - prevent the user installing or running the Standard Version. In - addition, the Modified Version must bear a name that is different - from the name of the Standard Version. - - (c) allow anyone who receives a copy of the Modified Version to - make the Source form of the Modified Version available to others - under - - (i) the Original License or - - (ii) a license that permits the licensee to freely copy, - modify and redistribute the Modified Version using the same - licensing terms that apply to the copy that the licensee - received, and requires that the Source form of the Modified - Version, and of any works derived from it, be made freely - available in that license fees are prohibited but Distributor - Fees are allowed. - - -Distribution of Compiled Forms of the Standard Version -or Modified Versions without the Source - -(5) You may Distribute Compiled forms of the Standard Version without -the Source, provided that you include complete instructions on how to -get the Source of the Standard Version. Such instructions must be -valid at the time of your distribution. If these instructions, at any -time while you are carrying out such distribution, become invalid, you -must provide new instructions on demand or cease further distribution. -If you provide valid instructions or cease distribution within thirty -days after you become aware that the instructions are invalid, then -you do not forfeit any of your rights under this license. - -(6) You may Distribute a Modified Version in Compiled form without -the Source, provided that you comply with Section 4 with respect to -the Source of the Modified Version. - - -Aggregating or Linking the Package - -(7) You may aggregate the Package (either the Standard Version or -Modified Version) with other packages and Distribute the resulting -aggregation provided that you do not charge a licensing fee for the -Package. Distributor Fees are permitted, and licensing fees for other -components in the aggregation are permitted. The terms of this license -apply to the use and Distribution of the Standard or Modified Versions -as included in the aggregation. - -(8) You are permitted to link Modified and Standard Versions with -other works, to embed the Package in a larger work of your own, or to -build stand-alone binary or bytecode versions of applications that -include the Package, and Distribute the result without restriction, -provided the result does not expose a direct interface to the Package. - - -Items That are Not Considered Part of a Modified Version - -(9) Works (including, but not limited to, modules and scripts) that -merely extend or make use of the Package, do not, by themselves, cause -the Package to be a Modified Version. In addition, such works are not -considered parts of the Package itself, and are not subject to the -terms of this license. - - -General Provisions - -(10) Any use, modification, and distribution of the Standard or -Modified Versions is governed by this Artistic License. By using, -modifying or distributing the Package, you accept this license. Do not -use, modify, or distribute the Package, if you do not accept this -license. - -(11) If your Modified Version has been derived from a Modified -Version made by someone other than you, you are nevertheless required -to ensure that your Modified Version complies with the requirements of -this license. - -(12) This license does not grant you the right to use any trademark, -service mark, tradename, or logo of the Copyright Holder. - -(13) This license includes the non-exclusive, worldwide, -free-of-charge patent license to make, have made, use, offer to sell, -sell, import and otherwise transfer the Package with respect to any -patent claims licensable by the Copyright Holder that are necessarily -infringed by the Package. If you institute patent litigation -(including a cross-claim or counterclaim) against any party alleging -that the Package constitutes direct or contributory patent -infringement, then this Artistic License to you shall terminate on the -date that such litigation is filed. - -(14) Disclaimer of Warranty: -THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS -IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL -LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF -ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Logtalk/QUICK_START.txt b/Logtalk/QUICK_START.txt deleted file mode 100644 index ba92a07dc..000000000 --- a/Logtalk/QUICK_START.txt +++ /dev/null @@ -1,127 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.8 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -Quick start -=========== - - -Starting up Logtalk -------------------- - -1. Install Logtalk by using either the installer provided for your -operating-system (when available) or by following the instructions -on the "INSTALL.txt" file. Depending on your operating-system, working -environment, and favorite Prolog compiler, you may already have a -script or a shortcut installed for easily running Logtalk with your -favorite Prolog compiler. In this case, skip the instructions below -for starting up Logtalk and go straight to the instructions on running -the examples. - -On POSIX operating-systems, the following shell scripts are installed -by default for running Logtalk with selected back-end Prolog compilers -(which must be properly installed for running the scripts!): - - B-Prolog: bplgt (first run must use sudo) - CIAO: ciaolgt (first run must use sudo) - CxProlog: cxlgt - ECLiPSe: eclipselgt - GNU Prolog: gplgt - K-Prolog: plclgt - SICStus Prolog: sicstuslgt - SWI-Prolog: swilgt - XSB: xsblgt (first run must use sudo) - YAP: yaplgt - -On Windows systems, shortcuts for running Logtalk with selected back-end -Prolog compilers are created on the "Start Menu/Programs/Logtalk" menu. -If you get an unexpected failure when using one of the Prolog integration -scripts, consult the "configs/NOTES.txt" file for compatibility notes. - -2. Open the "manuals/index.html" file with a web browser. - -3. Select the "Tutorial" link. This will provide you with a basic -understanding of the main Logtalk concepts. - -4. Go back to the "index.html" file, select the "User Manual" link, -then the "Installing Logtalk" and "Running and debugging Logtalk -programs" links. This will provide you with a basic understanding of -how to start Logtalk as well as how to compile and load Logtalk code. - - -In case a manual installation is necessary, and assuming that Logtalk -supports your Prolog compiler, apply the following steps: - -1. Read the "NOTES.txt" file in the "configs" sub-directory to check if -any patch or workaround is needed for your compiler. - -2. Start your Prolog compiler. - -3. Change the current working directory of your Prolog session to the -Logtalk installation directory. If you don't know which predicate to -use, check the "configs/NOTES.txt" file or your Prolog compiler reference -manual. - -4. Compile and load the config file for your Prolog compiler. - -5. Compile and load the Logtalk compiler/runtime found on the "compiler" -sub-directory. - -6. Adapt, if needed, the file "libpaths/libpaths.pl" to match your Logtalk -installation, Prolog compiler, operating-system, and then compile and -load it. - -Note that both the configuration files, the compiler/runtime files, and the -library paths file are Prolog files. The predicate used to load these files -depends on your Prolog compiler (consult your Prolog compiler documentation -or take a look at the definition of the predicate '$lgt_load_prolog_code'/1 -in the config file. For most command-line compilers, you could type at the -Prolog prompt something like: - - | ?- ['configs/foo.config', 'compiler/logtalk.pl', 'libpaths/libpaths.pl']. - -Replace the file name "foo.config" with the appropriate config file name for -your compiler. - - -Running the examples --------------------- - -You may now try some of the provided examples: - -1. Open the "examples" sub-directory. There you find several sub-directories -with ready to run examples and a "NOTES.txt" file containing general -instructions and a brief description of each example. Select and open one -of the examples sub-directory. - -2. Read the example "NOTES.txt" file for a description of the example. - -3. Open the "SCRIPT.txt" file for instructions on how to load the example -and for sample queries that you may try by copying-and-pasting them to -your Prolog interpreter top-level. - - -Writing your own programs -_________________________ - -Ready to start writing your own programs? - -1. Read the User Manual sections on "Programming in Logtalk" and "Running -and debugging Logtalk programs". - -2. Take a look at the "wenv" sub-directory. There you will find syntax -configuration files for popular text editors which enable syntax coloring -and other text services when editing Logtalk source files. - -3. Create a sub-directory with a suitable name to hold all the files of -your application. You may want to add the directory path to the "libpaths.pl" -file mentioned above in order to easily load your application. - -4. Copy to this sub-directory a loader file from one of the example -directories and modify it to load your own source files. - -5. Have fun! diff --git a/Logtalk/README.YAP b/Logtalk/README.YAP deleted file mode 100644 index 4578a8e9c..000000000 --- a/Logtalk/README.YAP +++ /dev/null @@ -1,25 +0,0 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.24.0 - -Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved. -================================================================= - - -This version of Logtalk included in the YAP distribuition does not -contain configuration files for other Prolog compilers. Also, the -Logtalk compiler/pre-processor is contained in the library/logtalk -directory. - -Logtalk can be loaded from YAP either as described in the included -Logtalk documentation or by using the call: - -| ?- use_module(library(logtalk)). - -This will provide you with the minimal support for compiling and -running Logtalk programs. For improved Logtalk + YAP integration, -please follow the instructions on the Logtalk INSTALL file. - -Note that, although we load Logtalk using the use_module/1 built-in -predicate, the system is not packaged as a module nor does it use -modules in its implementation. diff --git a/Logtalk/README.txt b/Logtalk/README.txt deleted file mode 100644 index 03da9341c..000000000 --- a/Logtalk/README.txt +++ /dev/null @@ -1,124 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.8 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -CONTENTS - - 1. License - 2. Home of Logtalk package - 3. Registration - 4. Support - 5. Installation - 6. Customization - 7. Quick start - 8. Documentation - 9. Upgrading -10. Citations -11. Contributions - - -1. LICENSE - -The overall copyright and permission notice for Logtalk can be found -in the "LICENSE.txt" file in this directory. Logtalk follows the -Artistic License 2.0. The copyright notice and license applies to all -files in this release (including sources, documentation, and examples) -unless otherwise explicitly stated. - - -2. HOME OF LOGTALK PACKAGE - -The latest release of the Logtalk package is always available at the URL: - - http://logtalk.org/ - -At this address you can also find additional documentation and information -about Logtalk. - - -3. REGISTRATION - -To register as a Logtalk user either use the registration form found at -the Logtalk web site, http://logtalk.org/regform.html, or send an email -message to: - - registration@logtalk.org - -with the following information: - -email address, full name, organization, organization type (education, -commercial, government, ...), prolog compilers used (optional), -platforms (mac, pc, unix,...) (optional) - - -4. SUPPORT - -For support options, please consult the page http://logtalk.org/support.html. - - -5. INSTALLATION - -Logtalk can be installed either from sources by running a few shell scripts -or by using one of the provided installers, depending on your operating -system. For manual installation, see the file "INSTALL.txt" for detailed -instructions. - -See the user manual for a description of the source files organization -and for using instructions (to read the user manual open the file -"manuals/index.html" with a web browser). Most files are formatted -using four-space tabs. - - -6. CUSTOMIZATION - -The file "CUSTOMIZE.txt" provides detailed instructions for customizing the -Logtalk installation and working environment. - - -7. QUICK START - -The file "QUICK_START.txt" provides quick instructions for those of you in -a hurry to run Logtalk, provided that your favorite Prolog compiler is -supported. - - -8. DOCUMENTATION - -The reference and user manuals and the tutorial are provided in XHTML format -and can be found in the "manuals" directory. - -The file "RELEASE_NOTES.txt" contains descriptions of all Logtalk updates -since the first public version. Read it carefully if you have been using a -previous Logtalk version. - - -9. UPGRADING - -If you are upgrading from a previous Logtalk version, please check the file -"UPGRADING.txt" for instructions on how to upgrade your programs or your -custom configuration files to run under this new version. - - -10. CITATIONS - -If you find Logtalk useful, please include a citation on your publications. -Consult the file "BIBLIOGRAPHY.bib" for bibliographic references in BibTeX -format (the Logtalk technical report published on 2000 or the 2003 PhD thesis -on Logtalk are good choices). - - -11. CONTRIBUTIONS - -Contributions, constructive criticisms, code, bug reports, and suggestions -are always welcome. If you want to contribute to this project, drop me a -line to the support address given above. - - -Happy Logtalking! - -Paulo Moura -pmoura@logtalk.org diff --git a/Logtalk/RELEASE_NOTES.txt b/Logtalk/RELEASE_NOTES.txt deleted file mode 100644 index 928dfd7fd..000000000 --- a/Logtalk/RELEASE_NOTES.txt +++ /dev/null @@ -1,2828 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.8 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -RELEASE NOTES -============= - - -2.30.8 - November 9, 2007 - - Fixed bug in the compilation of synchronized predicates that breaks - Logtalk on single-threaded Prolog compilers. - - -2.30.7 - November 5, 2007 - - Updated the multi-threading built-in predicates threaded_notify/1 and - threaded_wait/1 to accept lists of notifications. - - Added a new read-only compiler flag, "context_switching_calls", allowing - context switching calls to be disabled (they are enabled by default). - - Updated the B-Prolog config file to recognize eager_consume/1 directives. - Updated the XSB config file to recognize use_subsumptive_tabling/1, - use_variant_tabling/1, index/1, thread_private/1, and thread_shared/1 - directives. - Updated the YAP config file to recognize thread_local/1 directives. - Updated the SICStus Prolog config files to recognize volatile/1 directives. - Updated the SWI-Prolog config file to recognize thread_local/1, index/1, - and hash/1 directives. - - Changed the backup directory names generated by the "cplgtdirs.*" shell - scripts to not include whitespace characters. - - Updated the "xsbmtlgt.sh" integration script to start XSB-MT using the - new command-line option "--shared_predicates" (requires current XSB CVS - version). Updated the Windows GUI installer to support running Logtalk - with XSB-MT. - - Added a multi-threading example, "barriers", of barrier synchronization. - - Updated the "functions" example sample queries for compatibility with the - ISO Prolog standard regarding representation of float numbers. - - Added a workaround for a parsing bug in XSB while compiling the "sicstus" - example. - - -2.30.6 - October 21, 2007 - - Replaced calls to the proprietary current_thread/2 predicate in the - Logtalk runtime by calls to the thread_property/2 predicate as per - the ISO DTR on multi-threading predicates. Added a goal_expansion/2 - clause to the SWI-Prolog config file to automatically switch between - the current_thread/2 and thread_property/2 predicates depending on - availability. - - Changed handling of the encoding/1 directive by the Logtalk compiler in - order to improve compatibility with YAP and SICStus Prolog. Removed from - the config files the now obsolete '$lgt_set_stream_encoding'/2 predicate - definition. Renamed the compiler option "supports_encoding_dir" to - "encoding_directive" and changed its possible values to "unsupported", - "full" (used in both Logtalk source files and compiler generated Prolog - files), and "source" (used only in Logtalk source files). - - Renamed compiler option "underscore_vars" to "underscore_variables". - Renamed compiler option "supports_break_predicate" to "break_predicate". - - Improved the performance of recursive predicate definitions synchronized - by mutexes. Explicitly create all mutexes used by an entity at load time - for compatibility with XSB. Several changes to multi-threading support in - order to improve compatibility with current and forthcoming versions of - YAP, SWI-Prolog, and XSB. - - Updated the Logtalk compiler for compatibility with both logical and - immediate update semantics when compiling synchronized predicates. - - Updated the meta-predicate compilation sanity checks to verify the - existence of the minimum number of normal arguments in a clause head - required by the closure of maximum arity. - - Added a workaround for the lack of built-in support for character - unbuffered input when using the Logtalk built-in debugger to the config - files of ALS Prolog, B-Prolog, Ciao, CxProlog, IF/Prolog, JIProlog, - Prolog II+, SICStus Prolog, XSB, and YAP. Thanks to Parker Jones for the - bug report. - - Updated the YAP config file to auto-detect working Unicode support when - setting the "encoding_directive" compiler option. - - Updated the XSB config file to auto-detect multi-threading support - when setting the "threads" compiler option. Added an integration script - (xsbmtlgt.sh) and supporting files for the multi-threaded version of XSB - (requires current development version, available from the XSB CVS server). - - Added a MacPorts portfile for building MacOS X installer packages. - - Added a BOM to the "babel.lgt" UTF-8 file in the "encodings" example in - order to improve compatibility with SICStus Prolog. - - Updated the library object "random" by replacing the synchronized/0 - directive by a synchronized/1 directive listing only the predicates - that modify the random number seed. - - Added syntax coloring support for the GtkSourceView 2.x text widget - (used e.g. on the Gnome's Gedit text editor and on the MonoDevelop IDE). - Removed syntax coloring for the obsolete atomic/1 predicate directive - from the support files of Source-highlight, Emacs, SubEthaEdit, jEdit, - and Kate. Optimized the regular expressions used in most syntax coloring - configuration files of supported text editors. - - -2.30.5 - September 19, 2007 - - Added new multi-threading built-in predicates threaded_call/2, - threaded_once/2, threaded_exit/2, and threaded_peek/2. These new - predicates support the use of threaded call identifier tags in order to - link specific threaded_call/2 and threaded_once/2 calls to specific - threaded_exit/2 and threaded_peek/2 calls. Extended the "nondet" example - in order to illustrate the new functionality. - - Changed the implementation of the built-in predicate threaded_exit/1 in - order to avoid blocking when its argument is subsumed by the argument of - the corresponding threaded_call/1 call instead of being a variant. - - Updated the Logtalk compiler to encapsulate resource errors inside - error/2 exception terms (as specified in the ISO Prolog core standard). - - Corrected a bug in the library object "lgtunit" (wrong arity on two - failed_test/2 predicate calls). - - Corrected two problems with the "testing" example: a wrong call on the - object "dyn_tests" and a missing entry in the "libpaths.pl" file. Removed - two pointless dynamic predicate directives in the "buffer" example. - - Improved documentation of multi-threading programming and predicate - properties. Corrected the reference manual page describing the threaded/0 - directive. - - Simplified installation scripts by moving shared distribution cleaning - code into the "cleandist.sh" script. Updated the "install.sh" script to - set the installation prefix to "/usr" on Debian systems. Updated the - Linux RPM spec file in order to clean the building directory after the - package creation. - - -2.30.4 - August 22, 2007 - - Allow the argument of {}/1 calls to be a variable at compile time. - - Updated the Qu-Prolog config file to match and require version 8.1 and - added a "qplgt" integration script. - - Updated the XSB config file to match and require version 3.1 and to - take advantage of the compiler option optimize/1 when loading Logtalk - generated Prolog intermediate files. - - Added a new library object, "lgtunit", providing preliminary support for - writing and running unit tests. Added a new example, "testing", defining - sample unit tests. - - Added a new multi-threading example, "threads/tak", implementing the - Takeuchi function (recursive arithmetic). - - Updated the "threads/philosophers" example to use notifications instead - of a dynamic predicate for representing chopstick availability. Added an - alternative implementation using a parametric object. Improved example - documentation. - - Updated the "benchmarks" example to allow comparisons between calls to - imported category predicates and calls to local object predicates. - - Updated Emacs support in order to fix problems with the syntax-coloring - of some Logtalk built-in predicates and applied a patch contributed by - Nicolas Pelletier to workaround a compatibility problem with XEmacs. - - Updated jEdit support in order to fix a problem with the syntax-coloring - of the :/1 control construct. - - -2.30.3 - July 9, 2007 - - Updated the multi-threading built-in predicate threaded/1 to support - both conjunctions of goals (akin to and-parallelism) and disjunctions - of goals (akin to or-parallelism) as an argument. - - Removed the experimental threaded_race/1 multi-threading built-in - predicate (its or-parallelism functionality is subsumed by the updated - threaded/1 predicate). - - Corrected a bug in the implementation of the multi-threading built-in - predicate threaded_exit/1 when there are more than one thread running - the same non-deterministic goal (the fix ensures that all alternative - solutions per threaded_exit/1 call come from the same computing thread). - Thanks to Paul Crocker for the suggested bug fix solution. - - Updated the sample queries in the "threads/buffer"/SCRIPT.txt" file to - match the updated entities in the example. - - Updated the "threads/functions" example to use the new version of the - threaded/1 multi-threading built-in predicate. - - -2.30.2 - June 24, 2007 - - Updated the Logtalk compiler to throw a compilation error when duplicated - or conflicting predicate scope directives are found. - - Updated the Logtalk compiler to correct a cosmetic glitch when reporting - compilation errors. - - Updated the Logtalk compiler to check for mismatches between the argument - of this/1 calls and the parametric object identifier. - - Corrected a bug in the implementation of the multi-threading built-in - predicate threaded_ignore/1. - - Revamped the "threads/buffer" example to support setting the buffer - maximum number of items. - - Added a new DCG example, "dcgs/morse.lgt", for parsing messages in Morse - code. - - Extended the "parametric" example to illustrate a solution for dealing - with inheritance when defining "setter" predicates/methods that return - updated object identifiers. - - -2.30.1 - June 12, 2007 - - Added a new, experimental control construct, :/1, for calling imported - category predicates without using message sending mechanisms. - - Added preliminary support for static binding when calling imported - category using the new :/1 control construct for categories compiled - and loaded using the compiler option "reload(skip)". - - Added a new control construct, < "xmldocs", "xsl" -> "xslfile", and "doctype" -> "xmlsref". - No changes to the other flags or flag valid values. - - Updated documenting scripts to use system-wide resources from LOGTALKHOME - and user-modifiable resources from LOGTALKUSER. - - Updated "cplgtdirs.*" shell scripts to create links to the documenting - scripts and to the DTD and XML Schema specifications instead of making - local copies. Updated the "cplgtdirs.js" Windows JScript script to create - a link to the Logtalk manuals. - - Changed generation of predicate compiled functors to add an underscore - between the original predicate functor and arity (further minimizing the - chance of name conflicts). - - Improved compilation warning messages (separately handling plural and - singular forms). - - Improved documentation of Windows JScript installation and integration - scripts. - - Corrected a bug on the Logtalk built-in debugger on the processing of the - abort option at a leashed port (option was ignored instead of aborting the - debugging session). - - Added an option to choose between a "verbose" or "compact" listing of the - default compilation flags at Logtalk startup (defined on the config files). - - Improved CIAO integration scripts in order to suppress some (harmless) - warnings which are generated at first run. - - Updated SWI-Prolog hook file ("swihook.pl") in order to support Logtalk - library notation when loading Logtalk files using the SWI-Prolog consult/1 - predicate. - - Corrected a bug on the implementation of the built-in method abolish/1 - that prevented abolishing of dynamic predicates with arity zero. - - Corrected a bug on the "gplgt" shell script generated by the make_gplgt.sh - shell script where the value of the LOGTALKHOME environment variable would - not be retrieved at runtime. - - Removed config file for older versions of XSB (up to 2.6). Renamed the - config file for XSB 2.7.1 to simply "xsb.config". - - Consolidated the source files of the "birds", "errors", "lpa", "lo", - "metainterpreters", "poem", "relations", "roots", and "symdiff" examples - into single source files. Updated the "searching" example to take advantage - of the uses/2 directive. - - Removed outdated documenting shell scripts from the "xml" directory. - - Corrected a bug when compiling a source file where the generated Prolog - file might not be properly closed when a compilation error occurs. - - -2.25.3 - September 12, 2005 - - Consolidated the source files of the examples "bricks", "dynpred", "mi", - "parametric", "points", "polygons", "reflection", "shapes", "sicstus", - and "viewpoints" into single source files. - - Improved documentation on most example source files. Improved "parametric" - example by adding a new parametric objects and by illustrating alternative - ways of accessing object parameters. - - Updated several config files with declarations for some more non-standard - Prolog meta-predicates. - - Corrected some omissions and typos on the B-Prolog - Logtalk integration - instructions. - - Small performance optimization for messages and super-calls with not yet - cached method lookups. - - -2.25.2 - August 11, 2005 - - Updated Logtalk installation and Prolog integration scripts in order to - detect a wrongly defined LOGTALKHOME environment variable. - - Corrected a bug on the lgt_install.sh and make*lgt.sh shell scripts where - the wrong variable was being referenced when testing the existence of the - installation directory prefix. - - Corrected a bug on the makeall_lgt.sh shell script that failed to properly - detect unsuccessful completion of individual Prolog integration scripts. - - -2.25.1 - August 8, 2005 - - Added support for using the "source-highlight" package (version 2.0 or - later) by Lorenzo Bettini with Logtalk source files. - - Several optimizations to the syntax coloring configuration files of most - of the supported text editors. Added support for code folding to the Vim, - Kate, and TextMate text editors. - - Updated the SWI-Prolog shell integration script (make_swilgt.sh) to use - either "swipl" or "pl" as the name of the Prolog executable, depending - on the host operating system. - - Modified the way entity prefixes are generated for compiled code in order - to further minimize possible conflicts resulting from the same prefix being - used for different entities (bug report and fix by Brian Hulley). Changes - to the prefix format are also reflected on the names of the automatically - generated XML documenting files. - - Updated the lgt2html.* and lgt2xml.* documenting scripts in order to index - parametric objects using the notation /. - - Corrected a bug on the lgtxml.xsl XSLT file where links to related files - pointed to .html files instead of .xml files. - - Updated the lgt_install.sh and the make_*lgt.sh shell scripts to check and - report invalid installation directory prefixes. - - Added a new state-space search problem, "salt3.lgt", contributed by Paula - Marisa Sampaio, to the "searching" example. - - -2.25.0 - May 23, 2005 - - Logtalk compiler is now source file-based instead of entity-based. Thus, - a source file may now contain any number of entities, without the need of - using source metafiles. Therefore, this version drops support for source - metafiles and the .mlgt file name extension. - - The experimental encoding/1 directive, when used, must be the first term - on a source file. Added an entry to the reference manual describing the - directive. Improved "encodings" example. - - Added a new method, debugging/1, to the "debugger" pseudo-object for - querying the system about entities compiled in debug mode. - - Improved source file and entity compilation and loading reporting. In - particular, when using library notation for source files, the Logtalk - compiler now prints the library path containing the source files being - compiled or loaded. - - Added new shell scripts, makeall_lgt.*, which run all the make_*lgt.* - shell scripts in sequence. - - Simplified compiler reporting of singleton variables in directives and - clauses. - - Added an adaption of the "timetables" LPA Prolog++ example. - - Updated B-Prolog config file for the new 6.7 #2 version. Dropped support - for older versions of B-Prolog. - - -2.24.0 - April 22, 2005 - - Added experimental support for a encoding/1 directive for declaring the - text character encoding of a source file. This directive is fully based - on a directive with the same name and with similar semantics found on - recent development versions of SWI-Prolog. For now, this directive only - works with SWI-Prolog as most Prolog compilers lack support for dealing - with different text encodings. Added new flag "supports_encoding_dir". - Added a new example, "encodings", of using the new encoding/1 directive. - - When a source file contains an encoding/1 directive, the XML documenting - files will use the same encoding. When no encoding/1 directive is present, - the XML documenting files will assume UTF-8 encoding. - - Added new info/1 documenting directive key, "parameters", allowing the - declaration of both parameter names and parameter descriptions. Added new - info/1 documenting directive key, "remarks", allowing general remarks - about an entity to be stated. Added new info/2 documenting directive key, - "arguments", allowing declaration of both predicate argument names and - predicate argument descriptions. Added new info/2 documenting directive - key, "examples", allowing the representation of predicate call examples. - - Much improved and accurate reporting of non-portable predicate calls when - using the "portability" flag. - - Added a new directory to the Logtalk distribution, "contributions", which - will be used for user-contributed code. On this release, it contains an - implementation of the ISO 8601 standard by Daniel L. Dudley, providing a - library of useful date predicates. - - Added new lgt2xml.* shell scripts for generating (X)HTML indexes of XML - documenting files. - - Rewritten the lgtxhtml.xsl, lgthtml.xsl, lgtxml.xsl XSLT scripts in order - to make it easier to define alternative CSS files for the generated HTML - files. Rewritten the lgtpdfa4.xsl and lgtpdfus.xsl XSLT scripts in order - to improve appearance of the generated PDF files. - - Improved the documentation of the "benchmarks" example and added new - predicates for running batches of benchmark tests and for generating - lists of known size for the benchmark tests of static code. - - Corrected a bug in the lgt2html.*, lgt2pdf.*, and cplgtdirs.sh shell - scripts which resulted in failed transformations whenever the LOGTALKHOME - and LOGTALKUSER environment variables or the output directory contained - spaces or accented characters. - - Added workaround for Prolog compilers that define operators other than - ','/2 that cannot be redefined (such as new B-Prolog 6.7). - - Added a Logtalk "clip" file for the TextPad Windows text editor. - - Renamed directory "misc" to the more meaningful name "scripts". - - Corrected a bug in the implementation of the built-in database methods - asserta/1 and assertz/1 when asserting facts on objects compiled in debug - mode. - - Corrected a bug in the method leash/1 of the built-in pseudo-object - "debugger", which failed to accept an empty list as a valid argument. - - Corrected a bug in the header of the automatically generated XML - documenting files when using the XML Schema specification (logtalk.xsd), - which could prevented validation when the compiler flag "doctype" is set - to "web". - - Corrected a compilation bug where Prolog clauses written outside entities - on source metafiles would have their order reversed. Simplified splitting - of source metafiles. - - Corrected a compilation bug where Prolog clauses written before an entity - opening directive would not be copied to the generated Prolog file. - - Corrected a bug on the "roots" example in the object "class" which failed - to properly test the validity of new object identifiers. - - Corrected a bug in the syntax coloring file for the Vim text editor, which - resulted in an error message when opening a Logtalk source file for the - first time. - - -2.23.1 - March 7, 2005 - - Simplified message sending compilation, improving performance of both - entity compilation and runtime top-level message sending. - - Simplified implementation and improved performance of the built-in method - current_predicate/2. - - Updated the runtime error handler for top-level ::/2 calls to recognize - non-existing predicate exceptions thrown by XSB, SICStus Prolog, CIAO, - B-Prolog, and recent development versions of SWI-Prolog. Rewritten the - ::/2 predicate in order to minimize the overhead of the catch/3 calls - associated with the runtime error handler, thus improving performance. - - Expanded the benchmarks example to test performance of the built-in - database methods. - - Lookup caches are now cleaned before loading a redefined entity in order - to avoid potential problems with entity initialization goals containing - message sending calls (previous versions cleaned the caches only after - entity loading). - - When reloading an object, its tables of dynamic predicate declarations - and dynamic predicate definitions are now reseted. - - Corrected a compatibility problem with the "birds" example due to the use - of an operator not available in some Prolog compilers. - - -2.23.0 - February 21, 2005 - - Optimized the code generated for local calls to the built-in predicates - asserta/1, assertz/1, retract/1, and retractall/1, when the argument is - a dynamic predicate declared by a scope directive in the object making - the calls. - - Added caching of predicate compiled forms for dynamic facts when used - with the database built-in methods clause/2, asserta/1, assertz/1, - retract/1, and retractall/1, resulting in a significant performance - improvement when using an object's dynamic database. Improved performance - of the database built-in methods abolish/1, asserta/1, assertz/1, clause/2, - retract/1, and retractall/1 when the cache is not used. - - Corrected a bug on the implementation of the built-in methods asserta/1 - and assertz/1 that prevented asserting of rules. - - Corrected a bug on the implementation of built-in methods retractall/1, - retract/1, and clause/2 that allowed access to local dynamic predicates - from outside the container object. - - Added a runtime error handler for top-level ::/2 calls which tries to deal - with exceptions thrown by calling non-existing predicates by translating - Logtalk generated internal predicate names to user names. - - Print the total number of warnings after a call to the Logtalk built-in - predicates logtalk_compile/1-2 and logtalk_load/1-2. - - -2.22.5 - February 9, 2005 - - Added scripts for easy integration of Logtalk with K-Prolog. Updated the - K-Prolog config file, correcting a show-stopper bug and enabling support - for using the "library" notation for loading source files. - - Updated JIProlog config file in order to allow smart compilation of source - files. - - Changed format of preprocessor and runtime dynamic predicates that deal - with predicate indicators for better performance. - - Simplified implementation of Logtalk built-in methods asserta/1 and - assertz/1. - - Corrected a performance bug with calls to built-in predicates from objects - and categories. - - Corrected spurious backtracking occurring on some calls to the built-in - predicate define_events/5. - - Updated shell script "misc/cplgtdirs.sh" to prevent copy of Logtalk files - when the destination directory already exists (thus avoiding overriding - any user-modified files when upgrading Logtalk). - - Added syntax coloring for the predicate logtalk_library_path/2 to the - supported text editors. Updated the syntax coloring file for the TextMate - text editor, adding some missing ISO Prolog predicates. - - Improved printing of lists of unknown referenced entities, misspelt calls, - and singleton variables when compiling source files. Simplified handling - of references to unknown entities. - - Added workaround for Prolog compilers with broken read_term/3 singletons/1 - option. - - Updated the Logtalk compiler/runtime and the documentation to always - use the expression "compiler flag" instead of "compiler option" for - consistency. Other minor documentation improvements. - - Corrected a bug with the abolishing of dynamic entities where the clauses - corresponding to the alias/3 directive are not being abolished. - - Added new predicates '$lgt_call'/9 and '$lgt_once'/9 to all config files. - - Simplified and improved performance of compilation of directives containing - predicate indicators. - - -2.22.4 - January 12, 2005 - - Simplified method lookup cache tables, resulting in a small message - sending performance speedup. Improved method lookup caching for - parametric objects. Added support for caching method lookups for - parametric objects whose parameters contain cyclic terms. - - Added a new category, "assignvars", to the Logtalk standard library, - containing an adaptation of the implementation of logical assignable - variables developed by Nobukuni Kino. Added a new example, "assignvars", - illustrating some possible uses of assignable variables in the context - of parametric objects. - - Simplified compilation of op/3 directives: there is no longer need to - repeat the directives both before and inside an entity in order to make - the operators global and also use them in the compilation process. - - Simplified installation instructions. - - Corrected a compiler bug in the code that checks and prints a warning - when redefined parametric objects. - - Corrected a bug in the built-in predicate abolish_category/1, which - failed to delete import relation clauses between the category being - abolished and other categories. - - -2.22.3 - December 30, 2004 - - Added a configuration file for XSB 2.7. - - Corrected a bug where the use of alternative compilation directories - would fail the first time the logtalk_compile/1-2 or logtalk_load/1-2 - predicates are used for a given file or library. - - Corrected a bug in the built-in methods asserta/1 and assertz/1 when - asserting facts into an object being debugged, which resulted in wrong - execution context information being printed when tracing calls to - the asserted facts. - - Corrected a bug in the built-in methods asserta/1 and assertz/1 when - asserting rules into an object being debugged, which resulted in rule - bodies compiled with no information being printed for the rule head - when tracing calls to the asserted rules. - - Corrected a bug in the dynamic creation of objects, protocols, and - categories when the debug flag is on, which resulted in the table of - entities being debugged not being updated. - - Corrected a bug in the handling of exceptions thrown when using the - built-in debugger, which resulted in exceptions always being turned - into failures. - - -2.22.2 - December 24, 2004 - - Improved performance of dynamic creation and compilation of objects, - protocols, and categories. - - Improved error-checking code of methods asserta/1 and assertz/1 to - prevent asserting of non-callable terms as facts. - - Improved error checking for documenting directives (info/1 and info/2). - - Improved the XSB integration script (make_xsblgt.sh) in order to use the - configuration file and the libpaths file available from the $LOGTALKUSER - directory. - - Improved installation instructions and installation scripts documentation. - - Added documentation to the user manual on describing predicate exceptions - using the info/2 directive. - - Corrected a bug in the predicate_property/2 built-in method when called - with the second argument instantiated to the alias/1 property. - - -2.22.1 - December 6, 2004 - - Improved installation instructions. Updated the Windows installation - JScript script to add the Logtalk directories "misc" and "xml" to the - system PATH environment variable and to reuse the environment variable - LOGTALKUSER if already defined. - - Added helper batch scripts (misc/cplgtdirs.bat, xml/lgt2html.bat, and - xml/lgt2pdf.bat) for easily running the corresponding Windows JScript - scripts from the command-line (the two xml/lgt2*.bat scripts run the - corresponding *.js scripts stored in the %LOGTALKUSER%/xml directory - in order to support user customization). - - Updated the lgt2html.* and lgt2pdf.* shell scripts to use the environment - variable LOGTALKUSER instead of LOGTALKHOME for finding supporting files, - thus allowing for end-user customization of the scripts and their related - files. - - Added documentation on read-only compiler flags (which are defined in the - configuration files) to the User Manual. - - Updated the misc/lgt_install.js JScript installer script to workaround a - Windows Scripting Host bug which may result in broken shortcuts in the - created "Logtalk" program group. - - -2.22.0 - November 29, 2004 - - Implemented a notion of library as simply a directory containing source - files. Added a new dynamic predicate, logtalk_library_path/2, for - specifying library paths. Added a sample file (libpaths/libpaths.pl) for - setting library paths for the Logtalk standard library and for all the - supplied examples. - - Added support for using the notation () with the built-in - predicates logtalk_compile/1-2 and logtalk_load/1-2 for compiling and - loading source files contained on a library, without the need to first - change the current working directory. - - Changed the library and the examples loading instructions to use the new - notation (). - - Improved installation instructions and installation scripts. Added a new - environment variable, LOGTALKUSER, for defining the location of the copies - of the user-modifiable Logtalk files in a multiple users setup environment. - - Added utility predicates to most configuration files for querying and - changing the current working directory (needed for the () - notation to work). - - Corrected a bug in the code that checks for file existence when compiling - or loading source files and source metafiles. - - -2.21.6 - November 15, 2004 - - Added support for using alternative directories for storing the Prolog files - and the XML documenting files resulting from entity compilation. A new read- - only flag, "altdirs", allows the support for alternative directories to be - turned on the configuration files of Prolog compilers providing the necessary - operating-system access predicates for implementing this feature. - - Improved installation instructions and reporting of default compilation flags - at startup. - - Added a sorely missing "Hello World!" example :-) - - -2.21.5 - November 2, 2004 - - Added a new optimization compiler flag, "events", which can be used to switch - off event-driven programming support when not needed, on a per-object basis, - resulting in improved message sending performance. - - Small performance optimization to the runtime creation of dynamic objects, - protocols, and categories. - - Updated the error handling code of the built-in predicates create_object/4, - create_protocol/3, and create_category/4 in order to throw an instantiation - error when called with a non-instantiated argument. - - Updated the benchmarks example to calculate and subtract the benchmark loop - time in order to print absolute timings for the benchmarked goals. - - Updated the Qu-Prolog patching instructions to also convert Logtalk source - metafiles. - - Fixed a typo on the XSB compatibility notes in the configs/NOTES file. - - -2.21.4 - October 26, 2004 - - Corrected a silly bug in the definition of the predicate repeat/1 on the - new "benchmarks" example. - - -2.21.3 - October 25, 2004 - - Corrected a silly bug in message translation which resulted in a small - performance loss. Simplified implementation of message sending predicate - ::/2, resulting in a small performance improvement. - - Added a new section on message sending performance to the user manual. - - Added a new example, "benchmarks", for helping measuring performance of - Logtalk message sending between Prolog compilers and for comparing message - sending with predicate calls in plain Prolog and with calls to modules - predicates. - - Updated the YAP configuration file to hide some of the book-keeping tables - of the Logtalk runtime engine and to use statistics/2 instead of cputime/0 - for more accurate timings. - - Updated the Logtalk shell installation script to create the $prefix/bin - directory if it does not exist. - - The lgt2pdf.sh and lgt2html.sh shell scripts now use "rm -f" when removing - the DTD and XSD files in order to avoid prompting the the user about the file - permissions. - - Updated the cplgtdirs.sh shell script to make all copied files user writable. - - -2.21.2 - October 18, 2004 - - Added support for declaring grammar rule non-terminals as public, protected, - private, dynamic, or discontiguous using the notation Functor//Arity. Added - support for documenting non-terminals using the info/2 and mode/2 directives. - - Added support for a new alias/1 predicate property. - - New experimental config file for JIProlog 3.0 (see the configs/NOTES file - for details). - - Added a mode bundle for the TextMode 1.0.x (MacOS X) text editor providing - syntax highlighting, folding, and code snippets for editing Logtalk source - files. Corrected a bug in the syntax coloring of the :-/1-2 operator on the - SubEthaEdit 2.x text editor. - - -2.21.1 - September 27, 2004 - - Added experimental support for a new built-in method, expand_term/2, which - allows access to the Logtalk grammar rule translator. Corrected bug in the - expansion of \+/1 in grammar rule bodies. Optimized code generated for - message sending calls in the body of grammar rules. Improved error handling - of the built-in methods phrase/2 and phrase/3. Added new section on definite - clause grammars to the user manual. Added two new objects to the "dcgs" - example, dcgtest and bypass, containing test cases for the Logtalk DCG - translator and illustrating some programming techniques with grammar rules. - - Corrected a bug in the implementation of the built-in method clause/2 which - prevented access to clauses of local dynamic predicates. - - Corrected some dead links on the XHTML manuals. - - Corrected a bug in the syntax coloring of numbers on the SubEthaEdit 2.x - text editor. - - -2.21.0 - September 14, 2004 - - Added a new predicate directive, alias/3, which allows the definition of - alternative predicate names in order to improve readability of inherited - features and to solve conflicts between implemented, imported, or inherited - predicates. - - Added new example, "aliases", illustrating the use of the new alias/3 - predicate directive for improving readability of inherited features. - - Added new example, "diamonds", illustrating problems and solutions for the - "diamond problem" (multi-inheritance conflicts and ambiguities) using the - new alias/3 predicate directive. - - Allow categories to import other categories, i.e. allow categories to be - defined as a composition of other categories. This feature should only be - used when extending a category without breaking its functional cohesion - (for example, when a modified version of a category is needed for importing - into several unrelated objects). - - Added new example, "engines", illustrating importing a category from another - category. - - Updated the syntax coloring configuration files for the supported text - editors for the new alias/3 predicate directive. - - Added auto-complete strings for Logtalk methods and for Logtalk and Prolog - built-in predicates and directives to the SubEthaEdit 2.x text editor. - - Corrected a bug which prevented compilation of metafiles containing - parametric entities. - - -2.20.2 - August 31, 2004 - - Added a Windows JScript script for installing Logtalk. Improved the Windows - JScript scripts used for easy integration of Logtalk with selected Prolog - compilers. - - Improved user manual section on defining object and category metapredicates - and on calling non-standard Prolog built-in metapredicates. Improved the - description of some compiler options. - - Added some files missing from the "errors" example (which should have been - included in the previous release). - - Added basic syntax coloring support for the BBEdit 8.x text editor. - - -2.20.1 - August 19, 2004 - - Added Windows JScript scripts for easy integration of Logtalk with CIAO and - GNU Prolog. - - Added encoding attribute (set to UTF-8) to the xsl:output tag in the - lgtxml.xsl, lgthtml.xsl, and lgtxhtml.xsl files. - - Replaced the Windows JScript scripts lgt2pdf.js and lgt2html.js by their - final versions (the wrong ones shipped with Logtalk version 2.20.0). - - Updated the "errors" example to illustrate possible conflict errors when - using the uses/2 directive. - - Updated the RPM logtalk.spec file to use the .tgz archive extension. - - -2.20.0 - August 16, 2004 - - Added support for the uses/2 predicate directive (whose semantics is similar - to C++ using-declarations). Updated the uses/1 entity directive to accept as - argument a single object identifier. - - Improved installation instructions for Windows users. - - Added four new sample bash shell scripts and Windows JScript scripts for - converting XML documenting files to PDF, HTML, and XHTML using several XSL - processors. - - Added missing namespace to XSL files in order to generated valid (X)HTML - files with recent versions of XSLT processors. - - Updated the User Manual documentation on converting XML documenting files - to other formats. - - Removed the texml.xsl XSLT file as the TeXMLatte application it depends on - is no longer available. - - Added Windows JScript script for copying the Logtalk examples, library, and - xml directories to the user directory. - - Added Windows JScript scripts for easy integration of Logtalk with ECLiPSe, - SWI-Prolog, SICStus Prolog, and YAP. - - Added missing extension for source metafiles to the SWI-Prolog hook file. - - Corrected a bug in the lgtxhtml.xsl XSLT file where a wrong reference to - the Logtalk CSS file is being used in the xml-stylesheet tag. - - The iso_initialization_dir/1 compiler option is now a read only flag, - defined in the configuration files. - - -2.19.1 - August 2, 2004 - - Corrected a bug where entities could not be reloaded if they depend on - other, not yet loaded entities. - - Corrected a bug where compiler options would not be used when compiling - source metafiles. - - Corrected several typos on the Logtalk manuals. - - -2.19.0 - July 26, 2004 - - Added support for defining more than one entity per file using Logtalk - source metafiles (*.mlgt), which the runtime engine automatically splits - on single entity source files plus loading and compiling helper files. - - Updated the URL used on the automatically generated XML documenting files - when compiling entities with the option doctype(web). - - Improved error checking when compiling calls to the {}/1 control construct. - - Corrected several typos and some outdated links on the Logtalk manuals. - - -2.18.0 - July 9, 2004 - - Added caching of method lookups in order to improve message processing - performance (including messages to self and super calls). Applied several - optimizations to runtime translation of messages in order to further - improve performance. - - Improved error checking while parsing and compiling messages to self. - - Update ECLiPSe config files to compile the Prolog files generated by Logtalk - (when compiling source files) in optimized mode instead of traceable mode. - - Updated description of patches needed for running Logtalk with XSB, added - a shell script for easy integration of Logtalk with this Prolog compiler, - and corrected a problem with its corresponding config file. - - Added multifile/1 directive to the syntax coloring configuration files of the - supported text editors. - - -2.17.2 - June 14, 2004 - - Updated the Logtalk compiler to allow compilation of source files which - contain only directives and no entity definition. - - Simplified loading of library and example entities by using Logtalk source - files as loader files. - - Some improvements to the documentation, including the QUICK_START file and - the User Manual for first-time users, and to the example descriptions. - - Corrected a bug in handling of local object operators that are also global - operators. - - Corrected a bug where dynamic directives are not being generated for dynamic - predicates that lack a scope directive or an initial set of clauses. - - Corrected a bug where local dynamic predicates would need a private scope - directive in order to allow clauses of the predicate to be retracted. - - Simplified compilation of dynamic and discontiguous predicate directives. - - Added new "logic" example implementing a translator from logic propositions - to conjunctive normal form. - - Corrected a problem with wrong end-on-lines on some files. - - Added a shell script for easy integration of Logtalk with CIAO Prolog. - - -2.17.1 - June 7, 2004 - - Added custom handling of specification of predicate exceptions in info/2 - documenting directives when writing XML documenting files (declared as - "exceptions is [Cond1-Term1, Cond2-Term2, ...]"; each pair (Condi, Termi) - represents an error condition and its respective exception). - - Changed debugger command "e" to print exception terms instead of exiting - Logtalk session. - - Corrected a compilation error with B-Prolog due to operator priorities. - - Corrected a possible problem with the redefinition of loaded entities that - define (possibly at runtime) dynamic predicates. All clauses for an entity - dynamic predicates are retracted before loading the new entity definition. - - Corrected a potential bug when pretty printing terms with variables in the - debugger and in the created XML documenting files. - - Added four more DCGs examples ("walker movements", "iterative shell command - parsing", "bill of materials", and "command language"). - - New "puzzles" and "metainterpreters" examples. - - Added a mode bundle for the SubEthaEdit 2.x (MacOS X) text editor providing - syntax coloring for editing Logtalk source files. Optimized some of the - regular expressions in the syntax coloring files for the Kate/Kwrite and Vim - text editors. - - Removed predicate nth/3 from library entities listp, list, and difflist. - Replaced by the predicates nth0/3 and nth1/3. Added new predicates nth1/4 - and nth0/4. - - Updated the config file for Quintus Prolog to make use of the "files" - library. - - Added experimental implementations for some Prolog compilers of the library - portable protocol for operating system access (systemp.lgt). See the file - library/experimental/NOTES for details. - - -2.17.0 - April 26, 2004 - - Added built-in debugging support implemented through the definition of a - new pseudo-object named "debugger". Added "debug" compiler option. Renamed - library entities "debuggerp" and "debugger" to, respectively, "event_dbgp" - and "event_dbg". - - Improved installation instructions for multi-user environments. Added - a shell script for installing Logtalk in Unix and Unix-like operating - systems. Added a shell script for copying Logtalk xml, examples, and - library directories to the user home directory. - - Added a logtalk.spec file for building Linux RPMs from sources. - - Added a set of shell scripts for easy integration of Logtalk with ECLiPSe, - GNU Prolog, Qu-Prolog, SICStus Prolog, SWI-Prolog, and YAP. - - Corrected bug in the definition of the pseudo-object "user" that resulted - in mixed up metapredicate and type predicate properties. - - Removed config files for outdated versions of Qu-Prolog, SWI-Prolog, ECLiPSe, - K-Prolog, CIAO, YAP, Amzi! Prolog, LPA Win-Prolog, SICStus Prolog, and XSB. - - -2.16.2 - April 2, 2004 - - Corrected a bug in the library category monitor (file library/monitor.lgt) - that prevents its compilation. - - Changed the possible values of the read-only flag startup_message (defined - in the config files) to "flags" (print banner and flag values), "banner" - (print only the banner), and "none" (do not print neither the banner nor the - flag values). Default value is "flags". - - Updated the "errors" example to illustrate the error messages thrown when - trying to redefine Logtalk built-in control constructs. - - Corrected a small problem with the Logtalk language specification file for - Apple's Xcode IDE. - - Added preliminary support for syntax coloring using the Windows text editor - Crimson Editor. - - -2.16.1 - March 23, 2004 - - The local built-in method parameter/2 can now be used inside categories - (but please read the warnings about such practice on the user manual). - - Updated the Logtalk compiler to report an error when the user tries to - redefine a message sending or external call control construct inside an - object or category. - - Corrected a bug in the compilation of metacalls whose meta-arguments are - variables. - - Removed references to file sax.jar from the scripts used to convert XML - documenting files into (X)HTML. Updated scripts html.sh, htmlnt.cmd, and - htmldos.bat to use XT 20020426a or later version. - - Improved syntax coloring accuracy of built-in predicates and methods for - the SubEthaEdit text editor. - - Updated config file for Qu-Prolog 6.4. - - -2.16.0 - March 3, 2004 - - Logtalk is now distributed under the Artistic License 2.0. - - Operators declared inside an entity are now local to the entity, not - affecting the global operator table (complying with the Logtalk language - specification). Input and output of terms from inside objects and - categories now work as expected in the presence of local operator - declarations. Added a new example named "operators". - - Updated built-in method predicate_property/2 for returning metapredicate/1 - properties for both Logtalk and Prolog metapredicates. - - Added support for calls to non-ISO Prolog standard built-in metapredicates - inside objects and categories. Added support for the declaration of non-ISO - Prolog standard metapredicates in the config files. - - Small change to the way the Logtalk compiler reports the compilation of - entities. Small optimizations to the compilation of Logtalk source files. - - Corrected a bug where calls to Logtalk built-in predicates would be - reported as non-portable when the value of compiler option portability is - set to warning. - - New config file for Qu-Prolog 6.4 (see the configs/NOTES file for details). - - Corrected a problem with the syntax coloring of quoted atoms and strings - in the SubEthaEdit text editor. Added more accurate syntax highlight for - built-in methods and built-in predicates. - - Updated the syntax coloring configuration files for all supported text - editors to recognize the file extension used by the config files. - - -2.15.6 - February 9, 2004 - - Added "xmlspec" compiler option in order to specify the extension (dtd - or xsd) of the file describing the XML documenting files specification. - - Renamed compiler option "named_anonymous_vars" to the more appropriated - name "underscore_vars". Changed possible option values to "dont_care" and - "singletons" (default). - - Added XSLT file for converting XML documenting files to XHTML 1.0 Strict - files. Set the default encoding of all XSLT files to UTF-8. - - Added syntax coloring support for the KDE Kate and Kwrite text editors. - - Improved syntax coloring configuration files for VIM, jEdit, NEdit, - SubEthaEdit, and Emacs text editors. - - Removed outdated support for MacOS X Project Builder and added support - for the new MacOS X Xcode developer tool. - - Corrected bug in the built-in predicate current_logtalk_flag/2 that - prevented some flag values from being returned after using the built-in - predicate set_logtalk_flag/2. - - Corrected bug in the shapes example (wrong placement of the declaration - of the predicate side/1). - - -2.15.5 - December 30, 2003 - - Make operator ^^/1 right-associative for consistency with remaining - operator declarations. - - Added file BIBLIOGRAPHY containing a list of Logtalk publications in - BibTeX format. - - Added a font-lock file for Emacs providing syntax coloring for editing - Logtalk source files. - - Added an implementation of the Smalltalk dependent mechanism to the - standard Logtalk library. - - Updated the config file for ECLiPSe 5.4~5.7 with missing ISO Prolog - predicate definitions needed for successful compilation of all entities - in the Logtalk standard library. - - Updated manual pages to comply with XHTML 1.0 Strict and to provide - better navigation. - - -2.15.4 - July 9, 2003 - - Corrected a spurious backtracking bug in the DCG rule translator. Added - two more examples of DCGs. - - New config file for XSB 2.6. Updated Logtalk compiler to compile cleanly - under XSB after applying the patch described in configs/NOTES. - - Updated SWI-Prolog config file to hide compiled entity predicates (requires - SWI-Prolog 5.2.3 or later version). New optional file configs/swihook.pl - contains hook code that allows Logtalk entities to be compiled and loaded - using SWI-Prolog load_files/2 and consult/1 predicates. - - Syntax definition file for the Hydra 1.1 (MacOS X) text editor providing - syntax coloring for editing Logtalk source files. - - Updated syntax coloring files for jEdit, NEdit, Vim, and TextPad in order - to recognize character code constants (0'x) and the DCG operator -->/2. - - -2.15.3 - June 27, 2003 - - Updated experimental support for DCG rules to prevent over-simplification - of unification goals in the compilation of rules to clauses. Push-back - lists can now be used on rule heads. - - The compilation mode of an entity (static/dynamic) is now stored in the - corresponding entity table (implying recompilation of all entities). - - Updated GNU Prolog config file to hide compiled entity predicates. - - Updated SWI-Prolog config file for better integration of Logtalk with - this compiler. - - -2.15.2 - April 2, 2003 - - Experimental support for DCG rules inside categories and objects. Added - built-in methods phrase/2 and phrase/3. - - Updated GNU Prolog config file to not hide compiled entity predicates in - order to avoid incompatibilities with dynamic entities. - - -2.15.1 - March 8, 2003 - - New example, msglog, of using events and monitors to record, replay, and - print user messages. - - Corrected a typo on the jEdit templates that resulted in syntax errors. - Corrected wrong year format in info/1 directive in all entity templates. - Added missing version info key to jEdit prototype template. - - Corrected documentation of built-in local methods self/1 and sender/1. - Updated documentation of built-in local methods parameter/2 and this/1. - - -2.15.0 - February 5, 2003 - - Changed "authors" key in info/1 directive to "author". - - Corrected documentation of built-in local method this/1. - - New geometric shapes example implemented in two versions, one - prototype-based and the other one class-based. - - Improved support for jEdit text editor by adding a set of programming - templates for use with the editor Templates plug-in. - - Added basic support for syntax highlighting and programming templates - for MacOS X Project builder. - - -2.14.7 - January 10, 2003 - - Corrected a bug in the built-in methods asserta/1 and assertz/1 when - asserting predicate rules. - - The built-in predicates logtalk_compile/1-2 and logtalk_load/1-2 now - accept both an entity (an atom) or a list of entities (a list of atoms). - - Optimized the code generated when compiling or asserting clauses for - dynamic predicates. - - Optimized protected inheritance performance on some Prolog compilers. - - -2.14.6 - December 31, 2002 - - Corrected a bug where the opening directive of an object that, - simultaneously, implements a protocol, imports a category, instantiates - a class, and specializes a superclass, will not be recognized. - - -2.14.5 - December 20, 2002 - - Simplified dynamic table of predicate declarations by removing two - redundant arguments. - - Corrected a bug where sending messages such as true/0 or !/0 to an - unknown object succeeded instead of throwing the correct exception. - - Simplified the code used to generate links in the lgtpdfa4.xsl and - lgtpdfus.xsl XSLT files. - - -2.14.4 - November 5, 2002 - - Removed definition of deprecated built-in predicate logtalk_version/3. - - Show flag names when printing at startup the default flag values. - - Small change to messages printed on console with smart compilation of - source files turned on. - - Updated YAP 4.3.x config file to use the YAP "system" library to access - the operating system for time, date, and file properties (enabling smart - source code compilation). - - Updated the lgtpdfa4.xsl and lgtpdfus.xsl XSLT files to workaround a bug - in the PassiveTeX 1.21 XSL:FO processor. - - -2.14.3 - September 16, 2002 - - New compiler option, doctype, to set the doctype reference (if any) - in the XML documenting files. Default value is "local" for backward - compatibility. Updated the user manual section on compiler options. - - The Logtalk built-in predicate logtalk_version/3 should be considered - deprecated (use current_logtalk_flag/3 instead). All references to this - predicate have been removed from the manuals. - - Updated the jEdit syntax coloring config file for the new jEdit 4.1 - version. - - Updated the lgtpdfa4.xsl and lgtpdfus.xsl XSLT files for compatibility - with the XSL:FO processors Apache FOP 0.20.4, PassiveTeX, and RenderX - and with the XSL W3C Recommendation of October 15, 2001. Updated the - pdf.bat and pdf.sh scripts to reference the latest version of the - Apache FOP processor (0.20.4). - - Changed the shell scripts html.sh and pdf.sh for compatibility with the - sh, bash, and zsh shells. - - -2.14.2 - August 26, 2002 - - Calls to built-in method parameter/2 are now compiled inline, improving - call performance. - - Updated Logtalk compiler to clean temporary compilation predicates after - compiling an entity instead of only before compilation. - - Updated YAP 4.3.x config file for better Logtalk integration by hiding - all internal compiler, runtime, and compiled entities static predicates. - - Updated GNU Prolog config file for better Logtalk integration by hiding - all internal compiler, runtime, and compiled entities predicates. - - Updated the XSLT conversion scripts lgtxml.xsl and lgthtml.xsl to correct - some HTML conformance errors in the generated pages. - - Corrected some XHTML conformance errors in the manual pages. - - -2.14.1 - July 31, 2002 - - New Windows NT script and updated Unix shell script for batch converting - XML documenting files to HTML. Both scripts also generate an index.html - file containing links to all converted XML documenting files. - - Corrected wrong XHTML DOCTYPE declaration in manual pages. - - -2.14.0 - July 26, 2002 - - Renamed all compiler and runtime internal predicates and all auxiliary - predicates in the config files to start with a "$" character. - - New compiler option, code_prefix, to set a prefix for all Prolog code - functors generated by Logtalk when compiling entities. Default is ''. - - New compiler option, named_anonymous_vars, that instructs the compiler to - interpret variables that start with an underscore as anonymous variables - (and to not report them as singleton variables). Default value is "off". - - Directive info/2 was wrongly declared as a entity directive instead of a - predicate directive. - - Converted all manual pages to XHTML 1.0 format. Corrected a wrong link in - the reference manual. Replaced GIF images by PNG versions. - - Updated BProlog 6.x config file to workaround the new 6.2 built-in - predicate ::/2 that conflicts with the same named Logtalk message sending - operator. - - Removed call to the obsolete built-in predicate nodbgcomp/0 from all - ECLiPSe config files. - - -2.13.0 - June 15, 2002 - - Logtalk now outputs Prolog code using write_canonical/2 instead of - write_term/3. Goals are better portability of the generated Prolog files - and avoid issues with clauses with long bodies for Prolog compilers that - use a term print depth limit to prevent problems with cyclic terms. - - Added report of default flag values at Logtalk startup. - - Logtalk now prints a warning when redefining parametric objects. - - Removed need of an abort/0 predicate from the Logtalk debugger example. - Removed any definition of this predicate from the config files. - - Added missing definitions for some ISO built-in predicates to the Amzi! - Prolog 6.2.2 config file. - - -2.12.0 - May 25, 2002 - - New read-only Logtalk flag "version". Corrected exception term generated - when trying to modify a read-only flag using the set_logtalk_flag/2 - built-in predicate. - - Updated config file for OpenProlog 1.1b5. - - New config file for ECLiPSe 5.4. - - Renamed config files for CIAO 1.7 (beta of 1.8) to "ciao_aux18.config" - and "ciao18.config". - - Updated config file for Amzi! Prolog 6.2.2. - - New example of using some of the built-in database handling methods - (dynpred). - - Syntax configuration files for jEdit 4.0, VIM 6.1, NEdit 5.2, and - TextPad 4.5 text editors providing syntax highlighting for editing - Logtalk source files. - - -2.11.0 - April 22, 2002 - - Added a "smart compilation" feature to the Logtalk compiler, controlled - by a "smart_compilation" flag. Only available in Prolog compilers that - provide access to file modification dates. - - Added a "startup_message" flag to control printing of the Logtalk banner - at startup. - - Reworked Logtalk pre-processor compilation and loading reports. Compiler - option "report" now toggles between normal reporting (as specified by the - other flags) and silent compilation/loading of source files. - - -2.10.0 - April 5, 2002 - - Scope of object asserted predicates for which there is no declaration is - now a function of the context instead of always being declared public. - Asserting in this, the predicate is declared private, asserting in self, - the predicate is declared protected, otherwise the predicate is declared - public. - - Throw an error if a category contains clauses for dynamic predicates. - - Updated documentation on categories and built-in methods for database - handling. - - Retracting all clauses for a dynamic predicate from an object now allows - an inherited definition to be called when sending the corresponding - message. In previous versions the message just failed. - - Added missing entries for the built-in predicates current_logtalk_flag/2 - and set_logtalk_flag/2 to the Logtalk compiler built-in predicates table. - - Updated config file for Amzi! Prolog 6.1.74. - - Updated notes on patching XSB to work with Logtalk. - - -2.9.3 - February 9, 2002 - - New current_logtalk_flag/2 and set_logtalk_flag/2 built-in predicates. - - Updated documentation on new built-in predicates. - - Renamed SWI-Prolog config file swi330.config to swi.config. - - Renamed config file predicate lgt_default_compiler_option/2 to lgt_flag/2. - - New XSL style-sheets and shell scripts to convert Logtalk XML entity - documenting files to PDF format using XSL Formating Objects. - - -2.9.2 - January 4, 2002 - - The Logtalk compiler can now print a warning when compiling source files - that use non-ISO defined built-in predicates using a new portability/1 - compiler option. Updated the relevant sections of the user manual and the - errors example. - - Corrected a compiler bug where the entity relation tables only recorded - the last entry per entity relation type. - - Updated config file for CIAO 1.7#162. - - -2.9.1 - December 5, 2001 - - Logtalk compiler now prints a warning when redefining or replacing an - existing entity. - - Corrected a compiler bug in the error checking code for the info/1 - and info/2 directives. - - Changed the order of object loading in the "mi" example to avoid - spurious warning messages. - - Added a new problem ("bridge") to the "searching" example. Improved - "performance" monitor to give correct reports on alternative solutions. - Corrected a bug in the "water jug" state space example. - - -2.9.0 - October 22, 2001 - - Added config files for CIAO Prolog 1.7p115 and B-Prolog 6.0. - - Compiling and loading an entity that contains references to unknown - entities (by default) prints a warning. Updated user and reference - manuals. - - Rewritten all the compiler warning/error code and output messages. - - Changed compiled code functors postfixes from "_sdcl" and "_sdef" to - "_idcl" and "_idef" (implies recompilation of all objects, protocols, - and categories). - - Changed all occurrences and references to the term "entity_scope" to - "scope". - - Removed some redundant productions from the Logtalk grammar. - - Updated documentation on the xml directory. Renamed some of the .xsl - files. Added sample scripts to batch convert .xml files to .html files. - - Added a new loader utility file, all.loader, to load all library files - loaded by the other loader files. - - Started work on documenting the Logtalk pre-processor/compiler source - file. - - New "errors" example. Updated the "inheritance" example. - - -2.8.4 - March 9, 2001 - - Updated config files for BinProlog 8.0, K-Prolog 5.01, XSB 2.3, and - Amzi! Prolog 4.103~5.0. - - New config file for Amzi! Prolog 6.1 beta. - - Corrected an incomplete entity definition in the Logtalk XML DTD. - Rewrite the Logtalk XSLT files for improved compatibility with XSLT - processors regarding handling of whitespace. - - A first cut of a XML Schema for the Logtalk XML documentation files - (file xml/logtalk.xsd). - - Small improvements to the documentation. - - -2.8.3 - November 21, 2000 - - Corrected a bug where sending a message for a built-in method to an - unknown object fails instead of generating the expected exception. - - Put some occurrences of atoms public, mode, and type between ()'s to - avoid compilation errors in BinProlog 8.0 and other Prolog compilers - that declare these atoms as operators. - - Corrected the definition of the state space of the "Missionaries and - Cannibals" problem in the "searching" example that resulted in some - wrong solutions. - - -2.8.2 - November 5, 2000 - - New .xsl file to convert .xml files to TeXML files. - - Fixed a problem with explicit compilation options being correctly parsed - but not processed. - - Corrected a bug regarding default init options definition for the - points, polygons, and bricks examples. Updated category initialization - in roots example. - - -2.8.1 - October 28, 2000 - - New config file for K-Prolog 5.0. - - Improved compiler error detection and reporting of invalid directives - and clauses. - - Corrected a problem with some Prolog compilers where compiling a file - containing syntax errors may not close the file after the errors are - reported. - - Many small improvements to all documentation. - - Small improvements to the .xsl files and to the output of .xml files. - - -2.8.0 - October 1, 2000 - - I have found just a few days ago that I have uploaded to the Logtalk web - server a development version of Logtalk 2.7.0 instead of the final one! - To avoid confusions I decided to release a new version. - - Changed implementation of the logtalk_compile/1-2 and logtalk_load/1-2 - predicates to only accept a list of entities instead of either an entity - or a list of entities, simplifying and improving the performance of these - predicates. Improved error reporting for the logtalk_compile/1 and - logtalk_load/1 predicates. Updated relevant sessions in the user and - reference manuals. - - Simplified the implementation of the following predicates, by sharing - the error checking code with the corresponding extended versions: - implements_protocol/2, imports_category/2, instantiates_class/2, - specializes_class/2, extends_protocol/2, and extends_object/2. - - Completed some missing library file dependencies documentation in some - examples. - - New version of the QUICK_START help file. Updated tutorial. - - -2.7.0 - August 24, 2000 - - First release of the Logtalk standard library of objects, protocols and - categories. - - Rewritten all examples to use the new Logtalk standard library. - - New logtalk_load/2 and logtalk_compile/2 Logtalk built-in predicates, - accepting a list of compiler options. See the User and Reference Manuals - for details. - - New XSLT file for viewing .xml files in Microsoft Internet Explorer 5.5 - for Windows after installing the latest Microsoft XML Parser Preview - Release. Small improvements in all XSLT files. - - Starting with this version all config files need to provide a definition - for the compare/3 predicate if it is not built-in in the corresponding - Prolog compiler. Also, default Logtalk compiler options are now also set - in the config files using the lgt_default_compiler_option/2 predicate. - - Updated config file for CIAO 1.6p1. See the configs/NOTES file for - details. - - -2.6.2 - July 4, 2000 - - Improved performance and error checking for the built-in predicates - create_object/4, create_protocol/3 and create_category/4. - - Updated config file for BinProlog 7.83. - - Many small updates to all documentation. - - New PDF versions of the documentation formated for printing (with page - numbers, table of contents and index)are now available in both A4 and - US letter formats. - - -2.6.1 - May 5, 2000 - - Modified the structure of the automatically generated XML documenting - files to improve XSL translation performance. Added a new, more standard - compliant, XSL file to generate HTML files and renamed the old one to - ie5.xsl. See the xml/NOTES file for details. Corrected an error in the - logtalk.css CSS file. - - Modified the definitions of predicates lgt_file_extension/2 and - lgt_file_name/2 in all config files. - - Updated all the user manual sessions related to automatic documentation. - - Updated all HTML documentation for future XHTML 1.0 conformance. - - Start adding documenting directives to most examples. - - -2.6.0 - April 27, 2000 - - Added support for documentation of objects, protocols, and categories, - using automatic generation of XML files. - - Added info/1 and info/2 directives for documenting objects, protocols, - categories, and predicates. Added definition of documentation file name - extension and default file names for the DTD and XSL files to the config - files. - - Improved error checking for the built-in predicates create_object/4, - create_protocol/3 and create_category/4 to also detect invalid entity - identifiers. - - Updated the user and reference manuals to describe the new automatic - documenting features. - - Updated all HTML documentation to conform to HTML 4.01 strict standard. - - Corrected some wrong cross-reference links and titles in the reference - and user manuals HTML pages. - - PDF versions of the manuals and tutorial are now available in both A4 - and US letter formats. - - Corrected two errors in the searching example, one in the definition of - the farmer problem state space and the other when backtracking over - performance reports. - - -2.5.2 - March 7, 2000 - - Updated manuals to clarify some limitations of declaring and defining - dynamic predicates inside categories and documented a way of using the - built-in local method this/1 to access object parameters. - - Removed references to parametric categories from the Logtalk - documentation (at runtime we can only access object parameters, - not category parameters). - - Corrected two wrong declarations of built-in methods (forall/2 and - retractall/1) in the Logtalk pre-processor. - - Corrected bug where predicates declared in dynamic entities may have - a "static" instead of a "dynamic" property. - - Corrected a bug in category compilation that prevented a dynamic category - from being abolished. Speedup predicate definition lookups for categories. - - -2.5.1 - February 18, 2000 - - Two new examples: birds, a bird identification expert system adopted - (with permission) from an Amzi example, and viewpoints, a set of - prototypes showing how to do property sharing and value sharing in - Logtalk. - - Renamed config file yap421.config to yap430.config to match the name of - the new YAP 4.3.0 public release (named 4.2.1 while on beta testing). - - Partial config file for Trinc Prolog R3. - - -2.5.0 - December 29, 1999 - - The Logtalk pre-processor now accepts arbitrary clauses and directives - to appear in a file before an opening entity directive. The clauses and - directives are added unchanged to the compiled file. - - Improved performance for all kinds of message sending. - - Two new examples: reflection, showing how to implement a simple - class-based reflective system, and symdiff, showing how to use - parametric objects to implement symbolic expression differentiation - and simplification. - - Updated config file for the beta 8 release of SWI-Prolog 3.3.0. - - -2.4.0 - December 1, 1999 - - Logtalk is now an Open Source project, available under Perl's Artistic - license. - - Two new examples: instmethods, illustrating the use of instance defined - methods, and classvars, showing how to implement class variables. - - Updated Logtalk grammar to explicitly allow for user-defined types - in mode/2 directives. - - New config files for SWI-Prolog 3.3.0, SICStus Prolog 3.8 and CIAO - Prolog 1.4p0 (incomplete). - - Updated config file for B-Prolog 4.0. - - Updated config file for GNU Prolog to use the new call_with_args() - built-in predicate added in version 1.1.0. - - Updated config file for YAP Prolog to use the new call_with_args() - built-in predicate added in version 4.2.1. - - -2.3.1 - September 22, 1999 - - Logtalk pre-processor updated to only report one warning per redefined - Logtalk or Prolog built-in predicate. - - Changed some occurrences of atom "public" to "(public)" in - compiler/logtalk.pl file to avoid syntax errors in Prolog compilers - (like BinProlog) that define "public" as an operator. Also put some - terms between ()'s to avoid syntax errors with ALS Prolog 3.1 - - Update config file for ALS Prolog to work with version 3.1. - - Updated configs/NOTES file include a workaround to use Logtalk with - XSB 2.0, some guidelines on how to write loader utility files for - BinProlog 7.50, and a bug in ALS Prolog 3.1 that affects Logtalk. - - -2.3.0 - September 12, 1999 - - Metapredicate information is now stored with the other predicate - properties, instead of being discarded after compiling the clauses of - a metapredicate. Added predicate property metapredicate/1. It is now - possible to assert clauses for dynamic metapredicates. - - Corrected a bug in the processing of metacalls in pseudo-object user. - - Corrected a bug in the implementation of private inheritance. - Improved performance of protected inheritance. - - Corrected failure of processing initialization/1 and op/3 directives in - create_object/4, create_category/4 and create_protocol/3 built-in - predicates. - - Corrected a bug when calling private static category predicates from - importing objects. Simplified code generated for categories. - - Rewrite code for the built-in method current_predicate/1 to avoid - duplicated or wrong results when overriding predicate declarations - and to ensure that all possible argument type errors are detected. - - Changed compilation of classes that do not instantiate any (meta)class - in order to throw the correct exception when a message is sent to them. - - Changed compilation of root objects (that do not instantiate, specialize - or extend other objects) so that calls to "super" (^^/1) fail (as they - should) instead of generating a "predicate does not exist" error message. - - Changed implementation of "super" calls (^^/1) to avoid a potential - endless loop problem when using these calls from the inheritance root - object of a reflexive class-based systems. - - Pre-processor now checks for callable and object identifier errors. - Runtime now checks for non-instantiated messages. - - Added new example (inheritance) about public, protected and private - inheritance. - - Updated metapredicates, lo, kernel, and types examples. Most of the - code in the last two examples is being updated to form the basis of an - upcoming Logtalk standard library. - - Small changes in the pre-processor/runtime code for compatibility with - ECLiPSe 4.2.2. Updated config files for this Prolog compiler. - - Rewrite some predicates in the config files for SWI-Prolog and LPA - Mac & WIN Prologs for improved performance. - - New tutorial session about events and monitors. - - Updated documentation to match the changes made in this version. - - -2.2.0 - July 10, 1999 - - Implemented public, protected and private object inheritance, protocol - implementation and category importation. - - New Logtalk built-in predicates instantiates_class/3, extends_object/3, - extends_protocol/3, specializes_class/3, imports_category/3 and - implements_protocol/3. The third argument returns the relation scope. - - Pre-processor now checks most directive errors. - - Changed ^^/1 (super call) implementation to only allow the use of a - single predicate call for argument and to retain the original sender - of the message (see the updated sicstus example). - - Fixed bug that prevented directives with a variable number of arguments - (like dynamic(), public(), uses(), ...) being recognized. - - Changed definition of predicate read_term/3 in the configs files of Amzi!, - Aquarius, Arity, Eclipse, IC, K, LPA Mac&WIN, Master and XSB to always - instantiates the singleton variables list to the empty list. Needed to - prevent backtracking problems in logtalk_load/1 and logtalk_compile/1 - predicates. - - Removed choice-point in processing metacalls in predicate definitions. - - A banner with the Logtalk version is printed after loading the runtime/ - pre-processor. - - Removed variables example. The category attributes is now part of the - kernel example. Corrected some harmless syntax errors in directives in - kernel/attributes.lgt, kernel/monitor.lgt and miscellaneous/queens.lgt. - - Changed name of blocks example to bricks and object "block" to "brick" - in order to avoid problems with some Prolog compilers that use the atom - "block" for operators or built-in predicates. - - -2.1.0 - May 11, 1999 - - Fixed some bugs in the definition of the pseudo-object user when sending - the message predicate_property/2. - - Renamed config file for Calypso to GNU Prolog. - - New config file for LPA WinProlog 4.0. - - Corrected the omission in the documentation of the Logtalk grammar of the - built_in entity property. - - New tutorial pages about building reflective class-based systems. - - Modified pre-processor to compile throw/1 as a control structure to - ensure compatibility with the GNU-Prolog compiler. - - Modified pre-processor to ensure compatibility with Prolog compilers that - use immediate update semantics instead of the ISO logical database update. - - Improved simplification of compiled object and category clauses. - - Rewrite and clean up pre-processor code for better compiler performance. - - Several updates to the examples files. - - Changed all example loader files to wrap the call to logtalk_load/1 inside - an initialization/1 directive for ISO standard compliance. - - -2.0 GM - February 9, 1999 - - Removed some redundant choice-points that are being created when - compiling Logtalk entities. - - Small compilation speed optimizations. - - Logtalk compiled files now contain the declarations for the message - sending operators to ensure compatibility with some Prolog compilers. - - Changed the way Logtalk pre-processor writes directives to ensure - compatibility with some Prolog compilers. Corrected a bug in the - processing of the op/3 directive. - - Updated PrologII+ config file for version 4.5. - - Changed the definitions of catch/3 and throw/1 in the config files for - LPA Prolog compilers. - - New config file for MasterProlog 4.1; removed config file for the - old BIM Prolog 4.0. - - Corrected an error in the config file for OpenProlog in the definition - of the write_term/3 predicate. - - Added a safer definition for write_term/3 predicate in the config - files for Amzi, Aquarius, Arity, Eclipse, IC, K, LPA Mac, LPA Win, - and XSB Prolog compilers. - - Added a QUICK_START file. - - -2.0 Beta 3 - February 1, 1999 - - Closed some encapsulation holes in the implementation of super calls. - - Changed Logtalk pre-processor to use write_term/3 instead of write/2 and - writeq/2 to workaround some compatibility problems with some Prolog - compilers. - - Changed mode operators priority and type to be compatible with the ISO - standard. - - Modified definition of predicate read_term/3 in the config file for Amzi - compiler to return the atom end_of_file instead of '!EOF' at the end of - a file (this prevented Logtalk to complete compilation any file under - this compiler). Improved detection of built-in predicates while compiling. - - Removed config file for wamcc. This compiler have been replaced by - Calypso (developed by the same author). - - Updated K-Prolog config file for version 4.50. - - Improved documentation of template config file. - - Added SCRIPT files to the kernel and types examples. - - Updated Tutorial and User and Reference Manuals. - - New end user license. - - -2.0 Beta 2 - November 16, 1998 - - Built-ins logtalk_compile/1 and logtalk_load/1 updated to match - the documentation regarding thrown errors and to accept a list of - entities to compile/load. - - Modified the examples loader utility files to make only a call to - logtalk_load/1 by using a list of entities. This should make it easy to - modify these files for compilers that don't support arbitrary queries - in a file. - - Logtalk runtime no longer tries to catch some of the errors thrown - by ::/2. - - Added to all config files a Logtalk predicate to check if a file - exists in the current working directory (used by the logtalk_load/1 - and logtalk_compile/1 Logtalk built-in predicates). - - New configs files for the K-Prolog 4.14 and Calypso 1.0b6 Prolog - compilers. - - Completed the config file for Open Prolog 1.03d38 (with the exception - of lgt_current_date/3 that still have a dummy definition). - - Added a missing definition for Logtalk predicate forall/2 to the config - file for Prolog II+ 4.4. - - Modified Logtalk pre-processor/runtime to avoid syntax errors when - running on Open Prolog or Calypso and to remove some redundant - choice-points that are being created when compiling categories and - protocols. - - Modified some examples that use operators to avoid syntax errors in - some Prolog compilers. - - Modified the implementation of the built-in method - predicate_property/2 to avoid duplicate answers and to throw an - instantiation error if the first argument is not bound. - - Modified definition of the pseudo-object user to hide Logtalk pre- - processor predicates from the current_predicate/1 built-in method and - to ensure that the predicate_property/2 built-in method returns - Logtalk defined predicate properties for built-in Logtalk and Prolog - predicates. - - Modified Prolog code generated by the pre-processor to further minimize - possible conflicts with user defined predicates. - - Added a lgt_predicate_property/2 predicate to the config files to - improve Logtalk portability. - - Updated Tutorial and User and Reference Manuals. - - -2.0 Beta 1 - October 18, 1998 - - Added basic support for implementation multi-inheritance. - - Logtalk pre-processor updated to try to detect misspelt local - predicate calls. - - First public beta. - - -2.0 Alpha 1 - July, 1998 - - First release for registered users. diff --git a/Logtalk/UPGRADING.txt b/Logtalk/UPGRADING.txt deleted file mode 100644 index 2a84a177b..000000000 --- a/Logtalk/UPGRADING.txt +++ /dev/null @@ -1,175 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.8 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -Upgrading from Logtalk 1.x -========================== - -Logtalk 2.x is not compatible with programs written for Logtalk 1.x. -However, you should be able to translate most programs to make them -run under Logtalk 2.x. Most of the examples provided with Logtalk 1.x -have been rewritten to run under Logtalk 2.x. You may use them as -translation examples. - - -Upgrading from a previous Logtalk 2.x versions -============================================== - -Changes in the Logtalk compiler between releases may render Prolog config -files from older versions incompatible with new ones. You may need to update -your local Logtalk user files by running e.g. the "cplgtdirs" shell script. - -If your Logtalk programs depend on some of the example files, it is -advisable that you check your code against the new version before -throwing away the older release. - -Logtalk source files will need to be recompiled because of the changes -done in the version 2.5.0 to improve message sending performance. - -Logtalk version 2.7.0 provides the first cut of the Logtalk standard library. -Most examples have been rewritten to take advantage of the library. - -Logtalk version 2.8.0 introduces a small change on the logtalk_compile/1-2 -and logtalk_load/1-2 predicates that may imply updating your loader utility -files: the first argument is now always a list of entities even if we want -to compile or load a single entity. - -Logtalk version 2.9.0 changes compiled code functors postfixes from "_sdcl" -and "_sdef" to "_idcl" and "_idef", implying recompilation of all objects, -protocols, and categories. - -Logtalk version 2.10.0 changes some of the semantics of object dynamic -predicates. See the release notes for a description of the changes. - -Logtalk version 2.14.4 removes the definition of the deprecated built-in -predicate logtalk_version/3 (use current_logtalk_flag/3 instead). - -Logtalk version 2.14.5 changes compiled code in order to correct a bug -where sending messages such as true/0 to an unknown object will succeeded -instead of throwing the expected exception, implying recompilation of all -objects, protocols, and categories. - -Logtalk version 2.14.7 changes compiled code in order to optimize the -code generated by the compilation of dynamic predicate clauses. - -Logtalk version 2.15.0 changes the "authors" key in the directive info/1 to -"author". All the XSLT, DTD, and XSD files have been update to conform to -this change. If you use the directive info/1 in your programs, you will need -to apply this change to take advantage of automatic generation of documenting -files. - -Logtalk version 2.15.3 changes the format of the runtime entity tables, -implying recompilation of all objects, protocols, and categories. - -Logtalk version 2.15.6 renamed the compiler flag "named_anonymous_vars" to -"underscore_variables" and changed the possible option values form "on/off" to -"dont_care/singletons". - -Logtalk 2.16.0 improves support for the declaration and use of operators -local to objects and categories. Recompilation of any objects and categories -containing operator declarations is needed in order to take advantage of the -improvements made. - -Logtalk 2.16.1 now checks for attempts to redefined built-in Logtalk control -constructs when compiling source files. These checks may generate compilation -errors on files containing bugs that are not detected on previous versions of -the compiler. - -Logtalk version 2.16.2 changed the possible option values of the read-only -compiler flag "startup_message" to "none", "banner", and "flags". Default -value is "flags" (print both banner and default flag values). - -Logtalk version 2.17.1 removes predicate nth/3 from library entities listp, -list, and difflist (replaced by the predicates nth0/3 and nth1/3). - -Logtalk version 2.20.0 updates the semantics of the uses/1 entity directive -to accept as argument a single object identifier (this change is needed in -order to ensure compatibility with the new uses/2 predicate directive). - -Logtalk version 2.21.2 adds a new clause to the code generated when compiling -entity in order to support the new alias/1 predicate property, implying -recompilation of all objects, protocols, and categories. - -Logtalk version 2.22.0 adds support for using the notation () -when compiling and loading source files. Logtalk applications using this new -notation will need to be modified in order to run in previous Logtalk versions. -In addition, the exceptions generated by the predicates logtalk_compile/1-2 -and logtalk_load/1-2 have been updated to take into account this new feature. - -Logtalk version 2.22.2 adds stricter checking for the documenting directives -(info/1 and info/2), which can lead to compilation errors on entities which -compiled successfully on previous Logtalk versions. - -Logtalk version 2.22.5 adds new predicates to all config files (consult the -release notes for details). If you are using custom config files, be sure to -update them by coping the definition of the new predicates. - -Logtalk version 2.23.0 features new, optimized implementations of the database -built-in methods, implying the recompilation of all objects, protocols, and -categories. - -Logtalk version 2.25.0 drops support for source metafiles and .mlgt file name -extension as this version features a new, file-based compiler supporting the -definition of any number of entities in a single file. Older code using source -metafiles will need to rename the file name extensions from .mlgt to .lgt. - -Logtalk version 2.25.1 updates the compiler to generate XML documenting files -whose names always contain the arity of the entity identifier appended at the -end (using the format "_arity"). This change implied updates to the lgt2xml.* -and lgt2html.* shell scripts which render them incompatible with the XML files -generated by previous Logtalk versions. - -Logtalk version 2.27.0 changes representation of declared predicates in order -to support the new predicate property non_terminal/1, implying recompilation -of all objects, protocols, and categories. - -Logtalk version 2.27.1 optimizes the generation of predicate definition and -declaration linking clauses, resulting in small performance improvements and -in space savings for the Prolog code generated when compiling Logtalk entities. -Recompilation of all objects, protocols, and categories is necessary in order -to take advantage of this optimizations. - -Logtalk 2.28.0 changes representation of meta-predicates, implying the -recompilation of all objects, protocols, and categories that define them. -In addition, in order to close some security holes where meta-predicates -could be used to bypass predicate scope declarations, meta-predicates that -use closures must be re-implemented to use the new call/N Logtalk built-in -predicate. The directive metapredicate/1 is now deprecated, the directive -meta_predicate/1 should be used instead. There are also changes to the -config files that render the Logtalk runtime incompatible with the config -files of previous versions. - -Logtalk 2.29.0 makes some incompatible changes to the experimental support -for multi-threading programming that may imply updating any application that -uses the multi-threading predicates. The default value of the compiler flag -events/1 is now off. Applications using event-driven programming must either -turn this flag on or compile source files with the events(on) option. The -library protocol "event_handlersp" is now deprecated; new code should use -instead the built-in "monitoring" protocol. The new support for "threaded" -and "synchronized" entity properties implies recompilation of all objects -and categories. - -Logtalk 2.29.2 removes the built-in predicate threaded_discard/1. - -Logtalk 2.29.5 adds a new compiler option, "reload", whose default value is -defined in the config files. This makes previous config files incompatible -with this new Logtalk version. - -Logtalk 2.30.0 adds two new compiler options, "xmldir" and "tmpdir", allowing -a per-project definition of directories for storing XML documenting files and -for storing intermediate compilation files (e.g. Prolog files). Removed from -the config files the predicate '$lgt_alt_directory'/2. Older config files are -incompatible with this new Logtalk version. - -Logtalk 2.30.6 renamed the compiler flags "supports_break_predicate", -"supports_encoding_dir", and "underscore_vars" to, respectively, -"break_predicate", "encoding_directive", and "underscore_variables". Changed -the possible values of the "encoding_directive" compiler option (see manual). -Older config files are not compatible with this new Logtalk version. - -Logtalk 2.30.7 adds a new compiler flag "context_switching_calls". -Older config files are not compatible with this new Logtalk version. diff --git a/Logtalk/contributions/NOTES.txt b/Logtalk/contributions/NOTES.txt deleted file mode 100644 index 3d4460eda..000000000 --- a/Logtalk/contributions/NOTES.txt +++ /dev/null @@ -1,26 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - -This folder contains code contributions from Logtalk users. Here is -a short description of each included contribution: - -iso8601.lgt - Contributed by: Daniel L. Dudley - - This is a partial implementation of the ISO 8601 standard, - providing a library of date predicates. The time predicates - are not yet implemented. The best way to get acquainted with - this library is for you to compile the object and then run - one of the documentation helper scripts to transform the - resulting XML file into (X)HTML or PDF documentation. Your - feedback is appreciated. - -xml_parser - Contributed by: John Fletcher - - This folder contains a Logtalk version of John Fletcher's - Prolog XML parser (http://www.zen37763.zen.co.uk/xml.pl.html). diff --git a/Logtalk/contributions/iso8601.lgt b/Logtalk/contributions/iso8601.lgt deleted file mode 100755 index 4a8219afb..000000000 --- a/Logtalk/contributions/iso8601.lgt +++ /dev/null @@ -1,664 +0,0 @@ -/****************************************************************************** - - Library: ISO8601.PL - Copyright (c) 2004-2005 Daniel L. Dudley - - Purpose: ISO 8601 (and European civil calendar) compliant library of date - and time (clock) related predicates. That is, an ISO 8601 handler. - - Author: Daniel L. Dudley - Created: 2004-02-18 - -******************************************************************************/ - - -:- object(iso8601). - - :- info([ - version is 1.0, - author is 'Daniel L. Dudley', - date is 2005/04/11, - comment is 'ISO 8601 (and European civil calendar) compliant library of date predicates.', - remarks is [ - 'Scope:' - 'This object currently provides a powerful, versatile and efficient set of date-handling predicates, which--thanks to Logtalk--may be used as is on a wide range of Prolog compilers. Besides taking time to familiarize oneself with each predicate, the user should take note of the following information.', - 'Validation of dates: ' - 'Date parts are not validated--that is the caller''s responsibility! However, not being quite heartless yet, we do provide a predicate for this purpose.', - 'Date arithmetic:' - 'Many of the examples illustrate a simplified method of doing date arithmetic. Note, however, that we do not generally recommend this practice--it is all too easy to make mistakes. The safest way of finding the day difference between two dates is to first convert the dates to their Julian day numbers and then subtract one from the other. Similarly, the safe way to add or subtract a day offset to a particular date is to first convert the date to its Julian day number, add or subtract the day offset, and then convert the result to its corresponding date.', - 'BC years' - 'ISO 8601 specifies that the Gregorian calendar be used, yet requires that years prior to 1 AD be handled arithmetically, i.e., the year we know as 1 BC is year 0, 2 BC is year -1, 3 BC is year -2 and so on. We do not follow ISO 8601 with regard to the handling of BC years. Our date predicates will accept and interpret an input year 0 as 1 BC; however, a negative year, Year, should always be interpreted as abs(Year) =:= Year BC. We believe that the average person will find our handling of BC years more user-friendly than the ISO 8601 one, but we encourage feedback from users with a view to a possible change in future versions.', - 'Week numbers:' - 'It is possible for a day (date) to have a week number that belongs to another year. Up to three of the first days of a calendar year may belong to the last week (number) of the prior calendar year, and up to three days of the last days of a calendar year may belong to the first week (number) of the next calendar year. It for this reason that the Week parameter in date/6-7 is a compound term, namely week(WeekNo,ActualYear).', - 'Computation of Gregorian Easter Sunday:' - 'The algorithm is based upon the "Gaussian rule". Proleptic use is limited to years > 1582 AD, that is, after the introduction of the Gregorian calendar.', - 'Some Christian feast day offsets from Easter Sunday:' - 'Carnival Monday: -48 days, Mardi Gras (Shrove Tuesday): -47 days, Ash Wednesday: -46 days, Palm Sunday: -7 days, Easter Friday: -2 days, Easter Saturday: -1 day, Easter Monday: +1 day, Ascension of Christ: +39 days, Whitsunday: +49 days, Whitmonday: +50 days, Feast of Corpus Christi: +60 days.' - ]]). - - % CORE PREDICATES: - - :- public(date/4). - :- mode(date(?integer, ?integer, ?integer, ?integer), zero_or_one). - :- info(date/4, [ - comment is 'Get the system date and/or its Julian Day # or convert a Julian Day # to/from given date parts.', - arguments is [ - 'JD' - 'Julian day serial number', - 'Year' - '0 or negative if converted BC year, positive otherwise', - 'Month' - 'Normally an integer between 1 and 12 inclusive', - 'Day' - 'Normally an integer between 1 and 31 inclusive depending upon month'], - examples is [ - 'Current date (i.e., today):' - date(JD,Y,M,D) - {JD = 2453471, Y = 2005, M = 4, D = 10}, - 'Convert a date to its Julian day number:' - date(JD,2000,2,29) - {JD = 2451604}, - 'Convert a Julian day number to its date:' - date(2451604,Yr,Mth,Day) - {Yr = 2000, Mth = 2, Day = 29}, - 'What is the date of day # 60 in year 2000?' - date(J,2000,1,60) - {J = 2451604}, - 'What is the Julian of the 1st day prior to 2000-1-1?' - date(J,2000,1,0) - {J = 2451544}, - 'What is the Julian of the 60th day prior to 2000-1-1?' - date(J,2000,1,-59) - {J = 2451485}, - 'Illegal date is auto-adjusted (see also next query)' - date(JD,1900,2,29) - {JD = 2415080}, - 'This is the correct date!' - date(2415080,Y,M,D) - {Y = 1900, M = 3, D = 1}]]). - - :- public(date/5). - :- mode(date(?integer, ?integer, ?integer, ?integer, ?integer), zero_or_one). - :- info(date/5, [ - comment is 'Ditto date/4 + get/check its day-of-week #.', - arguments is [ - 'JD' - 'Julian day serial number', - 'Year' - '0 or negative if converted BC year, positive otherwise', - 'Month' - 'Normally an integer between 1 and 12 inclusive', - 'Day' - 'Normally an integer between 1 and 31 inclusive depending upon month', - 'DoW' - 'Day of week, where Monday=1, Tuesday=2, ..., Sunday=7'], - examples is [ - 'Get the Julian and the day-of-week # of a date:' - date(JD,2000,2,29,DoW) - {JD = 2451604, DoW = 2}, - 'Check the validity of a given date (day-of-week is 2, not 4):' - date(JD,2002,3,5,4) - {no}, - 'Get the Julian day of a given date if it is a Sunday:' - date(JD,2004,2,29,7) - {JD = 2453065}, - 'Get the date and day-of-week # of a Julian:' - date(2451545,Y,M,D,DoW) - {Y = 2000, M = 1, D = 1, DoW = 6}]]). - - :- public(date/6). - :- mode(date(?integer, ?integer, ?integer, ?integer, ?integer, ?compound), zero_or_one). - :- info(date/6, [ - comment is 'Ditto date/5 + get/check its week #.', - arguments is [ - 'JD' - 'Julian day serial number', - 'Year' - '0 or negative if converted BC year, positive otherwise', - 'Month' - 'Normally an integer between 1 and 12 inclusive', - 'Day' - 'Normally an integer between 1 and 31 inclusive depending upon month', - 'DoW' - 'Day of week, where Monday=1, Tuesday=2, ..., Sunday=7', - 'Week' - 'Compound term, week(WeekNo,ActualYear), of a day'], - examples is [ - 'Get the day-of-week and week number of a date:' - date(_,2000,1,1,DoW,Wk) - {DoW = 6, Wk = week(52,1999)}, - 'Get the week number and year of this week:' - date(_,_,_,_,_,Wk) - {Wk = week(7, 2004)}, - 'Get the Julian number and the week of a date if it is a Sunday:' - date(JD,2004,2,29,7,Wk) - {JD = 2453065, Wk = week(9,2004)}, - 'Get the day-of-week and week of a Julian day number:' - date(2453066,_,_,_,DoW,Wk) - {DoW = 1, Wk = week(10,2004)}, - 'Check that given date data matches:' - date(_,2004,3,1,1,week(10,2004)) - {yes}, - 'What is the date of a day of week (default is 1) in given week # and year?' - date(_,Y,M,D,DoW,week(26,2004)) - {Y = 2004, M = 6, D = 21, DoW = 1}, - 'Ditto for Sunday:' - date(_,Y,M,D,7,week(1,2005)) - {Y = 2005, M = 1, D = 9}, - 'Ditto for Tuesday in following week:' - date(_,Y,M,D,9,week(1,2005)) - {Y = 2005, M = 1, D = 11}, - 'Ditto for Thursday in the prior week:' - date(_,Y,M,D,4,week(0,2005)) - {Y = 2004, M = 12, D = 30}, - 'Ditto for Tuesday two weeks prior:' - date(_,Y,M,D,2,week(-1,2005)) - {Y = 2004, M = 12, D = 21}, - 'Ditto for Saturday:' - date(_,Y,M,D,6,week(53,2004)) - {Y = 2005, M = 1, D = 1}, - 'Ditto for Monday (note automatic compensation of nonexistent week number):' - date(_,Y,M,D,1,week(60,2004)) - {Y = 2005, M = 2, D = 14}]]). - - :- public(date/7). - :- mode(date(?integer, ?integer, ?integer, ?integer, ?integer, ?compound, ?integer), zero_or_one). - :- info(date/7, [ - comment is 'Ditto date/6 + get/check its day-of-year #.', - arguments is [ - 'JD' - 'Julian day serial number', - 'Year' - '0 or negative if converted BC year, positive otherwise', - 'Month' - 'Normally an integer between 1 and 12 inclusive', - 'Day' - 'Normally an integer between 1 and 31 inclusive depending upon month', - 'DoW' - 'Day of week, where Monday=1, Tuesday=2, ..., Sunday=7', - 'Week' - 'Compound term, week(WeekNo,ActualYear), of a day', - 'DoY' - 'Day of year (NB! calendar year, not week # year)'], - examples is [ - 'Get the date and day-of-year of a Julian number:' - date(2451649,Year,Month,Day,_,_,DoY) - {Year = 2000, Month = 4, Day = 14, DoY = 105}, - 'Get the Julian number, week number and day-of-year of a date, confirming that it is a Sunday:' - date(JD,2004,2,29,7,Wk,DoY) - {JD = 2453065, Wk = week(9,2004), DoY = 60}, - 'Confirm that a date is, in fact, a specific day-of-year:' - date(_,2004,3,1,_,_,61) - {yes}, - 'Get the Julian number, week day and day-of-year of a date:' - date(JD,2004,10,18,DoW,_,DoY) - {JD = 2453297, DoW = 1, DoY = 292}, - 'Get today''s day-of-year:' - date(_,_,_,_,_,_,DoY) - {DoY = 54}, - 'Get all missing date data (excl. Julian number) for the 60th calendar day of 2004:' - date(_,2004,Month,Day,DoW,Week,60) - {Month = 2, Day = 29, DoW = 7, Week = week(9,2004)}, - 'Match given date data and, if true, return the missing data (excl. Julian number):' - date(_,2004,3,Day,DoW,Week,61) - {Day = 1, DoW = 1, Week = week(10,2004)}, - 'Ditto (the 61st day-of-year cannot be both day 1 and 2 of the month):' - date(_,2004,Month,2,DoW,Week,61) - {no}]]). - - :- public(date_string/3). - :- mode(date_string(+atom, +integer, ?atom), zero_or_one). - :- mode(date_string(+atom, ?list, ?atom), zero_or_one). - :- info(date_string/3, [ - comment is 'Conversion between an ISO 8601 compliant date string and its components (truncated and expanded date representations are currently unsupported). Note that date components are not validated; that is the caller''s responsibility!', - arguments is [ - 'Format' - 'ISO 8601 format', - 'Components' - 'When bound and String is free, either a Julian number or a [Year,Month,Day] term; it binds to the system day/date if free When free and String is bound, it binds to an integer list representing the numeric elements of String', - 'String' - 'ISO 8601 formatted string correspondent to Components'], - examples is [ - 'Date, complete, basic (section 5.2.1.1):' - date_string('YYYYMMDD',[2004,2,29],Str) - {Str = '20040229'}, - 'Date, complete, basic (section 5.2.1.1):' - date_string('YYYYMMDD',Day,'20040229') - {Day = [2004,2,29]}, - 'Date, complete, extended (section 5.2.1.1):' - date_string('YYYY-MM-DD',[2003,12,16],Str) - {Str = '2003-12-16'}, - 'Date, complete, extended (section 5.2.1.1):' - date_string('YYYY-MM-DD',Day,'2003-12-16') - {Day = [2003,12,16]}, - 'Date, complete, extended (section 5.2.1.1):' - date_string('YYYY-MM-DD',_,Str) - {Str = '2004-02-17'}, - 'Date, complete, extended (section 5.2.1.1):' - date_string('YYYY-MM-DD',Day,'2004-02-17') - {Day = [2004,2,17]}, - 'Date, reduced, month (section 5.2.1.2 a):' - date_string('YYYY-MM',[2004,9,18],Str) - {Str = '2004-09'}, - 'Date, reduced, month (section 5.2.1.2 a):' - date_string('YYYY-MM',Day,'2004-09') - {Day = [2004,9]}, - 'Date, reduced, year (section 5.2.1.2 b):' - date_string('YYYY',[1900,7,24],Str) - {Str = '1900'}, - 'Date, reduced, year (section 5.2.1.2 b):' - date_string('YYYY',Day,'1900') - {Day = [1900]}, - 'Date, reduced, century (section 5.2.1.2 c):' - date_string('YY',2456557,Str) - {Str = '20'}, - 'Date, reduced, century (section 5.2.1.2 c):' - date_string('YY',Day,'20') - {Day = [20]}, - 'Date, ordinal, complete (section 5.2.2.1):' - date_string('YYYYDDD',[2005,3,25],Str) - {Str = '2005084'}, - 'Date, ordinal, complete (section 5.2.2.1):' - date_string('YYYYDDD',Day,'2005084') - {Day = [2005,84]}, - 'Date, ordinal, extended (section 5.2.2.1):' - date_string('YYYY-DDD',[1854,12,4],Str) - {Str = '1854-338'}, - 'Date, ordinal, extended (section 5.2.2.1):' - date_string('YYYY-DDD',Day,'1854-338') - {Day = [1854,338]}, - 'Week, complete, basic (section 5.2.3.1):' - date_string('YYYYWwwD',[2000,1,2],Str) - {Str = '1999W527'}, - 'Week, complete, basic (section 5.2.3.1):' - date_string('YYYYWwwD',Day,'1999W527') - {Day = [1999,52,7]}, - 'Week, complete, extended (section 5.2.3.1):' - date_string('YYYY-Www-D',[2003,12,29],Str) - {Str = '2004-W01-1'}, - 'Week, complete, extended (section 5.2.3.1):' - date_string('YYYY-Www-D',Day,'2004-W01-1') - {Day = [2004,1,1]}, - 'Week, complete, extended (section 5.2.3.1):' - date_string('YYYY-Www-D',2453167,Str) - {Str = '2004-W24-4'}, - 'Week, complete, extended (section 5.2.3.1):' - date_string('YYYY-Www-D',Day,'2004-W24-4') - {Day = [2004,24,4]}, - 'Week, reduced, basic (section 5.2.3.2):' - date_string('YYYYWww',[2004,2,29],Str) - {Str = '2004W09'}, - 'Week, reduced, basic (section 5.2.3.2):' - date_string('YYYYWww',Day,'2004W09') - {Day = [2004,9]}, - 'Week, reduced, extended (section 5.2.3.2):' - date_string('YYYY-Www',[2004,2,29],Str) - {Str = '2004-W09'}, - 'Week, reduced, extended (section 5.2.3.2):' - date_string('YYYY-Www',Day,'2004-W09') - {Day = [2004,9]}]]). - - % MISCELLANEOUS PREDICATES (GOODIES): - - :- public(valid_date/3). - :- mode(valid_date(+integer, +integer, +integer), zero_or_one). - :- info(valid_date/3, [ - comment is 'Validate a given date in the Gregorian calendar.', - argnames is ['Year', 'Month', 'Day'], - examples is [ - 'Yes, the recent millenium was a leap year:' - valid_date(2000,2,29) - {yes}, - '2004 was also a leap year:' - valid_date(2004,2,29) - {yes}, - 'Only 30 days in April:' - valid_date(2004,4,31) - {no}, - '1 BC was a leap year:' - valid_date(-1,2,29) - {yes} - ]]). - - :- public(leap_year/1). - :- mode(leap_year(?integer), zero_or_one). - :- info(leap_year/1, [ - comment is 'Succeed if given year is a leap year in the Gregorian calendar.', - arguments is [ - 'Year' - 'The Gregorian calendar year to investigate. If free, it binds to the system year'], - examples is [ - 'No, the prior centenary was not a leap year:' - leap_year(1900) - {no}, - 'The recent millenium:' - leap_year(2000) - {yes}, - 'This year:' - leap_year(Year) - {Year = 2004}, - 'This year (equivalent to prior query):' - leap_year(_) - {yes}, - 'Next centennial:' - leap_year(2100) - {no}, - 'Year 0, equivalent to 1 BC:' - leap_year(0) - {yes}, - '1 BC' - leap_year(-1) - {yes}, - '4 BC' - leap_year(-4) - {no}, - '5 BC' - leap_year(-5) - {yes} - ]]). - - :- public(calendar_month/3). - :- mode(calendar_month(?integer, ?integer, -compound), zero_or_one). - :- info(calendar_month/3, [ - comment is 'Compute a calendar month.', - arguments is [ - 'Year' - 'The calendar year', - 'Month' - 'The calendar month', - 'Calendar' - 'A compound term, m/3, composed of three main arguments specifying year, month, and a list of week and week day numbers (calendar body).'], - examples is [ - 'Compute the calendar of March, 2005:' - calendar_month(2005, 3, Calendar) - {Calendar = m(2005, 3,[w( 9, [ 0, 1, 2, 3, 4, 5, 6]),w(10, [ 7, 8, 9, 10, 11, 12, 13]),w(11, [14, 15, 16, 17, 18, 19, 20]),w(12, [21, 22, 23, 24, 25, 26, 27]),w(13, [28, 29, 30, 31, 0, 0, 0]),w( 0, [ 0, 0, 0, 0, 0, 0, 0])])}]]). - - :- public(easter_day/3). - :- mode(easter_day(?integer, -integer, -integer), zero_or_one). - :- info(easter_day/3, [ - comment is 'Compute a Gregorian Easter Sunday.', - arguments is [ - 'Year' - 'Integer specifying the year to be investigated', - 'Month' - 'Month in which Easter Sunday falls for given year', - 'Day'- 'Day of month in which Easter Sunday falls for given year'], - examples is [ - 'Compute Easter Sunday for a particular year:' - easter_day(2006,Month,Day) - {Month=4, Day=16}, - 'Compute Easter Sunday for the current year:' - easter_day(Y,M,D) - {Y = 2005, M = 3, D = 27} - ]]). - - - /************************ - ISO 8601 DATE PREDICATES - ************************/ - - %============================================================================== - % date(?JD, ?Year, ?Month, ?Day) - - date(JD,Year,Month,Day) :- - ( var(JD), var(Year), var(Month), var(Day) - -> % GET THE SYSTEM DATE AND ITS JULIAN DAY SERIAL NUMBER: - {'$lgt_current_date'(Year, Month, Day)} - ; true - ), - ( var(JD), nonvar(Year), nonvar(Month), nonvar(Day) - -> % CORRIGATE BC/AD CALENDAR YEARS TO FIT 0-BASED ALGORITHM: - (Year < 0 -> Year1 is Year + 1 ; Year1 = Year), - % CONVERT DATE PARTS TO JULIAN DAY SERIAL NUMBER: - A is (14 - Month) // 12, - Y is Year1 + 4800 - A, - M is Month + (12 * A) - 3, - D is Day + ((153 * M + 2) // 5) + (365 * Y) + (Y // 4), - JD is D - (Y // 100) + (Y // 400) - 32045 - ; nonvar(JD), - % CONVERT JULIAN DAY SERIAL NUMBER TO DATE PARTS: - A is JD + 32045, - B is (4 * (A + 36524)) // 146097 - 1, - C is A - ((146097 * B) // 4), - D is ((4 * (C + 365)) // 1461) - 1, - E is C - ((1461 * D) // 4), - M is ((5 * (E - 1)) + 2) // 153, - Day is E - (((153 * M) + 2) // 5), - Month is M + (3 - (12 * (M // 10))), - Year1 is ((100 * B) + D - 4800 + (M // 10)), - % CORRIGATE 0-BASED ALGORITHM RESULT TO BC/AD CALENDAR YEARS: - (Year1 < 1 -> Year is Year1 - 1 ; Year = Year1) - ). - - - %============================================================================== - % date(?JD, ?Year, ?Month, ?Day, ?DoW) - - date(JD,Year,Month,Day,DoW) :- - date(JD,Year,Month,Day), - DoW is (JD mod 7) + 1. - - - %============================================================================== - % date(?JD, ?Year, ?Month, ?Day, ?DoW, ?Week) - - date(JD,Year,Month,Day,DoW,week(Wk,Yr)) :- - ( var(JD), var(Year), var(Month), var(Day), nonvar(Wk), nonvar(Yr) - -> (var(DoW) -> DoW = 1 ; true), - date(JD1,Yr,1,1,DoW1), - (DoW1 > 4 -> Offset = 0 ; Offset = 1), - JD is JD1 + ((Wk - Offset) * 7) + DoW - DoW1, - date(JD,Year,Month,Day) - ; date(JD,Year,Month,Day,DoW), - D4 is (((JD + 31741 - (JD mod 7)) mod 146097) mod 36524) mod 1461, - L is D4 // 1460, - Wk is (((D4 - L) mod 365) + L) // 7 + 1, - % CORRIGATE YEAR AS NECESSARY: - ( Month =:= 1, (Day =:= 1 ; Day =:= 2 ; Day =:= 3), Wk > 1 - -> Yr is Year - 1 - ; ( Month =:= 12, (Day =:= 29 ; Day =:= 30 ; Day =:= 31), Wk =:= 1 - -> Yr is Year + 1 - ; Yr = Year - ) - ) - ). - - - %============================================================================== - % date(?JD, ?Year, ?Month, ?Day, ?DoW, ?Week, ?DoY) - - date(JD,Year,Month,Day,DoW,Week,DoY) :- - ( var(JD), nonvar(Year), (var(Month) ; var(Day)), nonvar(DoY) - -> date(JD1,Year,1,0), - JD is JD1 + DoY, - date(JD,Year,Month,Day,DoW,Week) - ; date(JD,Year,Month,Day,DoW,Week), - date(JD1,Year,1,0), - DoY is JD - JD1 - ). - - - %============================================================================== - % date_string(+Format, ?Day, ?String) - - date_string('YYYYMMDD',Day,String) :- % DATE - ( nonvar(String) - -> atom_chars(String,[Y0,Y1,Y2,Y3,M0,M1,D0,D1]), - number_chars(Y,[Y0,Y1,Y2,Y3]), - number_chars(M,[M0,M1]), - number_chars(D,[D0,D1]), - Day = [Y,M,D] - ; ((var(Day) ; Day = [Y|_], var(Y)) -> date(_,Y,M,D) ; true), - (Day = [Y,M,D] -> nonvar(Y), nonvar(M), nonvar(D) ; date(Day,Y,M,D)), - prepend_zeros(2,D,D1), - prepend_zeros(2,M,M1), - number_codes(Y,Y1), - list_of_lists_to_atom([Y1,M1,D1],String) - ). - date_string('YYYY-MM-DD',Day,String) :- % DATE - ( nonvar(String) - -> atom_chars(String,[Y0,Y1,Y2,Y3,_,M0,M1,_,D0,D1]), - number_chars(Y,[Y0,Y1,Y2,Y3]), - number_chars(M,[M0,M1]), - number_chars(D,[D0,D1]), - Day = [Y,M,D] - ; ((var(Day) ; Day = [Y|_], var(Y)) -> date(_,Y,M,D) ; true), - (Day = [Y,M,D] -> nonvar(Y), nonvar(M), nonvar(D) ; date(Day,Y,M,D)), - prepend_zeros(2,D,D1), - prepend_zeros(2,M,M1), - number_codes(Y,Y1), - list_of_lists_to_atom([Y1,[45],M1,[45],D1],String) - ). - date_string('YYYY-MM',Day,String) :- % YEAR & MONTH - ( nonvar(String) - -> atom_chars(String,[Y0,Y1,Y2,Y3,_,M0,M1]), - number_chars(Year,[Y0,Y1,Y2,Y3]), - number_chars(Month,[M0,M1]), - Day = [Year,Month] - ; ((var(Day) ; Day = [Y|_], var(Y)) -> date(_,Y,M,_) ; true), - (Day = [Y,M,_] -> nonvar(Y), nonvar(M) ; date(Day,Y,M,_)), - prepend_zeros(2,M,M1), - number_codes(Y,Y1), - list_of_lists_to_atom([Y1,[45],M1],String) - ). - date_string('YYYY',Day,String) :- % YEAR - ( nonvar(String) - -> atom_chars(String,[Y0,Y1,Y2,Y3]), - number_chars(Year,[Y0,Y1,Y2,Y3]), - Day = [Year] - ; ((var(Day) ; Day = [Y|_], var(Y)) -> date(_,Y,_,_) ; true), - (Day = [Y|_] -> nonvar(Y) ; date(Day,Y,_,_)), - number_codes(Y,Codes), - atom_codes(String,Codes) - ). - date_string('YY',Day,String) :- % CENTURY - ( nonvar(String) - -> atom_chars(String,[C0,C1]), - number_chars(Century,[C0,C1]), - Day = [Century] - ; ((var(Day) ; Day = [Y|_], var(Y)) -> date(_,Y,_,_) ; true), - (Day = [Y|_] -> nonvar(Y) ; date(Day,Y,_,_)), - Y1 is Y // 100, - number_codes(Y1,Codes), - atom_codes(String,Codes) - ). - date_string('YYYYDDD',Day,String) :- % YEAR & DAY-OF-YEAR - ( nonvar(String) - -> atom_chars(String,[Y0,Y1,Y2,Y3,D0,D1,D2]), - number_chars(Year,[Y0,Y1,Y2,Y3]), - number_chars(DoY,[D0,D1,D2]), - Day = [Year,DoY] - ; ((var(Day) ; Day = [Y|_], var(Y)) -> date(_,Y,M,D) ; true), - (Day = [Y,M,D] -> nonvar(Y), nonvar(M), nonvar(D) ; JD = Day), - date(JD,Y,M,D,_,_,DoY), - prepend_zeros(3,DoY,DoY1), - number_codes(Y,Y1), - list_of_lists_to_atom([Y1,DoY1],String) - ). - date_string('YYYY-DDD',Day,String) :- % YEAR & DAY-OF-YEAR - ( nonvar(String) - -> atom_chars(String,[Y0,Y1,Y2,Y3,_,D0,D1,D2]), - number_chars(Year,[Y0,Y1,Y2,Y3]), - number_chars(DoY,[D0,D1,D2]), - Day = [Year,DoY] - ; ((var(Day) ; Day = [Y|_], var(Y)) -> date(_,Y,M,D) ; true), - (Day = [Y,M,D] -> nonvar(Y), nonvar(M), nonvar(D) ; JD = Day), - date(JD,Y,M,D,_,_,DoY), - prepend_zeros(3,DoY,DoY1), - number_codes(Y,Y1), - list_of_lists_to_atom([Y1,[45],DoY1],String) - ). - date_string('YYYYWwwD',Day,String) :- % YEAR, WEEK & DAY-OF-WEEK - ( nonvar(String) - -> atom_chars(String,[Y0,Y1,Y2,Y3,_,W0,W1,DoW0]), - number_chars(Year,[Y0,Y1,Y2,Y3]), - number_chars(Week,[W0,W1]), - number_chars(DoW,[DoW0]), - Day = [Year,Week,DoW] - ; ((var(Day) ; Day = [Y|_], var(Y)) -> date(_,Y,M,D) ; true), - (Day = [Y,M,D] -> nonvar(Y), nonvar(M), nonvar(D) ; JD = Day), - date(JD,Y,M,D,DoW,week(Wk,Yr)), - number_codes(Yr,Y1), - prepend_zeros(2,Wk,Wk1), - number_codes(DoW,DoW1), - List = [Y1,[87],Wk1,DoW1], - list_of_lists_to_atom(List,String) - ). - date_string('YYYY-Www-D',Day,String) :- % YEAR, WEEK & DAY-OF-WEEK - ( nonvar(String) - -> atom_chars(String,[Y0,Y1,Y2,Y3,_,_,W0,W1,_,DoW0]), - number_chars(Year,[Y0,Y1,Y2,Y3]), - number_chars(Week,[W0,W1]), - number_chars(DoW,[DoW0]), - Day = [Year,Week,DoW] - ; ((var(Day) ; Day = [Y|_], var(Y)) -> date(_,Y,M,D) ; true), - (Day = [Y,M,D] -> nonvar(Y), nonvar(M), nonvar(D) ; JD = Day), - date(JD,Y,M,D,DoW,week(Wk,Yr)), - number_codes(Yr,Y1), - prepend_zeros(2,Wk,Wk1), - number_codes(DoW,DoW1), - List = [Y1,[45,87],Wk1,[45],DoW1], - list_of_lists_to_atom(List,String) - ). - date_string('YYYYWww',Day,String) :- % YEAR & WEEK - ( nonvar(String) - -> atom_chars(String,[Y0,Y1,Y2,Y3,_,W0,W1]), - number_chars(Year,[Y0,Y1,Y2,Y3]), - number_chars(Week,[W0,W1]), - Day = [Year,Week] - ; ((var(Day) ; Day = [Y|_], var(Y)) -> date(_,Y,M,D) ; true), - (Day = [Y,M,D] -> nonvar(Y), nonvar(M), nonvar(D) ; JD = Day), - date(JD,Y,M,D,_,week(Wk,Yr)), - number_codes(Yr,Y1), - prepend_zeros(2,Wk,Wk1), - List = [Y1,[87],Wk1], - list_of_lists_to_atom(List,String) - ). - date_string('YYYY-Www',Day,String) :- % YEAR & WEEK - ( nonvar(String) - -> atom_chars(String,[Y0,Y1,Y2,Y3,_,_,W0,W1]), - number_chars(Year,[Y0,Y1,Y2,Y3]), - number_chars(Week,[W0,W1]), - Day = [Year,Week] - ; ((var(Day) ; Day = [Y|_], var(Y)) -> date(_,Y,M,D) ; true), - (Day = [Y,M,D] -> nonvar(Y), nonvar(M), nonvar(D) ; JD = Day), - date(JD,Y,M,D,_,week(Wk,Yr)), - number_codes(Yr,Y1), - prepend_zeros(2,Wk,Wk1), - List = [Y1,[45,87],Wk1], - list_of_lists_to_atom(List,String) - ). - - - %----------------------------------- - % prepend_zeros(+Digits, +N, -Codes) - % Purpose: prepend zeros to a given integer - % Parameters: - % Digits: required number of digits to be entered into Codes - % N: integer to which zeros are prepended - % Codes: the resulting list of codes - % Called by: date_string/3 - % Examples: - % ?- prepend_zeros(2,2,Codes). => Codes = [48,50] - % ?- prepend_zeros(2,22,Codes). => Codes = [50,50] - % ?- prepend_zeros(3,2,Codes). => Codes = [48,48,50] - % ?- prepend_zeros(3,22,Codes). => Codes = [48,50,50] - - prepend_zeros(2, I, Codes) :- - number_codes(I, ICodes), - two_codes(ICodes, Codes). - prepend_zeros(3, I, Codes) :- - number_codes(I, ICodes), - three_codes(ICodes, Codes). - - two_codes([A], [48, A]) :- !. - two_codes([A, B], [A, B]). - - three_codes([A], [48, 48, A]) :- !. - three_codes([A, B], [48, A, B]) :- !. - three_codes([A, B, C], [A, B, C]). - - %--------------------------------------- - % list_of_lists_to_atom(+Llist, -String) - % Purpose: Convert a list of code lists to a string - % Called by: date_string/3 - - list_of_lists_to_atom(Llist,String) :- - flatten(Llist,Codes), - atom_codes(String,Codes). - - %------------------------------ - % flatten(+Llist, -Codes) - % Purpose: Convert a list of lists to a list of codes - % Note: custom, simplified version - % Called by: list_of_lists_to_atom/2 - - flatten([], []). - flatten([[]| Ls], F) :- - !, - flatten(Ls, F). - flatten([[H| T]| Ls], [H| Fs]) :- - flatten([T| Ls], Fs). - - - - /********************************** - MISCELLANEOUS PREDICATES (GOODIES) - **********************************/ - - %============================================================================== - % valid_date(+Year, +Month, +Day) - - valid_date(Year,Month,Day) :- - Month > 0, Month < 13, - Day > 0, - ( Month =:= 2 - -> (leap_year(Year) -> Days = 29 ; Days = 28) - ; days_in_month(Month,Days) - ), - Day =< Days. - - - %============================================================================== - % leap_year(+Year) - - leap_year(Year) :- - (var(Year) -> date(_,Year,_,_) ; true), - (Year < 0 -> Year1 is Year + 1 ; Year1 = Year), - 0 =:= Year1 mod 4, - (\+ 0 =:= Year1 mod 100 -> true ; 0 =:= Year1 mod 400). - - - %============================================================================== - % calendar_month(?Year, ?Month, -Calendar) - - calendar_month(Year,Month,m(Year,Month,Weeks)) :- - (var(Year), var(Month) -> date(_,Year,Month,_) ; true), - % COMPUTE THE BODY (A 6 ROW BY 8 COLUMN TABLE OF WEEK AND DAY NUMBERS): - date(JD,Year,Month,1,DoW,week(Week,_)), - Lead0s is DoW - 1, % number of leading zeros required - ( Month =:= 2 - -> (leap_year(Year) -> Days = 29 ; Days = 28) - ; days_in_month(Month,Days) - ), - Delta is 42 - (Lead0s + Days), % number of trailing zeros required - zeros(Delta,[],Append), % zeros to be appended to day list - day_list(Days,Append,DList), % create padded daylist - zeros(Lead0s,DList,DayList), % prepend zeros to padded day list - Julian is JD - Lead0s, - week_list(6,Julian,Week,DayList,Weeks). - - %------------------------------- - % zeros(+Counter, +Build, -List) - % Purpose: Prepend or append a list of 0's (zeros) to a given list - % Called by: calendar_month/3 - - zeros(0,L,L):- !. - zeros(DoW,Build,List) :- - Next is DoW - 1, - zeros(Next,[0|Build],List). - - %------------------------------------- - % day_list(+Counter, +Build, -DayList) - % Purpose: Return a list of day #s - % Called by: calendar_month/3 - - day_list(0,DayList,DayList) :- !. - day_list(N,SoFar,DayList) :- - N1 is N - 1, - day_list(N1,[N|SoFar],DayList). - - %------------------------------------------- - % week_list(+N, +JD, +Week, +Days, -WeekList) - % Purpose: Return a list of week and day #s - % Called by: calendar_month/3 - - week_list(0,_,_,_,[]). - week_list(N,JD,Week,Days,[X|Weeks]) :- - Days = [F1,F2,F3,F4,F5,F6,F7|Days1], - ( N < 3, - F1 =:= 0 - -> Wk = 0 - ; Wk = Week - ), - X = w(Wk,[F1,F2,F3,F4,F5,F6,F7]), - JD1 is JD + 7, - ( Week > 51 - -> date(JD1,_,_,_,_,week(Week1,_)) - ; Week1 is Week + 1 - ), - N1 is N - 1, - week_list(N1,JD1,Week1,Days1,Weeks). - - - %============================================================================== - % easter_day(?Year, -Month, -Day) - - easter_day(Year,Month,Day):- - (nonvar(Year) -> true ; date(_,Year,_,_)), - Year > 1582, - A is Year mod 19, - B is Year mod 4, - C is Year mod 7, - calc_M_and_N(Year,M,N), - D is (19 * A + M) mod 30, - E is ((2 * B) + (4 * C) + (6 * D) + N) mod 7, - R is 22 + D + E, - calc_month_and_day(R,Month,Day1), - corr_day(Day1,Month,A,D,E,Day). - - %---------------------------- - % calc_M_and_N(+Year, -M, -N) - % Purpose: Calculate intermediate values M and N - % Called by: easter_day/3 - - calc_M_and_N(Year,M,N):- - T is Year // 100, - P is (13 + 8 * T) // 25, - Q is T // 4, - M is (15 + T - P - Q) mod 30, - N is (T - (T // 4) + 4) mod 7. - - %------------------------------------- - % calc_month_and_day(+R, -Month, -Day) - % Purpose: Calculate the Easter Sunday month and likely day - % Called by: easter_day/3 - - calc_month_and_day(R,4,Day):- % April - R > 31, - !, - Day is R - 31. - calc_month_and_day(R,3,R). % March - - %--------------------------------------------------- - % corr_day(+PossDay, +Month, +A, +D, +E, -ActualDay) - % Purpose: Calculate the actual Easter Sunday - % Called by: easter_day/3 - - corr_day(_,4,_,29,6,19):- % April, Gregorian exception 1 - !. - corr_day(_,4,A,28,6,18):- % April, Gregorian exception 2 - A > 10, - !. - corr_day(Day,_,_,_,_,Day). % Otherwise - - - - /************************ - LOCAL UTILITY PREDICATES - ************************/ - - %------------------------------------ - % days_in_month(+Month, -DaysInMonth) - % Purpose: Return the number of days in a given month - % Called by: valid_date/3, calendar_month/3 - - days_in_month( 1, 31). - days_in_month( 2, 28). - days_in_month( 3, 31). - days_in_month( 4, 30). - days_in_month( 5, 31). - days_in_month( 6, 30). - days_in_month( 7, 31). - days_in_month( 8, 31). - days_in_month( 9, 30). - days_in_month(10, 31). - days_in_month(11, 30). - days_in_month(12, 31). - - -:- end_object. diff --git a/Logtalk/contributions/xml_parser/NOTES.txt b/Logtalk/contributions/xml_parser/NOTES.txt deleted file mode 100644 index b37d62a93..000000000 --- a/Logtalk/contributions/xml_parser/NOTES.txt +++ /dev/null @@ -1,19 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This folder contains a Logtalk version of John Fletcher's Prolog XML -parser: - - http://www.zen37763.zen.co.uk/xml.pl.html - -To load this XML parser and for sample queries, please see the SCRIPT -file. - -For a detailed description of this XML parser, please see the comments -in the "xml.lgt" source file or convert the automatically generated -documentation to HTML or PDF. diff --git a/Logtalk/contributions/xml_parser/SCRIPT.txt b/Logtalk/contributions/xml_parser/SCRIPT.txt deleted file mode 100644 index eca09c77b..000000000 --- a/Logtalk/contributions/xml_parser/SCRIPT.txt +++ /dev/null @@ -1,34 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the necessary library support files (if not -% already loaded): - -| ?- logtalk_load(library(types_loader)). -... - - -% now you are ready for loading the XML parser: - -| ?- logtalk_load(xml_parser(loader)). -... - - -% let's try some examples (the goals generate XML files named qi.xml): - -| ?- logtalk_load(xml_parser(examples)). -... - -| ?- test(q1). -... - -| ?- test(q2). -... - -| ?- test(q12). -... diff --git a/Logtalk/contributions/xml_parser/bib.xml b/Logtalk/contributions/xml_parser/bib.xml deleted file mode 100644 index efe888e71..000000000 --- a/Logtalk/contributions/xml_parser/bib.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - TCP/IP Illustrated - StevensW. - Addison-Wesley - 65.95 - - - - Advanced Programming in the Unix environment - StevensW. - Addison-Wesley - 65.95 - - - - Data on the Web - AbiteboulSerge - BunemanPeter - SuciuDan - Morgan Kaufmann Publishers - 39.95 - - - - The Economics of Technology and Content for Digital TV - - GerbargDarcy - CITI - - Kluwer Academic Publishers - 129.95 - - - - diff --git a/Logtalk/contributions/xml_parser/books.xml b/Logtalk/contributions/xml_parser/books.xml deleted file mode 100644 index 6fbcd39a4..000000000 --- a/Logtalk/contributions/xml_parser/books.xml +++ /dev/null @@ -1,15 +0,0 @@ - - Data Model -
- Syntax For Data Model -
-
- XML -
- Basic Syntax -
-
- XML and Semistructured Data -
-
-
diff --git a/Logtalk/contributions/xml_parser/examples.lgt b/Logtalk/contributions/xml_parser/examples.lgt deleted file mode 100644 index db1da8c4e..000000000 --- a/Logtalk/contributions/xml_parser/examples.lgt +++ /dev/null @@ -1,387 +0,0 @@ -/* Using xml.pl to solve XML Query Cases - An Example - * - * The following is a complete example to illustrate how the module can be used; - * it exercises both the input and output parsing modes of xml::parse/[2,3], and - * illustrates the use of xml::subterm/2 to access the nodes of a "document value - * model". It's written for Quintus Prolog, but should port to other Prologs - * easily. - * - * The entry-point of the program is the test/1 predicate. - * - * test( +QueryId ) executes a Prolog implementation of a Query from Use Case - * "XMP": Experiences and Exemplars, in the W3C's XML Query Use Cases, which - * "contains several example queries that illustrate requirements gathered from - * the database and document communities". - * - * - * QueryId is one of q1q12 selecting which of the 12 use cases is executed. - * The XML output is written to the file [QueryId].xml in the current directory. - * - * xml::pp/1 is used to display the resulting "document value model" - % data-structures on the user output (stdout) stream. - */ -test( Query ) :- - xml_query( Query, ResultElement ), - % Parse output XML into the Output chars - xml::parse( Codes, xml([], [ResultElement]) ), - atom_concat( Query, '.xml', OutputFile ), - % Write OutputFile from the Output list of chars - open( OutputFile, write, Output ), - put_codes( Codes, Output ), - close( Output ), - % Pretty print OutputXML - write( 'Output XML' ), nl, - xml::pp( xml([], [ResultElement]) ). - -/* xml_query( +QueryNo, ?OutputXML ) when OutputXML is an XML Document Value Model - * produced by running an example taken, identified by QueryNo from the XML Query - * "XMP" use case. - */ - -% Q1: List books published by Addison-Wesley after 1991, including their year and -% title. - -xml_query( q1, element(bib, [], Books) ) :- - element_name( Title, title ), - element_name( Publisher, publisher ), - input_document( 'bib.xml', Bibliography ), - findall( - element(book, [year=Year], [Title]), - ( - xml::subterm( Bibliography, element(book, Attributes, Content) ), - xml::subterm( Content, Publisher ), - xml::subterm( Publisher, Text ), - text_value( Text, "Addison-Wesley" ), - list::member( year=Year, Attributes ), - number_codes( YearNo, Year ), - YearNo > 1991, - xml::subterm( Content, Title ) - ), - Books - ). - -% Q2: Create a flat list of all the title-author pairs, with each pair enclosed -% in a "result" element. - -xml_query( q2, element(results, [], Results) ) :- - element_name( Title, title ), - element_name( Author, author ), - element_name( Book, book ), - input_document( 'bib.xml', Bibliography ), - findall( - element(result, [], [Title,Author]), - ( - xml::subterm( Bibliography, Book ), - xml::subterm( Book, Title ), - xml::subterm( Book, Author ) - ), - Results - ). - -% Q3: For each book in the bibliography, list the title and authors, grouped -% inside a "result" element. - -xml_query( q3, element(results, [], Results) ) :- - element_name( Title, title ), - element_name( Author, author ), - element_name( Book, book ), - input_document( 'bib.xml', Bibliography ), - findall( - element(result, [], [Title|Authors]), - ( - xml::subterm( Bibliography, Book ), - xml::subterm( Book, Title ), - findall( Author, xml::subterm(Book, Author), Authors ) - ), - Results - ). - -% Q4: For each author in the bibliography, list the author's name and the titles -% of all books by that author, grouped inside a "result" element. - -xml_query( q4, element(results, [], Results) ) :- - element_name( Title, title ), - element_name( Author, author ), - element_name( Book, book ), - input_document( 'bib.xml', Bibliography ), - findall( Author, xml::subterm(Bibliography, Author), AuthorBag ), - sort( AuthorBag, Authors ), - findall( - element(result, [], [Author|Titles]), - ( - list::member( Author, Authors ), - findall( Title, ( - xml::subterm( Bibliography, Book ), - xml::subterm( Book, Author ), - xml::subterm( Book, Title ) - ), - Titles - ) - ), - Results - ). - -% Q5: For each book found at both bn.com and amazon.com, list the title of the -% book and its price from each source. - -xml_query( q5, element('books-with-prices', [], BooksWithPrices) ) :- - element_name( Title, title ), - element_name( Book, book ), - element_name( Review, entry ), - input_document( 'bib.xml', Bibliography ), - input_document( 'reviews.xml', Reviews ), - findall( - element('book-with-prices', [], [ - Title, - element('price-bn',[], BNPrice ), - element('price-amazon',[], AmazonPrice ) - ] ), - ( - xml::subterm( Bibliography, Book ), - xml::subterm( Book, Title ), - xml::subterm( Reviews, Review ), - xml::subterm( Review, Title ), - xml::subterm( Book, element(price,_, BNPrice) ), - xml::subterm( Review, element(price,_, AmazonPrice) ) - ), - BooksWithPrices - ). - -% Q6: For each book that has at least one author, list the title and first two -% authors, and an empty "et-al" element if the book has additional authors. - -xml_query( q6, element(bib, [], Results) ) :- - element_name( Title, title ), - element_name( Author, author ), - element_name( Book, book ), - input_document( 'bib.xml', Bibliography ), - findall( - element(book, [], [Title,FirstAuthor|Authors]), - ( - xml::subterm( Bibliography, Book ), - xml::subterm( Book, Title ), - findall( Author, xml::subterm(Book, Author), [FirstAuthor|Others] ), - other_authors( Others, Authors ) - ), - Results - ). - -% Q7: List the titles and years of all books published by Addison-Wesley after -% 1991, in alphabetic order. - -xml_query( q7, element(bib, [], Books) ) :- - element_name( Title, title ), - element_name( Publisher, publisher ), - input_document( 'bib.xml', Bibliography ), - findall( - Title-element(book, [year=Year], [Title]), - ( - xml::subterm( Bibliography, element(book, Attributes, Book) ), - xml::subterm( Book, Publisher ), - xml::subterm( Publisher, Text ), - text_value( Text, "Addison-Wesley" ), - list::member( year=Year, Attributes ), - number_codes( YearNo, Year ), - YearNo > 1991, - xml::subterm( Book, Title ) - ), - TitleBooks - ), - keysort( TitleBooks, TitleBookSet ), - range( TitleBookSet, Books ). - -% Q8: Find books in which the name of some element ends with the string "or" and -% the same element contains the string "Suciu" somewhere in its content. For each -% such book, return the title and the qualifying element. - -xml_query( q8, element(bib, [], Books) ) :- - element_name( Title, title ), - element_name( Book, book ), - element_name( QualifyingElement, QualifyingName ), - list::append( "Suciu", _Back, Suffix ), - input_document( 'bib.xml', Bibliography ), - findall( - element(book, [], [Title,QualifyingElement]), - ( - xml::subterm( Bibliography, Book ), - xml::subterm( Book, QualifyingElement ), - atom_codes( QualifyingName, QNChars ), - list::append( _QNPrefix, "or", QNChars ), - xml::subterm( QualifyingElement, TextItem ), - text_value( TextItem, TextValue ), - list::append( _Prefix, Suffix, TextValue ), - xml::subterm( Book, Title ) - ), - Books - ). - -% Q9: In the document "books.xml", find all section or chapter titles that -% contain the word "XML", regardless of the level of nesting. - -xml_query( q9, element(results, [], Titles) ) :- - element_name( Title, title ), - list::append( "XML", _Back, Suffix ), - input_document( 'books.xml', Books ), - findall( - Title, - ( - xml::subterm( Books, Title ), - xml::subterm( Title, TextItem ), - text_value( TextItem, TextValue ), - list::append( _Prefix, Suffix, TextValue ) - ), - Titles - ). - -% Q10: In the document "prices.xml", find the minimum price for each book, in the -% form of a "minprice" element with the book title as its title attribute. - -xml_query( q10, element(results, [], MinPrices) ) :- - element_name( Title, title ), - element_name( Price, price ), - input_document( 'prices.xml', Prices ), - findall( Title, xml::subterm(Prices, Title), TitleBag ), - sort( TitleBag, TitleSet ), - element_name( Book, book ), - findall( - element(minprice, [title=TitleString], [MinPrice]), - ( - list::member( Title, TitleSet ), - xml::subterm( Title, TitleText ), - text_value( TitleText, TitleString ), - findall( PriceValue-Price, ( - xml::subterm( Prices, Book ), - xml::subterm( Book, Title ), - xml::subterm( Book, Price ), - xml::subterm( Price, Text ), - text_value( Text, PriceChars ), - number_codes( PriceValue, PriceChars ) - ), - PriceValues - ), - minimum( PriceValues, PriceValue-MinPrice ) - ), - MinPrices - ). - -% Q11: For each book with an author, return the book with its title and authors. -% For each book with an editor, return a reference with the book title and the -% editor's affiliation. - -xml_query( q11, element(bib, [], Results) ) :- - element_name( Title, title ), - element_name( Author, author ), - element_name( Book, book ), - element_name( Editor, editor ), - element_name( Affiliation, affiliation ), - input_document( 'bib.xml', Bibliography ), - findall( - element(book, [], [Title,FirstAuthor|Authors]), - ( - xml::subterm( Bibliography, Book ), - xml::subterm( Book, Title ), - findall( Author, xml::subterm(Book, Author), [FirstAuthor|Authors] ) - ), - Books - ), - findall( - element(reference, [], [Title,Affiliation]), - ( - xml::subterm( Bibliography, Book ), - xml::subterm( Book, Title ), - xml::subterm( Book, Editor ), - xml::subterm( Editor, Affiliation ) - ), - References - ), - list::append( Books, References, Results ). - -% Q12: Find pairs of books that have different titles but the same set of authors -% (possibly in a different order). - -xml_query( q12, element(bib, [], Pairs) ) :- - element_name( Author, author ), - element_name( Book1, book ), - element_name( Book2, book ), - element_name( Title1, title ), - element_name( Title2, title ), - input_document( 'bib.xml', Bibliography ), - findall( - element('book-pair', [], [Title1,Title2]), - ( - xml::subterm( Bibliography, Book1 ), - findall( Author, xml::subterm(Book1, Author), AuthorBag1 ), - sort( AuthorBag1, AuthorSet ), - xml::subterm( Bibliography, Book2 ), - Book2 @< Book1, - findall( Author, xml::subterm(Book2, Author), AuthorBag2 ), - sort( AuthorBag2, AuthorSet ), - xml::subterm( Book1, Title1 ), - xml::subterm( Book2, Title2 ) - ), - Pairs - ). - -% Auxilliary Predicates - -other_authors( [], [] ). -other_authors( [Author|Authors], [Author|EtAl] ) :- - et_al( Authors, EtAl ). - -et_al( [], [] ). -et_al( [_|_], [element('et-al',[],[])] ). - -text_value( [pcdata(Text)], Text ). -text_value( [cdata(Text)], Text ). - -element_name( element(Name, _Attributes, _Content), Name ). - - -/* range( +Pairs, ?Range ) when Pairs is a list of key-datum pairs and Range - * is the list of data. - */ -range( [], [] ). -range( [_Key-Datum|Pairs], [Datum|Data] ) :- - range( Pairs, Data ). - -/* minimum( +List, ?Min ) is true if Min is the least member of List in the - * standard order. - */ -minimum( [H|T], Min ):- - minimum1( T, H, Min ). - -minimum1( [], Min, Min ). -minimum1( [H|T], Min0, Min ) :- - compare( Relation, H, Min0 ), - minimum2( Relation, H, Min0, T, Min ). - -minimum2( '=', Min0, Min0, T, Min ) :- - minimum1( T, Min0, Min ). -minimum2( '<', Min0, _Min1, T, Min ) :- - minimum1( T, Min0, Min ). -minimum2( '>', _Min0, Min1, T, Min ) :- - minimum1( T, Min1, Min ). - -/* input_document( +File, ?XML ) reads File and parses the input into the - * "Document Value Model" XML. - */ -input_document( File, XML ) :- - % Read InputFile as a list of chars - open( File, read, Input ), - get_codes( Input, Codes ), - close( Input ), - % Parse the Input chars into the term XML - xml::parse( Codes, XML ). - - -put_codes( [], _ ). -put_codes( [Code|Codes], Output ) :- - put_code( Output, Code ), - put_codes( Codes, Output ). - - -get_codes( Input, [Code|Codes] ) :- - \+ at_end_of_stream( Input ), - get_code( Input, Code ), - get_codes( Input, Codes ). -get_codes( _, [] ). diff --git a/Logtalk/contributions/xml_parser/loader.lgt b/Logtalk/contributions/xml_parser/loader.lgt deleted file mode 100644 index 89d1ccdc5..000000000 --- a/Logtalk/contributions/xml_parser/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(xml)). diff --git a/Logtalk/contributions/xml_parser/prices.xml b/Logtalk/contributions/xml_parser/prices.xml deleted file mode 100644 index 3c903fbd6..000000000 --- a/Logtalk/contributions/xml_parser/prices.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - Advanced Programming in the Unix environment - www.amazon.com - 65.95 - - - Advanced Programming in the Unix environment - www.bn.com - 65.95 - - - TCP/IP Illustrated - www.amazon.com - 65.95 - - - TCP/IP Illustrated - www.bn.com - 65.95 - - - Data on the Web - www.amazon.com - 34.95 - - - Data on the Web - www.bn.com - 39.95 - - diff --git a/Logtalk/contributions/xml_parser/reviews.xml b/Logtalk/contributions/xml_parser/reviews.xml deleted file mode 100644 index 8797e1df5..000000000 --- a/Logtalk/contributions/xml_parser/reviews.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - Data on the Web - 34.95 - - A very good discussion of semi-structured database - systems and XML. - - - - Advanced Programming in the Unix environment - 65.95 - - A clear and detailed discussion of UNIX programming. - - - - TCP/IP Illustrated - 65.95 - - One of the best books on TCP/IP. - - - \ No newline at end of file diff --git a/Logtalk/contributions/xml_parser/xml.lgt b/Logtalk/contributions/xml_parser/xml.lgt deleted file mode 100644 index 861883515..000000000 --- a/Logtalk/contributions/xml_parser/xml.lgt +++ /dev/null @@ -1,2426 +0,0 @@ -/* xml.pl : Contains parse/[2,3] a bi-directional XML parser written in - * Prolog. - * - * Copyright (C) 2001-2005 Binding Time Limited - * Copyright (C) 2005, 2006 John Fletcher - * - * Current Release: $Revision: 2.0 $ - * - * TERMS AND CONDITIONS: - * - * This program is offered free of charge, as unsupported source code. You may - * use it, copy it, distribute it, modify it or sell it without restriction, - * but entirely at your own risk. - * - */ - -:- object(xml). - - :- info([ - version is 2.0, - author is 'John Fletcher', - date is 2006/11/2, - copyright is 'Copyright (C) 2001-2005 Binding Time Limited, Copyright (C) 2005, 2006 John Fletcher', - license is 'The code has been placed into the public domain, to encourage the use of Prolog with XML. This program is offered free of charge, as unsupported source code. You may use it, copy it, distribute it, modify it or sell it without restriction, but entirely at your own risk.', - comment is 'Bi-directional XML parser.', - remarks is [ - 'On-line documentation:' - 'http://www.zen37763.zen.co.uk/xml.pl.html', - 'Compliance:' - 'This XML parser supports a subset of XML suitable for XML Data and Worldwide Web applications. It is neither as strict nor as comprehensive as the XML 1.0 Specification mandates. It is not as strict, because, while the specification must eliminate ambiguities, not all errors need to be regarded as faults, and some reasonable examples of real XML usage would have to be rejected if they were. It is not as comprehensive, because, where the XML specification makes provision for more or less complete DTDs to be provided as part of a document, xml.pl actions the local definition of ENTITIES only. Other DTD extensions are treated as commentary.', - 'Bi-directional conversions:' - 'The conversions are not completely symmetrical, in that weaker XML is accepted than can be generated. Specifically, in-bound (Chars -> Document) parsing does not require strictly well-formed XML. If Chars does not represent well-formed XML, Document is instantiated to the term malformed(, ).' - ]]). - - :- public(parse/2). - :- mode(parse(+nonvar, ?nonvar), zero_or_one). - :- mode(parse(?nonvar, +nonvar), zero_or_one). - :- info(parse/2, [ - comment is 'Parses Chars to/from a data structure of the form xml(, ).', - argnames is ['Chars', 'Document']]). - - :- public(parse/3). - :- mode(parse(+nonvar, +nonvar, ?nonvar), zero_or_one). - :- mode(parse(+nonvar, ?nonvar, +nonvar), zero_or_one). - :- info(parse/3, [ - comment is 'Parses Chars to/from a data structure of the form xml(, ).', - argnames is ['Controls', 'Chars', 'Document']]). - - :- public(subterm/2). - :- mode(subterm(+nonvar, ?nonvar), zero_or_one). - :- info(subterm/2, [ - comment is 'Unifies Subterm with a sub-term of XMLTerm. Note that XMLTerm is a sub-term of itself.', - argnames is ['XMLTerm', 'Subterm']]). - - :- public(pp/1). - :- mode(pp(+nonvar), zero_or_one). - :- info(pp/1, [ - comment is 'Pretty prints a XML document on the current output stream.', - argnames is ['XMLDocument']]). - - :- uses(list, [append/3, member/2, select/3, valid/1::is_list/1]). - :- uses(term, [ground/1]). - - /* parse( {+Controls}, +?Chars, ?+Document ) parses Chars to/from a data - * structure of the form xml(, ). is a list of - * = attributes from the (possibly implicit) XML signature of the - * document. is a (possibly empty) list comprising occurrences of : - * - * pcdata() : Text - * comment() : An xml comment; - * element(,,) : .. encloses - * : if empty - * instructions(, ) : Processing ?>" - * cdata( ) : ]]> - * doctype(, ) : DTD - * - * The conversions are not completely symmetrical, in that weaker XML is - * accepted than can be generated. Specifically, in-bound (Chars -> Document) - * does not require strictly well-formed XML. Document is instantiated to the - * term malformed(Attributes, Content) if Chars does not represent well-formed - * XML. The Content of a malformed/2 structure can contain: - * - * unparsed( ) : Text which has not been parsed - * out_of_context( ) : is not closed - * - * in addition to the standard term types. - * - * Out-bound (Document -> Chars) parsing _does_ require that Document defines - * strictly well-formed XML. If an error is detected a 'domain' exception is - * raised. - * - * The domain exception will attempt to identify the particular sub-term in - * error and the message will show a list of its ancestor elements in the form - * {(id)}* where is the value of any attribute _named_ id. - * - * At this release, the Controls applying to in-bound (Chars -> Document) - * parsing are: - * - * extended_characters() : Use the extended character - * : entities for XHTML (default true) - * - * format() : Strip layouts when no character data - * : appears between elements. - * : (default true) - * - * remove_attribute_prefixes() : Remove namespace prefixes from - * : attributes when it's the same as the - * : prefix of the parent element - * : (default false). - * - * allow_ampersand() : Allow unescaped ampersand - * : characters (&) to occur in PCDATA. - * : (default false). - * - * [ is one of 'true' or 'false'] - * - * For out-bound (Document -> Chars) parsing, the only available option is: - * - * format() : Indent the element content - * : (default true) - * - * Different DCGs for input and output are used because input parsing is - * more flexible than output parsing. Errors in input are recorded as part - * of the data structure. Output parsing throws an exception if the document - * is not well-formed, diagnosis tries to identify the specific culprit term. - */ - parse( Chars, Document ) :- - parse( [], Chars, Document ). - - parse( Controls, Chars, Document ) :- - ( ground( Chars ) -> - xml_to_document( Controls, Chars, Document ) - ; document_to_xml( Controls, Document, Chars ) - ). - - document_to_xml( Controls, Document, Chars ) :- - ( member( format(false), Controls ) -> - Format = false - ; Format = true - ), - ( ground( Document ), - document_generation(Format, Document, Chars0, [] ) -> - Chars = Chars0 - ; fault( Document, [], Culprit, Path, Message ), - throw( - application_error('XML Parse: ~s in ~q~nCulprit: ~q~nPath: ~s', - [Message,Document,Culprit,Path] ) - ) - ). - - /* subterm( +XMLTerm, ?Subterm ) unifies Subterm with a sub-term of Term. - * Note that XMLTerm is a sub-term of itself. - */ - subterm( Term, Term ). - subterm( xml(_Attributes, Content), Term ) :- - subterm( Content, Term ). - subterm( [H|T], Term ) :- - ( subterm( H, Term ) - ; subterm( T, Term ) - ). - subterm( element(_Name,_Attributes,Content), Term ) :- - subterm( Content, Term ). - subterm( namespace(_URI,_Prefix,Content), Term ) :- - subterm( Content, Term ). - - - /* xml_to_document( +Controls, +XML, ?Document ) translates the list of - * character codes XML into the Prolog term Document. Controls is a list - * of terms controlling the treatment of layout characters and character - * entities. - */ - - :- private(xml_to_document/3). - :- mode(xml_to_document(+nonvar, +nonvar, ?nonvar), zero_or_one). - :- info(xml_to_document/3, [ - comment is 'Translates the list of character codes XML into the Prolog term Document. Controls is a list of terms controlling the treatment of layout characters and character entities.', - argnames is ['Controls', 'XML', 'Document']]). - - xml_to_document( Controls, XML, Document ) :- - initial_context( Controls, Context ), - ( xml_declaration( Attributes0, XML, XML1 ) -> - Attributes = Attributes0 - ; otherwise -> - XML1 = XML, - Attributes = [] - ), - xml_to_document( XML1, Context, Terms, [], WellFormed ), - xml_to_document1( WellFormed, Attributes, Terms, Document ). - - xml_to_document1( true, Attributes, Terms, xml(Attributes, Terms) ). - xml_to_document1( false, Attributes, Terms, malformed(Attributes, Terms) ). - - % unparsed( +Unparsed, +Context, ?Terms, ?Residue, ?WellFormed ) - unparsed( Unparsed, _Context, [unparsed(Unparsed)], [], false ). - - xml_declaration( Attributes ) --> - spaces, - "". - - xml_to_document( [], Context, Terms, [], WF ) :- - close_context( Context, Terms, WF ). - xml_to_document( [Char|Chars], Context, Terms, Residue, WF ) :- - ( Char =:= "<" -> - markup_structure( Chars, Context, Terms, Residue, WF ) - ; Char =:= "&" -> - entity_reference( Chars, Context, Terms, Residue, WF ) - ; Char =< " ", - \+ space_preserve( Context ) -> - layouts( Chars, Context, [Char|T], T, Terms, Residue, WF ) - ; void_context( Context ) -> - unparsed( [Char|Chars], Context, Terms, Residue, WF ) - ; otherwise -> - Terms = [pcdata([Char|Chars1])|Terms1], - acquire_pcdata( Chars, Context, Chars1, Terms1, Residue, WF ) - ). - - layouts( [], Context, _Plus, _Minus, Terms, [], WF ) :- - close_context( Context, Terms, WF ). - layouts( [Char|Chars], Context, Plus, Minus, Terms, Residue, WF ) :- - ( Char =:= "<" -> - markup_structure( Chars, Context, Terms, Residue, WF ) - ; Char =:= "&" -> - reference_in_layout( Chars, Context, Plus, Minus, Terms, Residue, WF ) - ; Char =< " " -> - Minus = [Char|Minus1], - layouts( Chars, Context, Plus, Minus1, Terms, Residue, WF ) - ; void_context( Context ) -> - unparsed( [Char|Chars], Context, Terms, Residue, WF ) - ; otherwise -> - Terms = [pcdata(Plus)|Terms1], - Minus = [Char|Chars1], - context_update( space_preserve, Context, true, Context1 ), - acquire_pcdata( Chars, Context1, Chars1, Terms1, Residue, WF ) - ). - - acquire_pcdata( [], Context, [], Terms, [], WF ) :- - close_context( Context, Terms, WF ). - acquire_pcdata( [Char|Chars], Context, Chars1, Terms, Residue, WF ) :- - ( Char =:= "<" -> - Chars1 = [], - markup_structure( Chars, Context, Terms, Residue, WF ) - ; Char =:= "&" -> - reference_in_pcdata( Chars, Context, Chars1, Terms, Residue, WF ) - ; otherwise -> - Chars1 = [Char|Chars2], - acquire_pcdata( Chars, Context, Chars2, Terms, Residue, WF ) - ). - - markup_structure( [], Context, Terms, Residue, WF ) :- - unparsed( "<", Context, Terms, Residue, WF ). - markup_structure( Chars, Context, Terms, Residue, WF ) :- - Chars = [Char|Chars1], - ( Char =:= "/" -> - closing_tag( Context, Chars1, Terms, Residue, WF ) - ; Char =:= "?" -> - pi_acquisition( Chars1, Context, Terms, Residue, WF ) - ; Char =:= "!" -> - declaration_acquisition( Chars1, Context, Terms, Residue, WF ) - ; open_tag(Tag,Context,Attributes,Type, Chars, Chars2 ) -> - push_tag( Tag, Chars2, Context, Attributes, Type, Terms, Residue, WF ) - ; otherwise -> - unparsed( [0'<|Chars], Context, Terms, Residue, WF ) %' - ). - - push_tag( Tag, Chars, Context, Attributes, Type, Terms, Residue, WF ) :- - new_element(Tag, Chars, Context, Attributes, Type, Term, Rest, WF0), - push_tag1( WF0, Context, Term, Rest, Terms, Residue, WF ). - - push_tag1( true, Context, Term, Chars, [Term|Terms], Residue, WF ) :- - xml_to_document( Chars, Context, Terms, Residue, WF ). - push_tag1( false, _Context, Term, Chars, [Term], Chars, false ). - - new_element( TagChars, Chars, Context, Attributes0, Type, Term, Residue, WF ) :- - namespace_attributes( Attributes0, Context, Context1, Attributes1 ), - ( append( NSChars, [0':|TagChars1], TagChars ), %' - specific_namespace( NSChars, Context1, SpecificNamespace ) -> - Namespace0 = SpecificNamespace - ; otherwise -> - NSChars = "", - TagChars1 = TagChars, - default_namespace( Context1, Namespace0 ) - ), - current_namespace( Context1, CurrentNamespace ), - ( Namespace0 == CurrentNamespace -> - Term = element(Tag, Attributes, Contents), - Context2 = Context1 - ; otherwise -> - Term = namespace( Namespace0, NSChars, - element(Tag, Attributes, Contents) - ), - context_update( current_namespace, Context1, Namespace0, Context2 ) - ), - input_attributes( Attributes1, Context2, Attributes ), - atom_codes( Tag, TagChars1 ), - close_tag( Type, Chars, Context2, Contents, Residue, WF ). - - close_tag( empty, Residue, _Context, [], Residue, true ). - close_tag( push(Tag), Chars, Context0, Contents, Residue, WF ) :- - context_update( element, Context0, Tag, Context1 ), - xml_to_document( Chars, Context1, Contents, Residue, WF ). - - pi_acquisition( Chars, Context, Terms, Residue, WellFormed ) :- - ( inline_instruction(Target, Processing, Chars, Rest ), - Target \== xml -> - Terms = [instructions(Target, Processing)|Terms1], - xml_to_document( Rest, Context, Terms1, Residue, WellFormed ) - ; otherwise -> - unparsed( [0'<,0'?|Chars], Context, Terms, Residue, WellFormed ) - ). - - declaration_acquisition( Chars, Context, Terms, Residue, WF ) :- - ( declaration_type( Chars, Type, Chars1 ), - declaration_parse( Type, Context, Term, Context1, Chars1, Rest ) -> - Terms = [Term|Terms1], - xml_to_document( Rest, Context1, Terms1, Residue, WF ) - ; otherwise -> - unparsed( [0'<,0'!|Chars], Context, Terms, Residue, WF ) - ). - - open_tag( Tag, Namespaces, Attributes, Termination ) --> - nmtoken_chars( Tag ), - attributes( Attributes, [], Namespaces ), - spaces, - open_tag_terminator( Tag, Termination ). - - open_tag_terminator( Tag, push(Tag) ) --> - ">". - open_tag_terminator( _Tag, empty ) --> - "/>". - - declaration_parse( comment, Namespaces, comment(Comment), Namespaces ) --> - comment(Comment). - declaration_parse( cdata, Namespaces, cdata(CData), Namespaces ) --> - cdata( CData ). - declaration_parse( doctype, Namespaces0, doctype(Name, Names), Namespaces ) --> - doctype( Name, Names, Namespaces0, Namespaces ), - spaces, - ">". - - inline_instruction( Target, Processing, Plus, Minus ) :- - nmtoken(Target, Plus, Mid0 ), - spaces( Mid0, Mid1 ), - append( Processing, [0'?,0'>|Minus], Mid1 ), - !. - - entity_reference_name( Reference ) --> - nmtoken_chars( Reference ), - ";". - - declaration_type( [Char1,Char2|Chars1], Class, Rest ) :- - Chars = [Char1,Char2|Chars1], - ( declaration_type1( Char1, Char2, Chars1, Class0, Residue ) -> - Class = Class0, - Rest = Residue - ; otherwise -> - Class = generic, - Rest = Chars - ). - - declaration_type1( 0'-, 0'-, Chars, comment, Chars ). - declaration_type1( 0'[, 0'C, Chars, cdata, Residue ) :- - append( "DATA[", Residue, Chars ). - declaration_type1( 0'D, 0'O, Chars, doctype, Residue ) :- - append( "CTYPE", Residue, Chars ). - - closing_tag( Context, Chars, Terms, Residue, WellFormed ) :- - ( closing_tag_name( Tag, Chars, Rest ), - current_tag( Context, Tag ) -> - Terms = [], - Residue = Rest, - WellFormed = true - ; otherwise -> - unparsed( [0'<,0'/|Chars], Context, Terms, Residue, WellFormed ) - ). - - closing_tag_name( Tag ) --> - nmtoken_chars( Tag ), - spaces, - ">". - - entity_reference( Chars, Context, Terms, Residue, WF ) :- - reference_in_layout( Chars, Context, L, L, Terms, Residue, WF ). - - reference_in_layout( Chars, Context, Plus, Minus, Terms, Residue, WF ) :- - ( standard_character_entity( Char, Chars, Rest ) -> - Minus = [Char|Chars1], - Terms = [pcdata(Plus)|Terms1], - acquire_pcdata( Rest, Context, Chars1, Terms1, Residue, WF ) - ; entity_reference_name( Reference, Chars, Rest ), - defined_entity( Reference, Context, String ) -> - append( String, Rest, Full ), - xml_to_document( Full, Context, Terms, Residue, WF ) - ; allow_ampersand( Context ) -> - Minus = [0'&|Chars1], %' - Terms = [pcdata(Plus)|Terms1], - acquire_pcdata( Chars, Context, Chars1, Terms1, Residue, WF ) - ; otherwise -> - unparsed( [0'&|Chars], Context, Terms, Residue, WF ) %' - ). - - reference_in_pcdata( Chars0, Context, Chars1, Terms, Residue, WF ) :- - ( standard_character_entity( Char, Chars0, Rest ) -> - Chars1 = [Char|Chars2], - acquire_pcdata( Rest, Context, Chars2, Terms, Residue, WF ) - ; entity_reference_name( Reference, Chars0, Rest ), - defined_entity( Reference, Context, String ) -> - append( String, Rest, Full ), - acquire_pcdata( Full, Context, Chars1, Terms, Residue, WF ) - ; allow_ampersand( Context ) -> - Chars1 = [0'&|Chars2], - acquire_pcdata( Chars0, Context, Chars2, Terms, Residue, WF ) - ; otherwise -> - Chars1 = [], - unparsed( [0'&|Chars0], Context, Terms, Residue, WF ) - ). - - namespace_attributes( [], Context, Context, [] ). - namespace_attributes( Attributes0, Context0, Context, Attributes ) :- - Attributes0 = [_|_], - append( "xmlns:", Unqualified, QualifiedNameChars ), - ( select( "xmlns"=Value, Attributes0, Attributes1 ) -> - atom_codes( URI, Value ), - context_update( default_namespace, Context0, URI, Context1 ), - namespace_attributes( Attributes1, Context1, Context, Attributes ) - ; select( QualifiedNameChars=Value, Attributes0, Attributes1 ) -> - Attributes = [QualifiedNameChars=Value|Attributes2], - atom_codes( URI, Value ), - context_update( ns_prefix(Unqualified), Context0, URI, Context1 ), - namespace_attributes( Attributes1, Context1, Context, Attributes2 ) - ; member( "xml:space"="preserve", Attributes0 ) -> - Attributes = Attributes0, - context_update( space_preserve, Context0, true, Context ) - ; otherwise -> - Context = Context0, - Attributes = Attributes0 - ). - - input_attributes( [], _Context, [] ). - input_attributes( [NameChars=Value|Attributes0], Context, - [Name=Value|Attributes] ) :- - ( remove_attribute_prefixes( Context ), - append( NSChars, [0':|NameChars1], NameChars ), %' - NSChars \== "xmlns", - specific_namespace( NSChars, Context, Namespace ), - current_namespace( Context, Namespace ) -> - atom_codes( Name, NameChars1 ) - ; otherwise -> - atom_codes( Name, NameChars ) - ), - input_attributes( Attributes0, Context, Attributes ). - - attributes( [Name=Value|Attributes], Seen, Namespaces ) --> - spaces, - nmtoken_chars( Name ), - {\+ member(Name, Seen)}, - spaces, - "=", - spaces, - attribute_value( Value, Namespaces ), - attributes( Attributes, [Name|Seen], Namespaces ). - attributes( [], _Seen, _Namespaces ) --> "". - - xml_declaration_attributes( [] ) --> "". - xml_declaration_attributes( [Name=Value|Attributes] ) --> - spaces, - nmtoken( Name ), - spaces, - "=", - spaces, - xml_string( Value ), - {xml_declaration_attribute_valid(Name, Value)}, - xml_declaration_attributes( Attributes ), - spaces. - - doctype( Name, External, Namespaces0, Namespaces1 ) --> - spaces, - nmtoken( Name ), - spaces, - doctype_id( External0 ), - spaces, - doctype1( Namespaces0, Literals, Namespaces1 ), - {doctype_extension(Literals, External0, External)}. - - doctype_extension( [], External, External ). - doctype_extension( [Literal|Literals], External0, External ) :- - extended_doctype( External0, [Literal|Literals], External ). - - extended_doctype( system(URL), Literals, system(URL,Literals) ). - extended_doctype( public(URN,URL), Literals, public(URN,URL,Literals) ). - extended_doctype( local, Literals, local(Literals) ). - - doctype1( Namespaces0, Literals, Namespaces1 ) --> - "[", - !, - dtd( Namespaces0, Literals, Namespaces1 ), - "]". - doctype1( Namespaces, [], Namespaces ) --> "". - - doctype_id( system(URL) ) --> - "SYSTEM", - spaces, - uri( URL ). - doctype_id( public(URN,URL) ) --> - "PUBLIC", - spaces, - uri( URN ), - spaces, - uri( URL ). - doctype_id( local ) --> "". - - dtd( Namespaces0, Literals, Namespaces1 ) --> - spaces, - "", - {\+ character_entity( Name, _StandardChar ), - % Don't allow < "e; etc. to be updated - context_update( entity(Name), Namespaces0, String, Namespaces2 ) - }, - dtd( Namespaces2, Literals, Namespaces1 ). - dtd( Namespaces0, Literals, Namespaces1 ) --> - spaces, - " - spaces, - " spaces. - - dtd_literal( [] ) --> ">", !. - dtd_literal( Chars ) --> - "--", - !, - dtd_comment, - dtd_literal( Chars ). - dtd_literal( [Char|Chars] ) --> - [Char], - dtd_literal( Chars ). - - dtd_comment( Plus, Minus ) :- - append( _Chars, [0'-,0'-|Minus], Plus ), - !. - - nmtokens( [Name|Names] ) --> - spaces, - nmtoken( Name ), - nmtokens( Names ). - nmtokens( [] ) --> []. - - entity_value( Quote, Namespaces, String, [Char|Plus], Minus ) :- - ( Char == Quote -> - String = [], - Minus = Plus - ; Char =:= "&" -> - reference_in_entity( Namespaces, Quote, String, Plus, Minus ) - ; otherwise -> - String = [Char|String1], - entity_value( Quote, Namespaces, String1, Plus, Minus ) - ). - - attribute_value( String, Namespaces ) --> - quote( Quote ), - attribute_leading_layouts( Quote, Namespaces, String ). - - attribute_leading_layouts( _Quote, _Namespace, [], [], [] ). - attribute_leading_layouts( Quote, Namespaces, String, [Char|Plus], Minus ) :- - ( Char == Quote -> - String = [], - Minus = Plus - ; Char =:= "&" -> - ref_in_attribute_layout( Namespaces, Quote, String, Plus, Minus ) - ; Char > 32, Char \== 160 -> - String = [Char|String1], - attribute_layouts( Quote, Namespaces, false, String1, Plus, Minus ) - ; otherwise -> - attribute_leading_layouts( Quote, Namespaces, String, Plus, Minus ) - ). - - attribute_layouts( _Quote, _Namespaces, _Layout, [], [], [] ). - attribute_layouts( Quote, Namespaces, Layout, String, [Char|Plus], Minus ) :- - ( Char == Quote -> - String = [], - Minus = Plus - ; Char =:= "&" -> - reference_in_value( Namespaces, Quote, Layout, String, Plus, Minus ) - ; Char > 32, Char \== 160 -> - ( Layout == true -> - String = [0' ,Char|String1] %' - ; otherwise -> - String = [Char|String1] - ), - attribute_layouts( Quote, Namespaces, false, String1, Plus, Minus ) - ; otherwise -> - attribute_layouts( Quote, Namespaces, true, String, Plus, Minus ) - ). - - ref_in_attribute_layout( NS, Quote, String, Plus, Minus ) :- - ( standard_character_entity( Char, Plus, Mid ) -> - String = [Char|String1], - attribute_layouts( Quote, NS, false, String1, Mid, Minus ) - ; entity_reference_name( Name, Plus, Suffix ), - defined_entity( Name, NS, Text ) -> - append( Text, Suffix, Mid ), - attribute_leading_layouts( Quote, NS, String, Mid, Minus ) - ; otherwise -> % Just & is okay in a value - String = [0'&|String1], %' - attribute_layouts( Quote, NS, false, String1, Plus, Minus ) - ). - - reference_in_value( Namespaces, Quote, Layout, String, Plus, Minus ) :- - ( standard_character_entity( Char, Plus, Mid ) -> - ( Layout == true -> - String = [0' ,Char|String1] %' - ; otherwise -> - String = [Char|String1] - ), - Layout1 = false - ; entity_reference_name( Name, Plus, Suffix ), - defined_entity( Name, Namespaces, Text ) -> - String = String1, - append( Text, Suffix, Mid ), - Layout1 = Layout - ; otherwise -> % Just & is okay in a value - Mid = Plus, - String = [0'&|String1], %' - Layout1 = false - ), - attribute_layouts( Quote, Namespaces, Layout1, String1, Mid, Minus ). - - /* References are resolved backwards in Entity defintions so that - * circularity is avoided. - */ - reference_in_entity( Namespaces, Quote, String, Plus, Minus ) :- - ( standard_character_entity( _SomeChar, Plus, _Rest ) -> - String = [0'&|String1], % ' Character entities are unparsed - Mid = Plus - ; entity_reference_name( Name, Plus, Suffix ), - defined_entity( Name, Namespaces, Text ) -> - String = String1, - append( Text, Suffix, Mid ) - ), - entity_value( Quote, Namespaces, String1, Mid, Minus ). - - standard_character_entity( Char ) --> - "#x", hex_character_reference( Char ), ";". - standard_character_entity( Char ) --> - "#", digit( Digit ), digits( Digits ), ";", - {number_chars( Char, [Digit|Digits])}. - standard_character_entity( C ) --> - chars( String ), - ";", - !, - {character_entity(String, C)}. - - uri( URI ) --> - quote( Quote ), - uri1( Quote, URI ). - - uri1( Quote, [] ) --> - quote( Quote ), - !. - uri1( Quote, [Char|Chars] ) --> - [Char], - uri1( Quote, Chars ). - - comment( Chars, Plus, Minus ) :- - append( Chars, [0'-,0'-,0'>|Minus], Plus ), %' - !. - - cdata( Chars, Plus, Minus ) :- - append( Chars, [0'],0'],0'>|Minus], Plus ), %' - !. - % Syntax Components - - hex_character_reference( Code ) --> - hex_character_reference1( 0, Code ). - - hex_character_reference1( Current, Code ) --> - hex_digit_char( Value ), - !, - {New is (Current << 4) + Value}, - hex_character_reference1( New, Code ). - hex_character_reference1( Code, Code ) --> "". - - hex_digit_char( 0 ) --> "0". - hex_digit_char( 1 ) --> "1". - hex_digit_char( 2 ) --> "2". - hex_digit_char( 3 ) --> "3". - hex_digit_char( 4 ) --> "4". - hex_digit_char( 5 ) --> "5". - hex_digit_char( 6 ) --> "6". - hex_digit_char( 7 ) --> "7". - hex_digit_char( 8 ) --> "8". - hex_digit_char( 9 ) --> "9". - hex_digit_char( 10 ) --> "A". - hex_digit_char( 11 ) --> "B". - hex_digit_char( 12 ) --> "C". - hex_digit_char( 13 ) --> "D". - hex_digit_char( 14 ) --> "E". - hex_digit_char( 15 ) --> "F". - hex_digit_char( 10 ) --> "a". - hex_digit_char( 11 ) --> "b". - hex_digit_char( 12 ) --> "c". - hex_digit_char( 13 ) --> "d". - hex_digit_char( 14 ) --> "e". - hex_digit_char( 15 ) --> "f". - - quote( 0'" ) --> %' - """". - quote( 0'' ) --> - "'". - - spaces( [], [] ). - spaces( [Char|Chars0], Chars1 ) :- - ( Char =< 32 -> - spaces( Chars0, Chars1 ) - ; otherwise -> - Chars1 = [Char|Chars0] - ). - - nmtoken( Name ) --> - nmtoken_chars( Chars ), - {atom_codes(Name, Chars)}. - - nmtoken_chars( [Char|Chars] ) --> - [Char], - {nmtoken_first( Char )}, - nmtoken_chars_tail( Chars ). - - nmtoken_chars_tail( [Char|Chars] ) --> - [Char], - {nmtoken_char(Char)}, - !, - nmtoken_chars_tail( Chars ). - nmtoken_chars_tail([]) --> "". - - nmtoken_first( 0': ). - nmtoken_first( 0'_ ). - nmtoken_first( Char ) :- - alphabet( Char ). - - nmtoken_char( 0'a ). - nmtoken_char( 0'b ). - nmtoken_char( 0'c ). - nmtoken_char( 0'd ). - nmtoken_char( 0'e ). - nmtoken_char( 0'f ). - nmtoken_char( 0'g ). - nmtoken_char( 0'h ). - nmtoken_char( 0'i ). - nmtoken_char( 0'j ). - nmtoken_char( 0'k ). - nmtoken_char( 0'l ). - nmtoken_char( 0'm ). - nmtoken_char( 0'n ). - nmtoken_char( 0'o ). - nmtoken_char( 0'p ). - nmtoken_char( 0'q ). - nmtoken_char( 0'r ). - nmtoken_char( 0's ). - nmtoken_char( 0't ). - nmtoken_char( 0'u ). - nmtoken_char( 0'v ). - nmtoken_char( 0'w ). - nmtoken_char( 0'x ). - nmtoken_char( 0'y ). - nmtoken_char( 0'z ). - nmtoken_char( 0'A ). - nmtoken_char( 0'B ). - nmtoken_char( 0'C ). - nmtoken_char( 0'D ). - nmtoken_char( 0'E ). - nmtoken_char( 0'F ). - nmtoken_char( 0'G ). - nmtoken_char( 0'H ). - nmtoken_char( 0'I ). - nmtoken_char( 0'J ). - nmtoken_char( 0'K ). - nmtoken_char( 0'L ). - nmtoken_char( 0'M ). - nmtoken_char( 0'N ). - nmtoken_char( 0'O ). - nmtoken_char( 0'P ). - nmtoken_char( 0'Q ). - nmtoken_char( 0'R ). - nmtoken_char( 0'S ). - nmtoken_char( 0'T ). - nmtoken_char( 0'U ). - nmtoken_char( 0'V ). - nmtoken_char( 0'W ). - nmtoken_char( 0'X ). - nmtoken_char( 0'Y ). - nmtoken_char( 0'Z ). - nmtoken_char( 0'0 ). - nmtoken_char( 0'1 ). - nmtoken_char( 0'2 ). - nmtoken_char( 0'3 ). - nmtoken_char( 0'4 ). - nmtoken_char( 0'5 ). - nmtoken_char( 0'6 ). - nmtoken_char( 0'7 ). - nmtoken_char( 0'8 ). - nmtoken_char( 0'9 ). - nmtoken_char( 0'. ). - nmtoken_char( 0'- ). - nmtoken_char( 0'_ ). - nmtoken_char( 0': ). - - xml_string( String ) --> - quote( Quote ), - xml_string1( Quote, String ). - - xml_string1( Quote, [] ) --> - quote( Quote ), - !. - xml_string1( Quote, [Char|Chars] ) --> - [Char], - xml_string1( Quote, Chars ). - - alphabet( 0'a ). - alphabet( 0'b ). - alphabet( 0'c ). - alphabet( 0'd ). - alphabet( 0'e ). - alphabet( 0'f ). - alphabet( 0'g ). - alphabet( 0'h ). - alphabet( 0'i ). - alphabet( 0'j ). - alphabet( 0'k ). - alphabet( 0'l ). - alphabet( 0'm ). - alphabet( 0'n ). - alphabet( 0'o ). - alphabet( 0'p ). - alphabet( 0'q ). - alphabet( 0'r ). - alphabet( 0's ). - alphabet( 0't ). - alphabet( 0'u ). - alphabet( 0'v ). - alphabet( 0'w ). - alphabet( 0'x ). - alphabet( 0'y ). - alphabet( 0'z ). - alphabet( 0'A ). - alphabet( 0'B ). - alphabet( 0'C ). - alphabet( 0'D ). - alphabet( 0'E ). - alphabet( 0'F ). - alphabet( 0'G ). - alphabet( 0'H ). - alphabet( 0'I ). - alphabet( 0'J ). - alphabet( 0'K ). - alphabet( 0'L ). - alphabet( 0'M ). - alphabet( 0'N ). - alphabet( 0'O ). - alphabet( 0'P ). - alphabet( 0'Q ). - alphabet( 0'R ). - alphabet( 0'S ). - alphabet( 0'T ). - alphabet( 0'U ). - alphabet( 0'V ). - alphabet( 0'W ). - alphabet( 0'X ). - alphabet( 0'Y ). - alphabet( 0'Z ). - - digit( C ) --> [C], {digit_table( C )}. - - digit_table( 0'0 ). - digit_table( 0'1 ). - digit_table( 0'2 ). - digit_table( 0'3 ). - digit_table( 0'4 ). - digit_table( 0'5 ). - digit_table( 0'6 ). - digit_table( 0'7 ). - digit_table( 0'8 ). - digit_table( 0'9 ). - - digits( [Digit|Digits] ) --> - digit( Digit ), - digits( Digits ). - digits( [] ) --> []. - - character_entity( "quot", 0'" ). %' - character_entity( "amp", 0'& ). %' - character_entity( "lt", 0'< ). %' - character_entity( "gt", 0'> ). %' - character_entity( "apos", 0'' ). - - /* pp( +XMLDocument ) "pretty prints" XMLDocument on the current - * output stream. - */ - pp( xml(Attributes, Document) ) :- - write( 'xml( ' ), pp_attributes( Attributes, 0 ), pp_comma, nl, - pp_list( Document, s(0) ), - write( ' ).' ), nl. - pp( malformed(Attributes, Document) ) :- - write( 'malformed( ' ), pp_attributes( Attributes, 0 ), pp_comma, nl, - pp_list( Document, s(0) ), - write( ' ).' ), nl. - - pp_indented( [], Indent ) :- - pp_indent( Indent), write( '[]' ). - pp_indented( List, Indent ) :- - List = [_|_], - pp_indent( Indent ), - pp_list( List, Indent ). - pp_indented( comment(Text), Indent ) :- - pp_indent( Indent ), write( 'comment(' ), pp_string(Text), write( ')' ). - pp_indented( namespace(URI,Prefix,Element), Indent ) :- - pp_indent( Indent ), - write( 'namespace( ' ), writeq( URI ), pp_comma_sp, - pp_string( Prefix ), pp_comma, nl, - pp_indented( Element, s(Indent) ), nl, - pp_indent( s(Indent) ), write( ')' ). - pp_indented( element(Tag,Attributes,Contents), Indent ) :- - pp_indent( Indent ), write( 'element( ' ), writeq( Tag ), pp_comma, nl, - pp_attributes( Attributes, s(Indent) ), pp_comma, nl, - pp_list( Contents, s(Indent) ), write( ' )' ). - pp_indented( instructions(Target, Processing), Indent ) :- - pp_indent( Indent ), write( 'instructions( ' ), writeq( Target ), pp_comma_sp, - pp_string(Processing), write( ')' ). - pp_indented( doctype(Name, DoctypeId), Indent ) :- - pp_indent( Indent ), write( 'doctype( ' ), writeq( Name ), pp_comma_sp, - pp_indented( DoctypeId, s(Indent) ), %' - write( ' )' ). - pp_indented( cdata(CData), Indent ) :- - pp_indent( Indent ), write( 'cdata(' ), pp_string(CData), write( ')' ). - pp_indented( pcdata(PCData), Indent ) :- - pp_indent( Indent ), write( 'pcdata(' ), pp_string(PCData), write( ')' ). - pp_indented( public(URN,URL), _Indent ) :- - write( 'public(' ), pp_string(URN), pp_comma_sp, - pp_string(URL), write( ')' ). - pp_indented( public(URN,URL,Literals), Indent ) :- - write( 'public(' ), pp_string(URN), pp_comma_sp, - pp_string(URL), pp_list( Literals, s(Indent) ), write( ')' ). - pp_indented( system(URL), _Indent ) :- - write( 'system(' ), pp_string(URL), write( ')' ). - pp_indented( system(URL,Literals), Indent ) :- - write( 'system(' ), pp_string(URL), pp_comma_sp, - pp_list( Literals, s(Indent) ), write( ')' ). - pp_indented( local, _Indent ) :- - write( local ). - pp_indented( local(Literals), Indent ) :- - write( 'local(' ), nl, - pp_list( Literals, s(Indent) ), write( ')' ). - pp_indented( dtd_literal(String), Indent ) :- - pp_indent( Indent ), write( 'dtd_literal(' ), pp_string(String), write( ')' ). - pp_indented( out_of_context(Tag), Indent ) :- - pp_indent( Indent ), write( '/* SYNTAX ERROR */ out_of_context( ' ), - writeq( Tag ), write( ' )' ). - pp_indented( unparsed(String), Indent ) :- - pp_indent( Indent ), write( '/* SYNTAX ERROR */ unparsed( ' ), - pp_string(String), write( ' )' ). - - pp_list( [], Indent ) :- - pp_indent( Indent ), write( [] ). - pp_list( [H|T], Indent ) :- - pp_indent( Indent ), write( '[' ), nl, - pp_indented( H, Indent ), - pp_list1( T, Indent ), - pp_indent( Indent ), write( ']' ). - - pp_list1( [], _Indent ) :- - nl. - pp_list1( [H|T], Indent ) :- - pp_comma, nl, - pp_indented( H, Indent ), - pp_list1( T, Indent ). - - pp_attributes( [], Indent ) :- - pp_indent( Indent ), write( [] ). - pp_attributes( [Attribute|Attributes], Indent ) :- - pp_indent( Indent ), write( '[' ), - pp_attributes1( Attributes, Attribute ), - write( ']' ). - - pp_attributes1( [], Name=Value ) :- - pp_name( Name ), pp_string( Value ). - pp_attributes1( [H|T], Name=Value ) :- - pp_name( Name ), pp_string( Value ), pp_comma_sp, - pp_attributes1( T, H ). - - - pp_name( Name ) :- - ( possible_operator( Name ) -> - write( '(' ), write( Name ), write( ')=' ) - ; otherwise -> - writeq( Name ), write( '=' ) - ). - - possible_operator( (abolish) ). - possible_operator( (attribute) ). - possible_operator( (check_advice) ). - possible_operator( (compile_command) ). - possible_operator( (delay) ). - possible_operator( (demon) ). - possible_operator( (discontiguous) ). - possible_operator( (div) ). - possible_operator( (do) ). - possible_operator( (document_export) ). - possible_operator( (document_import) ). - possible_operator( (dy) ). - possible_operator( (dynamic) ). - possible_operator( (edb) ). - possible_operator( (eexport) ). - possible_operator( (else) ). - possible_operator( (except) ). - possible_operator( (export) ). - possible_operator( (foreign_pred) ). - possible_operator( (from) ). - possible_operator( (from_chars) ). - possible_operator( (from_file) ). - possible_operator( (from_stream) ). - possible_operator( (global) ). - possible_operator( (help) ). - possible_operator( (hilog) ). - possible_operator( (if) ). - possible_operator( (import) ). - possible_operator( (index) ). - possible_operator( (initialization) ). - possible_operator( (is) ). - possible_operator( (listing) ). - possible_operator( (local) ). - possible_operator( (locked) ). - possible_operator( (meta_predicate) ). - possible_operator( (mod) ). - possible_operator( (mode) ). - possible_operator( (module_transparent) ). - possible_operator( (multifile) ). - possible_operator( (namic) ). - possible_operator( (nocheck_advice) ). - possible_operator( (nospy) ). - possible_operator( (not) ). - possible_operator( (of) ). - possible_operator( (once) ). - possible_operator( (onto_chars) ). - possible_operator( (onto_file) ). - possible_operator( (onto_stream) ). - possible_operator( (parallel) ). - possible_operator( (public) ). - possible_operator( (r) ). - possible_operator( (rem) ). - possible_operator( (skipped) ). - possible_operator( (spy) ). - possible_operator( (table) ). - possible_operator( (then) ). - possible_operator( (thread_local) ). - possible_operator( (ti) ). - possible_operator( (ti_off) ). - possible_operator( (traceable) ). - possible_operator( (unskipped) ). - possible_operator( (untraceable) ). - possible_operator( (use_subsumptive_tabling) ). - possible_operator( (use_variant_tabling) ). - possible_operator( (volatile) ). - possible_operator( (with) ). - possible_operator( (with_input_from_chars) ). - possible_operator( (with_output_to_chars) ). - possible_operator( (xor) ). - - pp_indent( 0 ). - pp_indent( s(N) ) :- - write( ' ' ), - pp_indent( N ). - - pp_comma :- - write( ',' ). - - pp_comma_sp :- - write( ', ' ). - - - % Entity and Namespace map operations: these maps are usually quite small, so - % a linear list lookup is okay. They could be substituted by a logarithmic - % data structure - in extremis. - - - /* empty_map( ?Map ) is true if Map is a null map. - */ - :- private(empty_map/1). - :- mode(empty_map(?nonvar), zero_or_one). - :- info(empty_map/1, [ - comment is 'True if Map is a null map.', - argnames is ['Map']]). - - empty_map( [] ). - - /* map_member( +Key, +Map, ?Data ) is true if Map is a ordered map structure - * which records the pair Key-Data. Key must be ground. - */ - :- private(map_member/3). - :- mode(map_member(+nonvar, +nonvar, ?nonvar), zero_or_one). - :- info(map_member/3, [ - comment is 'True if Map is a ordered map structure which records the pair Key-Data. Key must be ground.', - argnames is ['Key', 'Map', 'Data']]). - - map_member( Key0, [Key1-Data1|Rest], Data0 ) :- - ( Key0 == Key1 -> - Data0 = Data1 - ; Key0 @> Key1 -> - map_member( Key0, Rest, Data0 ) - ). - - /* map_store( +Map0, +Key, +Data, ?Map1 ) is true if Map0 is an ordered map - * structure, Key must be ground, and Map1 is identical to Map0 except that - * the pair Key-Data is recorded by Map1. - */ - :- private(map_store/4). - :- mode(map_store(+nonvar, +nonvar, +nonvar, ?nonvar), zero_or_one). - :- info(map_store/4, [ - comment is 'True if Map0 is an ordered map structure, Key must be ground, and Map1 is identical to Map0 except that the pair Key-Data is recorded by Map1.', - argnames is ['Map0', 'Key', 'Data', 'Map1']]). - - map_store( [], Key, Data, [Key-Data] ). - map_store( [Key0-Data0|Map0], Key, Data, Map ) :- - ( Key == Key0 -> - Map = [Key-Data|Map0] - ; Key @< Key0 -> - Map = [Key-Data,Key0-Data0|Map0] - ; otherwise -> % > - Map = [Key0-Data0|Map1], - map_store( Map0, Key, Data, Map1 ) - ). - - /* context(?Element, ?PreserveSpace, ?CurrentNS, ?DefaultNS, ?Entities, ?Namespaces ) - * is an ADT hiding the "state" arguments for XML Acquisition - */ - initial_context( - Controls, - context(void,PreserveSpace,'','',Entities,Empty, - RemoveAttributePrefixes,AllowAmpersand) - ) :- - empty_map( Empty ), - ( member( extended_characters(false), Controls ) -> - Entities = Empty - ; otherwise -> - extended_character_entities(Entities) - ), - ( member( format(false), Controls ) -> - PreserveSpace = true - ; otherwise -> - PreserveSpace = false - ), - ( member( remove_attribute_prefixes(true), Controls ) -> - RemoveAttributePrefixes = true - ; otherwise -> - RemoveAttributePrefixes = false - ), - ( member( allow_ampersand(true), Controls ) -> - AllowAmpersand = true - ; otherwise -> - AllowAmpersand = false - ). - - context_update( current_namespace, Context0, URI, Context1 ) :- - Context0 = context(Element,Preserve,_Current,Default,Entities, - Namespaces,RemoveAttributePrefixes,Amp), - Context1 = context(Element,Preserve,URI,Default,Entities, - Namespaces,RemoveAttributePrefixes,Amp). - context_update( element, Context0, Tag, Context1 ) :- - Context0 = context(_Element,Preserve,Current,Default,Entities, - Namespaces,RemoveAttributePrefixes,Amp), - Context1 = context(tag(Tag),Preserve,Current,Default,Entities, - Namespaces,RemoveAttributePrefixes,Amp). - context_update( default_namespace, Context0, URI, Context1 ):- - Context0 = context(Element,Preserve,Current,_Default,Entities, - Namespaces,RemoveAttributePrefixes,Amp), - Context1 = context(Element,Preserve,Current,URI,Entities, - Namespaces,RemoveAttributePrefixes,Amp). - context_update( space_preserve, Context0, Boolean, Context1 ):- - Context0 = context(Element,_Preserve,Current,Default,Entities, - Namespaces,RemoveAttributePrefixes,Amp), - Context1 = context(Element,Boolean,Current,Default,Entities, - Namespaces,RemoveAttributePrefixes,Amp). - context_update( ns_prefix(Prefix), Context0, URI, Context1 ) :- - Context0 = context(Element,Preserve,Current,Default,Entities, - Namespaces0,RemoveAttributePrefixes,Amp), - Context1 = context(Element,Preserve,Current,Default,Entities, - Namespaces1,RemoveAttributePrefixes,Amp), - map_store( Namespaces0, Prefix, URI, Namespaces1 ). - context_update( entity(Name), Context0, String, Context1 ) :- - Context0 = context(Element,Preserve,Current,Default,Entities0, - Namespaces,RemoveAttributePrefixes,Amp), - Context1 = context(Element,Preserve,Current,Default,Entities1, - Namespaces,RemoveAttributePrefixes,Amp), - map_store( Entities0, Name, String, Entities1 ). - - remove_attribute_prefixes( Context ) :- - Context = context(_Element,_Preserve,_Current,_Default,_Entities, - _Namespaces,true,_Amp). - - current_tag( Context, Tag ) :- - Context = context(tag(Tag),_Preserve,_Current,_Default,_Entities, - _Namespaces,_RPFA,_Amp). - - current_namespace( Context, Current ) :- - Context = context(_Element,_Preserve,Current,_Default,_Entities, - _Namespaces,_RPFA,_Amp). - - default_namespace( Context, Default ) :- - Context = context(_Element,_Preserve,_Current,Default,_Entities, - _Namespaces,_RPFA,_Amp). - - space_preserve( Context ) :- - Context = context(tag(_Tag),true,_Current,_Default,_Entities, - _Namespaces,_RPFA,_Amp). - - specific_namespace( Prefix, Context, URI ) :- - Context = context(_Element,_Preserve,_Current,_Default,_Entities, - Namespaces,_RPFA,_Amp), - map_member( Prefix, Namespaces, URI ). - - defined_entity( Reference, Context, String ) :- - Context = context(_Element,_Preserve,_Current,_Default,Entities, - _Namespaces,_RPFA,_Amp), - map_member( Reference, Entities, String ). - - close_context( Context, Terms, WellFormed ) :- - Context = context(Element,_Preserve,_Current,_Default,_Entities, - _Namespaces,_RPFA,_Amp), - close_context1( Element, Terms, WellFormed ). - - close_context1( void, [], true ). - close_context1( tag(TagChars), [out_of_context(Tag)], false ) :- - atom_chars( Tag, TagChars ). - - void_context( - context(void,_Preserve,_Current,_Default,_Entities,_Names,_RPFA,_Amp) - ). - - allow_ampersand( - context(_Void,_Preserve,_Current,_Default,_Entities,_Names,_RPFA,true) - ). - - /* pp_string( +String ) prints String onto the current output stream. - * If String contains only 7-bit chars it is printed in shorthand quoted - * format, otherwise it is written as a list. - * If your Prolog uses " to delimit a special string type, just use write/1. - */ - :- private(pp_string/1). - :- mode(pp_string(+nonvar), zero_or_one). - :- info(pp_string/1, [ - comment is 'Prints String onto the current output stream. If String contains only 7-bit chars it is printed in shorthand quoted format, otherwise it is written as a list.', - argnames is ['String']]). - - pp_string( Chars ) :- - ( member( Char, Chars ), - (Char > 255 ; Char < 9) -> - write( Chars ) - ; otherwise -> - put_quote, - pp_string1( Chars ), - put_quote - ). - - put_quote :- - put_code( 0'" ). % ' - - pp_string1( [] ). - pp_string1( [Char|Chars] ) :- - ( Char =:= """" -> % Meta-quote - put_code( Char ), - put_code( Char ), - pp_string1( Chars ) - ; Char =:= 13, % Handle Windows border-settings - Chars = [10|Chars1] -> - put_code( 10 ), - pp_string1( Chars1 ) - ; otherwise -> - put_code( Char ), - pp_string1( Chars ) - ). - - xml_declaration_attributes_valid( [] ). - xml_declaration_attributes_valid( [Name=Value|Attributes] ) :- - xml_declaration_attribute_valid( Name, Value ), - xml_declaration_attributes_valid( Attributes ). - - xml_declaration_attribute_valid( Name, Value ) :- - lowercase( Value, Lowercase ), - canonical_xml_declaration_attribute( Name, Lowercase ). - - canonical_xml_declaration_attribute( version, "1.0" ). - canonical_xml_declaration_attribute( standalone, "yes" ). - canonical_xml_declaration_attribute( standalone, "no" ). - % The encodings here are all valid for the output produced. - canonical_xml_declaration_attribute( encoding, "utf-8" ). - % canonical_xml_declaration_attribute( encoding, "utf-16" ). - % This is erroneous for the output of this library - canonical_xml_declaration_attribute( encoding, "us-ascii" ). - canonical_xml_declaration_attribute( encoding, "ascii" ). - canonical_xml_declaration_attribute( encoding, "iso-8859-1" ). - canonical_xml_declaration_attribute( encoding, "iso-8859-2" ). - canonical_xml_declaration_attribute( encoding, "iso-8859-15" ). - canonical_xml_declaration_attribute( encoding, "windows-1252" ). - % In general, it's better not to specify an encoding. - - /* lowercase( +MixedCase, ?Lowercase ) holds when Lowercase and MixedCase are - * lists of character codes, and Lowercase is identical to MixedCase with - * every uppercase character replaced by its lowercase equivalent. - */ - lowercase( [], [] ). - lowercase( [Char|Chars], [Lower|LowerCase] ) :- - ( Char >= "A", Char =< "Z" -> - Lower is Char + "a" - "A" - ; otherwise -> - Lower = Char - ), - lowercase( Chars, LowerCase ). - - extended_character_entities( [ - "Aacute"-[193], % latin capital letter A with acute, - "aacute"-[225], % latin small letter a with acute, - "Acirc"-[194], % latin capital letter A with circumflex, - "acirc"-[226], % latin small letter a with circumflex, - "acute"-[180], % acute accent = spacing acute, - "AElig"-[198], % latin capital letter AE - "aelig"-[230], % latin small letter ae - "Agrave"-[192], % latin capital letter A with grave - "agrave"-[224], % latin small letter a with grave - "alefsym"-[8501], % alef symbol = first transfinite cardinal, - "Alpha"-[913], % greek capital letter alpha, U+0391 - "alpha"-[945], % greek small letter alpha, - "and"-[8743], % logical and = wedge, U+2227 ISOtech - "ang"-[8736], % angle, U+2220 ISOamso - "Aring"-[197], % latin capital letter A with ring above - "aring"-[229], % latin small letter a with ring above - "asymp"-[8776], % almost equal to = asymptotic to, - "Atilde"-[195], % latin capital letter A with tilde, - "atilde"-[227], % latin small letter a with tilde, - "Auml"-[196], % latin capital letter A with diaeresis, - "auml"-[228], % latin small letter a with diaeresis, - "bdquo"-[8222], % double low-9 quotation mark, U+201E NEW - "Beta"-[914], % greek capital letter beta, U+0392 - "beta"-[946], % greek small letter beta, U+03B2 ISOgrk3 - "brvbar"-[166], % broken bar = broken vertical bar, - "bull"-[8226], % bullet = black small circle, - "cap"-[8745], % intersection = cap, U+2229 ISOtech - "Ccedil"-[199], % latin capital letter C with cedilla, - "ccedil"-[231], % latin small letter c with cedilla, - "cedil"-[184], % cedilla = spacing cedilla, U+00B8 ISOdia> - "cent"-[162], % cent sign, U+00A2 ISOnum> - "Chi"-[935], % greek capital letter chi, U+03A7 - "chi"-[967], % greek small letter chi, U+03C7 ISOgrk3 - "circ"-[710], % modifier letter circumflex accent, - "clubs"-[9827], % black club suit = shamrock, - "cong"-[8773], % approximately equal to, U+2245 ISOtech - "copy"-[169], % copyright sign, U+00A9 ISOnum> - "crarr"-[8629], % downwards arrow with corner leftwards - "cup"-[8746], % union = cup, U+222A ISOtech - "curren"-[164], % currency sign, U+00A4 ISOnum> - "dagger"-[8224], % dagger, U+2020 ISOpub - "Dagger"-[8225], % double dagger, U+2021 ISOpub - "darr"-[8595], % downwards arrow, U+2193 ISOnum - "dArr"-[8659], % downwards double arrow, U+21D3 ISOamsa - "deg"-[176], % degree sign, U+00B0 ISOnum> - "Delta"-[916], % greek capital letter delta, - "delta"-[948], % greek small letter delta, - "diams"-[9830], % black diamond suit, U+2666 ISOpub - "divide"-[247], % division sign, U+00F7 ISOnum> - "Eacute"-[201], % latin capital letter E with acute, - "eacute"-[233], % latin small letter e with acute, - "Ecirc"-[202], % latin capital letter E with circumflex, - "ecirc"-[234], % latin small letter e with circumflex, - "Egrave"-[200], % latin capital letter E with grave, - "egrave"-[232], % latin small letter e with grave, - "empty"-[8709], % empty set = null set = diameter, - "emsp"-[8195], % em space, U+2003 ISOpub - "ensp"-[8194], % en space, U+2002 ISOpub - "Epsilon"-[917], % greek capital letter epsilon, U+0395 - "epsilon"-[949], % greek small letter epsilon, - "equiv"-[8801], % identical to, U+2261 ISOtech - "Eta"-[919], % greek capital letter eta, U+0397 - "eta"-[951], % greek small letter eta, U+03B7 ISOgrk3 - "ETH"-[208], % latin capital letter ETH, U+00D0 ISOlat1> - "eth"-[240], % latin small letter eth, U+00F0 ISOlat1> - "Euml"-[203], % latin capital letter E with diaeresis, - "euml"-[235], % latin small letter e with diaeresis, - "euro"-[8364], % euro sign, U+20AC NEW - "exist"-[8707], % there exists, U+2203 ISOtech - "fnof"-[402], % latin small f with hook = function - "forall"-[8704], % for all, U+2200 ISOtech - "frac12"-[189], % vulgar fraction one half - "frac14"-[188], % vulgar fraction one quarter - "frac34"-[190], % vulgar fraction three quarters - "frasl"-[8260], % fraction slash, U+2044 NEW - "Gamma"-[915], % greek capital letter gamma, - "gamma"-[947], % greek small letter gamma, - "ge"-[8805], % greater-than or equal to, - "harr"-[8596], % left right arrow, U+2194 ISOamsa - "hArr"-[8660], % left right double arrow, - "hearts"-[9829], % black heart suit = valentine, - "hellip"-[8230], % horizontal ellipsis = three dot leader, - "Iacute"-[205], % latin capital letter I with acute, - "iacute"-[237], % latin small letter i with acute, - "Icirc"-[206], % latin capital letter I with circumflex, - "icirc"-[238], % latin small letter i with circumflex, - "iexcl"-[161], % inverted exclamation mark, U+00A1 ISOnum> - "Igrave"-[204], % latin capital letter I with grave, - "igrave"-[236], % latin small letter i with grave, - "image"-[8465], % blackletter capital I = imaginary part, - "infin"-[8734], % infinity, U+221E ISOtech - "int"-[8747], % integral, U+222B ISOtech - "Iota"-[921], % greek capital letter iota, U+0399 - "iota"-[953], % greek small letter iota, U+03B9 ISOgrk3 - "iquest"-[191], % inverted question mark - "isin"-[8712], % element of, U+2208 ISOtech - "Iuml"-[207], % latin capital letter I with diaeresis, - "iuml"-[239], % latin small letter i with diaeresis, - "Kappa"-[922], % greek capital letter kappa, U+039A - "kappa"-[954], % greek small letter kappa, - "Lambda"-[923], % greek capital letter lambda, - "lambda"-[955], % greek small letter lambda, - "lang"-[9001], % left-pointing angle bracket = bra, - "laquo"-[171], % left-pointing double angle quotation mark - "larr"-[8592], % leftwards arrow, U+2190 ISOnum - "lArr"-[8656], % leftwards double arrow, U+21D0 ISOtech - "lceil"-[8968], % left ceiling = apl upstile, - "ldquo"-[8220], % left double quotation mark, - "le"-[8804], % less-than or equal to, U+2264 ISOtech - "lfloor"-[8970], % left floor = apl downstile, - "lowast"-[8727], % asterisk operator, U+2217 ISOtech - "loz"-[9674], % lozenge, U+25CA ISOpub - "lrm"-[8206], % left-to-right mark, U+200E NEW RFC 2070 - "lsaquo"-[8249], % single left-pointing angle quotation mark, - "lsquo"-[8216], % left single quotation mark, - "macr"-[175], % macron = spacing macron = overline - "mdash"-[8212], % em dash, U+2014 ISOpub - "micro"-[181], % micro sign, U+00B5 ISOnum> - "middot"-[183], % middle dot = Georgian comma - "minus"-[8722], % minus sign, U+2212 ISOtech - "Mu"-[924], % greek capital letter mu, U+039C - "mu"-[956], % greek small letter mu, U+03BC ISOgrk3 - "nabla"-[8711], % nabla = backward difference, - "nbsp"-[160], % no-break space = non-breaking space, - "ndash"-[8211], % en dash, U+2013 ISOpub - "ne"-[8800], % not equal to, U+2260 ISOtech - "ni"-[8715], % contains as member, U+220B ISOtech - "not"-[172], % not sign, U+00AC ISOnum> - "notin"-[8713], % not an element of, U+2209 ISOtech - "nsub"-[8836], % not a subset of, U+2284 ISOamsn - "Ntilde"-[209], % latin capital letter N with tilde, - "ntilde"-[241], % latin small letter n with tilde, - "Nu"-[925], % greek capital letter nu, U+039D - "nu"-[957], % greek small letter nu, U+03BD ISOgrk3 - "Oacute"-[211], % latin capital letter O with acute, - "oacute"-[243], % latin small letter o with acute, - "Ocirc"-[212], % latin capital letter O with circumflex, - "ocirc"-[244], % latin small letter o with circumflex, - "OElig"-[338], % latin capital ligature OE, - "oelig"-[339], % latin small ligature oe, U+0153 ISOlat2 - "Ograve"-[210], % latin capital letter O with grave, - "ograve"-[242], % latin small letter o with grave, - "oline"-[8254], % overline = spacing overscore, - "Omega"-[937], % greek capital letter omega, - "omega"-[969], % greek small letter omega, - "Omicron"-[927], % greek capital letter omicron, U+039F - "omicron"-[959], % greek small letter omicron, U+03BF NEW - "oplus"-[8853], % circled plus = direct sum, - "or"-[8744], % logical or = vee, U+2228 ISOtech - "ordf"-[170], % feminine ordinal indicator, U+00AA ISOnum> - "ordm"-[186], % masculine ordinal indicator, - "Oslash"-[216], % latin capital letter O with stroke - "oslash"-[248], % latin small letter o with stroke, - "Otilde"-[213], % latin capital letter O with tilde, - "otilde"-[245], % latin small letter o with tilde, - "otimes"-[8855], % circled times = vector product, - "Ouml"-[214], % latin capital letter O with diaeresis, - "ouml"-[246], % latin small letter o with diaeresis, - "para"-[182], % pilcrow sign = paragraph sign, - "part"-[8706], % partial differential, U+2202 ISOtech - "permil"-[8240], % per mille sign, U+2030 ISOtech - "perp"-[8869], % up tack = orthogonal to = perpendicular, - "Phi"-[934], % greek capital letter phi, - "phi"-[966], % greek small letter phi, U+03C6 ISOgrk3 - "Pi"-[928], % greek capital letter pi, U+03A0 ISOgrk3 - "pi"-[960], % greek small letter pi, U+03C0 ISOgrk3 - "piv"-[982], % greek pi symbol, U+03D6 ISOgrk3 - "plusmn"-[177], % plus-minus sign = plus-or-minus sign, - "pound"-[163], % pound sign, U+00A3 ISOnum> - "prime"-[8242], % prime = minutes = feet, U+2032 ISOtech - "Prime"-[8243], % double prime = seconds = inches, - "prod"-[8719], % n-ary product = product sign, - "prop"-[8733], % proportional to, U+221D ISOtech - "Psi"-[936], % greek capital letter psi, - "psi"-[968], % greek small letter psi, U+03C8 ISOgrk3 - "radic"-[8730], % square root = radical sign, - "rang"-[9002], % right-pointing angle bracket = ket, - "raquo"-[187], % right-pointing double angle quotation mark - "rarr"-[8594], % rightwards arrow, U+2192 ISOnum - "rArr"-[8658], % rightwards double arrow, - "rceil"-[8969], % right ceiling, U+2309 ISOamsc - "rdquo"-[8221], % right double quotation mark, - "real"-[8476], % blackletter capital R = real part symbol, - "reg"-[174], % registered sign = registered trade mark sign, - "rfloor"-[8971], % right floor, U+230B ISOamsc - "Rho"-[929], % greek capital letter rho, U+03A1 - "rho"-[961], % greek small letter rho, U+03C1 ISOgrk3 - "rlm"-[8207], % right-to-left mark, U+200F NEW RFC 2070 - "rsaquo"-[8250], % single right-pointing angle quotation mark, - "rsquo"-[8217], % right single quotation mark, - "sbquo"-[8218], % single low-9 quotation mark, U+201A NEW - "Scaron"-[352], % latin capital letter S with caron, - "scaron"-[353], % latin small letter s with caron, - "sdot"-[8901], % dot operator, U+22C5 ISOamsb - "sect"-[167], % section sign, U+00A7 ISOnum> - "shy"-[173], % soft hyphen = discretionary hyphen, - "Sigma"-[931], % greek capital letter sigma, - "sigma"-[963], % greek small letter sigma, - "sigmaf"-[962], % greek small letter final sigma, - "sim"-[8764], % tilde operator = varies with = similar to, - "spades"-[9824], % black spade suit, U+2660 ISOpub - "sub"-[8834], % subset of, U+2282 ISOtech - "sube"-[8838], % subset of or equal to, U+2286 ISOtech - "sum"-[8721], % n-ary sumation, U+2211 ISOamsb - "sup"-[8835], % superset of, U+2283 ISOtech - "sup1"-[185], % superscript one = superscript digit one, - "sup2"-[178], % superscript two = superscript digit two - "sup3"-[179], % superscript three = superscript digit three - "supe"-[8839], % superset of or equal to, - "szlig"-[223], % latin small letter sharp s = ess-zed, - "Tau"-[932], % greek capital letter tau, U+03A4 - "tau"-[964], % greek small letter tau, U+03C4 ISOgrk3 - "there4"-[8756], % therefore, U+2234 ISOtech - "Theta"-[920], % greek capital letter theta, - "theta"-[952], % greek small letter theta, - "thetasym"-[977], % greek small letter theta symbol, - "thinsp"-[8201], % thin space, U+2009 ISOpub - "THORN"-[222], % latin capital letter THORN, - "thorn"-[254], % latin small letter thorn with, - "tilde"-[732], % small tilde, U+02DC ISOdia - "times"-[215], % multiplication sign, U+00D7 ISOnum> - "trade"-[8482], % trade mark sign, U+2122 ISOnum - "Uacute"-[218], % latin capital letter U with acute, - "uacute"-[250], % latin small letter u with acute, - "uarr"-[8593], % upwards arrow, U+2191 ISOnum - "uArr"-[8657], % upwards double arrow, U+21D1 ISOamsa - "Ucirc"-[219], % latin capital letter U with circumflex, - "ucirc"-[251], % latin small letter u with circumflex, - "Ugrave"-[217], % latin capital letter U with grave, - "ugrave"-[249], % latin small letter u with grave, - "uml"-[168], % diaeresis = spacing diaeresis, - "upsih"-[978], % greek upsilon with hook symbol, - "Upsilon"-[933], % greek capital letter upsilon, - "upsilon"-[965], % greek small letter upsilon, - "Uuml"-[220], % latin capital letter U with diaeresis, - "uuml"-[252], % latin small letter u with diaeresis, - "weierp"-[8472], % script capital P = power set - "Xi"-[926], % greek capital letter xi, U+039E ISOgrk3 - "xi"-[958], % greek small letter xi, U+03BE ISOgrk3 - "Yacute"-[221], % latin capital letter Y with acute, - "yacute"-[253], % latin small letter y with acute, - "yen"-[165], % yen sign = yuan sign, U+00A5 ISOnum> - "yuml"-[255], % latin small letter y with diaeresis, - "Yuml"-[376], % latin capital letter Y with diaeresis, - "Zeta"-[918], % greek capital letter zeta, U+0396 - "zeta"-[950], % greek small letter zeta, U+03B6 ISOgrk3 - "zwj"-[8205], % zero width joiner, U+200D NEW RFC 2070 - "zwnj"-[8204] % zero width non-joiner, - ] ). - - - /* chars( ?Chars, ?Plus, ?Minus ) used as chars( ?Chars ) in a DCG to - * copy the list Chars inline. - * - * This is best expressed in terms of append/3 where append/3 is built-in. - * For other Prologs, a straightforward specification can be used: - * - * chars( [] ) --> "". - * chars( [Char|Chars] ) --> - * [Char], - * chars( Chars ). - */ - - chars( Chars, Plus, Minus ) :- - append( Chars, Minus, Plus ). - - - /* fault( +Term, +Indentation, ?SubTerm, ?Path, ?Message ) identifies SubTerm - * as a sub-term of Term which cannot be serialized after Indentation. - * Message is an atom naming the type of error; Path is a string encoding a - * list of SubTerm's ancestor elements in the form {(id)}* where is the - * element tag and is the value of any attribute _named_ id. - */ - :- private(fault/5). - :- mode(fault(+nonvar, +nonvar, ?nonvar, ?nonvar, ?nonvar), zero_or_one). - :- info(fault/5, [ - comment is 'Identifies SubTerm as a sub-term of Term which cannot be serialized after Indentation. Message is an atom naming the type of error; Path is a string encoding a list of SubTerm''s ancestor elements in the form {(id)}* where is the element tag and is the value of any attribute _named_ id.', - argnames is ['Term', 'Indentation', 'SubTerm', 'Path', 'Message']]). - - fault( Term, _Indent, Term, [], "Illegal Variable" ) :- - var( Term ). - fault( xml(Attributes,_Content), _Indent, Term, [], Message ) :- - member( Attribute, Attributes ), - attribute_fault( Attribute, Term, Message ). - fault( xml(_Attributes,Content), Indent, Culprit, Path, Message ) :- - content_fault( Content, Indent, Culprit, Path, Message ). - fault( Term, _Indent, Term, [], "Illegal Term" ). - - content_fault( Term, _Indent, Term, [], "Illegal Variable" ) :- - var( Term ). - content_fault( pcdata(Chars), _Indent, Chars, [], "Invalid Character Data" ) :- - \+ is_chars( Chars ). - content_fault( cdata(Chars), _Indent, Chars, [], "Invalid Character Data" ) :- - \+ is_chars( Chars ). - content_fault( [H|_T], Indent, Culprit, Path, Message ) :- - content_fault( H, Indent, Culprit, Path, Message ). - content_fault( [_H|T], Indent, Culprit, Path, Message ) :- - content_fault( T, Indent, Culprit, Path, Message ). - content_fault( namespace(_URI,_Prefix,Element), Indent, Culprit, Path, Message ) :- - element_fault( Element, [0' |Indent], Culprit, Path, Message ). - content_fault( Element, Indent, Culprit, Path, Message ) :- - element_fault( Element, [0' |Indent], Culprit, Path, Message ). - content_fault( Term, Indent, Term, [], "Illegal Term" ) :- - \+ generation(Term, "", false, Indent, _Format, _Plus, _Minus ). - - element_fault( element(Tag, _Attributes, _Contents), _Indent, Tag, [], "Tag must be an atom" ) :- - \+ atom( Tag ). - element_fault( element(Tag, Attributes, _Contents), _Indent, Tag, [], "Attributes must be instantiated" ) :- - var( Attributes ). - element_fault( element(Tag, Attributes, _Contents), _Indent, Faulty, Path, Message ) :- - fault_path( Tag, Attributes, Path, [] ), - member( Attribute, Attributes ), - attribute_fault( Attribute, Faulty, Message ). - element_fault( element(Tag, Attributes, Contents), Indent, Culprit, Path, Message ) :- - fault_path( Tag, Attributes, Path, Path1 ), - content_fault( Contents, Indent, Culprit, Path1, Message ). - - attribute_fault( Attribute, Attribute, "Illegal Variable" ) :- - var( Attribute ). - attribute_fault( Name=Value, Name=Value, "Attribute Name must be atom" ) :- - \+ atom(Name). - attribute_fault( Name=Value, Name=Value, "Attribute Value must be chars" ) :- - \+ is_chars( Value ). - attribute_fault( Attribute, Attribute, "Malformed Attribute" ) :- - \+ Attribute = (_Name=_Value). - - is_chars( Chars ) :- - is_list( Chars ), - \+ (member( Char, Chars ), \+ (integer(Char), Char >=0, Char =< 255)). - - fault_path( Tag, Attributes ) --> - {atom_codes( Tag, Chars )}, - chars( Chars ), - fault_id( Attributes ), - " ". - - fault_id( Attributes ) --> - {member( id=Chars, Attributes ), is_chars( Chars )}, - !, - "(", chars(Chars), ")". - fault_id( _Attributes ) --> "". - - - /* document_generation( +Format, +Document ) is a DCG generating Document - * as a list of character codes. Format is true|false defining whether layouts, - * to provide indentation, should be added between the element content of - * the resultant "string". Note that formatting is disabled for elements that - * are interspersed with pcdata/1 terms, such as XHTML's 'inline' elements. - * Also, Format is over-ridden, for an individual element, by an explicit - * 'xml:space'="preserve" attribute. - */ - :- private(document_generation//2). - :- mode(document_generation(+nonvar, +nonvar), zero_or_one). - :- info(document_generation//2, [ - comment is 'DCG generating Document as a list of character codes. Format is true|false defining whether layouts, to provide indentation, should be added between the element content of the resultant "string". Note that formatting is disabled for elements that are interspersed with pcdata/1 terms, such as XHTML''s ''inline'' elements. Also, Format is over-ridden, for an individual element, by an explicit ''xml:space''="preserve" attribute.', - argnames is ['Format', 'Document']]). - - document_generation( Format, xml(Attributes, Document) ) --> - document_generation_body( Attributes, Format, Document ). - - document_generation_body( [], Format, Document ) --> - generation( Document, "", Format, [], _Format1 ). - document_generation_body( Attributes, Format, Document ) --> - { Attributes = [_|_], - xml_declaration_attributes_valid( Attributes ) - }, - "", - indent( true, [] ), - generation( Document, "", Format0, [], _Format1 ). - - generation( [], _Prefix, Format, _Indent, Format ) --> []. - generation( [Term|Terms], Prefix, Format0, Indent, Format ) --> - generation( Term, Prefix, Format0, Indent, Format1 ), - generation( Terms, Prefix, Format1, Indent, Format ). - generation( doctype(Name, External), _Prefix, Format, [], Format ) --> - "". - generation( instructions(Target,Process), _Prefix, Format, Indent, Format ) --> - indent( Format, Indent ), - "". - generation( pcdata(Chars), _Prefix, Format0, _Indent, Format1 ) --> - pcdata_generation( Chars ), - {pcdata_format( Chars, Format0, Format1 )}. - generation( comment( Comment ), _Prefix, Format, Indent, Format ) --> - indent( Format, Indent ), - "". - generation( namespace(URI, Prefix, element(Name, Atts, Content)), - _Prefix0, Format, Indent, Format ) --> - indent( Format, Indent ), - "<", generated_prefixed_name( Prefix, Name ), - generated_prefixed_attributes( Prefix, URI, Atts, Format, Format1 ), - generated_content( Content, Format1, Indent, Prefix, Name ). - generation( element(Name, Atts, Content), Prefix, Format, Indent, Format ) --> - indent( Format, Indent ), - "<", generated_prefixed_name( Prefix, Name ), - generated_attributes( Atts, Format, Format1 ), - generated_content( Content, Format1, Indent, Prefix, Name ). - generation( cdata(CData), _Prefix, Format, Indent, Format ) --> - indent( Format, Indent ), - "". - - generated_attributes( [], Format, Format ) --> []. - generated_attributes( [Name=Value|Attributes], Format0, Format ) --> - {( Name == 'xml:space', - Value="preserve" -> - Format1 = false - ; otherwise -> - Format1 = Format0 - )}, - " ", - generated_name( Name ), - "=""", - quoted_string( Value ), - """", - generated_attributes( Attributes, Format1, Format ). - - generated_prefixed_name( [], Name ) --> - generated_name( Name ). - generated_prefixed_name( Prefix, Name ) --> - {Prefix = [_|_]}, - chars( Prefix ), ":", - generated_name( Name ). - - generated_content( [], _Format, _Indent, _Prefix, _Namespace ) --> - " />". % Leave an extra space for XHTML output. - generated_content( [H|T], Format, Indent, Prefix, Namespace ) --> - ">", - generation( H, Prefix, Format, [0' |Indent], Format1 ), - generation( T, Prefix, Format1, [0' |Indent], Format2 ), - indent( Format2, Indent ), - "". - - generated_prefixed_attributes( [_|_Prefix], _URI, Atts, Format0, Format ) --> - generated_attributes( Atts, Format0, Format ). - generated_prefixed_attributes( [], URI, Atts, Format0, Format ) --> - {atom_codes( URI, Namespace ), - findall( Attr, (member(Attr, Atts), \+ Attr=(xmlns=_Val)), Atts1 ) - }, - generated_attributes( [xmlns=Namespace|Atts1], Format0, Format ). - - generated_name( Name, Plus, Minus ) :- - atom_codes( Name, Chars ), - append( Chars, Minus, Plus ). - - generated_external_id( local ) --> "". - generated_external_id( local(Literals) ) --> " [", - generated_doctype_literals( Literals ), " - ]". - generated_external_id( system(URL) ) --> - " SYSTEM """, - chars( URL ), - """". - generated_external_id( system(URL,Literals) ) --> - " SYSTEM """, - chars( URL ), - """ [", - generated_doctype_literals( Literals ), " - ]". - generated_external_id( public(URN,URL) ) --> - " PUBLIC """, - chars( URN ), - """ """, - chars( URL ), - """". - generated_external_id( public(URN,URL,Literals) ) --> - " PUBLIC """, - chars( URN ), - """ """, - chars( URL ), - """ [", - generated_doctype_literals( Literals ), " - ]". - - generated_doctype_literals( [] ) --> "". - generated_doctype_literals( [dtd_literal(String)|Literals] ) --> " - ", - generated_doctype_literals( Literals ). - - /* quoted_string( +Chars ) is a DCG representing Chars, a list of character - * codes, as a legal XML attribute string. Any leading or trailing layout - * characters are removed. &, " and < characters are replaced by &, " - * and < respectively, . - */ - quoted_string( Raw, Plus, Minus ) :- - quoted_string1( Raw, NoLeadingLayouts ), - quoted_string2( NoLeadingLayouts, Layout, Layout, Plus, Minus ). - - quoted_string1( [], [] ). - quoted_string1( [Char|Chars], NoLeadingLayouts ) :- - ( Char > 32 -> - NoLeadingLayouts = [Char|Chars] - ; otherwise -> - quoted_string1( Chars, NoLeadingLayouts ) - ). - - quoted_string2( [], _LayoutPlus, _LayoutMinus, List, List ). - quoted_string2( [Char|Chars], LayoutPlus, LayoutMinus, Plus, Minus ) :- - ( Char =< " " -> - Plus = Plus1, - LayoutMinus = [Char|LayoutMinus1], - LayoutPlus = LayoutPlus1 - ; Char =< 127 -> - Plus = LayoutPlus, - pcdata_7bit( Char, LayoutMinus, Plus1 ), - LayoutPlus1 = LayoutMinus1 - ; legal_xml_unicode( Char ) -> - Plus = LayoutPlus, - number_codes( Char, Codes ), - pcdata_8bits_plus( Codes, LayoutMinus, Plus1 ), - LayoutPlus1 = LayoutMinus1 - ; otherwise -> - LayoutPlus = LayoutPlus1, - LayoutMinus = LayoutMinus1, - Plus = Plus1 - ), - quoted_string2( Chars, LayoutPlus1, LayoutMinus1, Plus1, Minus ). - - indent( false, _Indent ) --> []. - indent( true, Indent ) --> - " - ", chars( Indent ). - - /* pcdata_generation( +Chars ) is a DCG representing Chars, a list of character - * codes as legal XML "Parsed character data" (PCDATA) string. Any codes - * which cannot be represented by a 7-bit character are replaced by their - * decimal numeric character entity e.g. code 160 (non-breaking space) is - * represented as  . Any character codes disallowed by the XML - * specification are not encoded. - */ - pcdata_generation( [], Plus, Plus ). - pcdata_generation( [Char|Chars], Plus, Minus ) :- - ( Char =< 127 -> - pcdata_7bit( Char, Plus, Mid ) - ; legal_xml_unicode( Char ) -> - number_codes( Char, Codes ), - pcdata_8bits_plus( Codes, Plus, Mid ) - ; otherwise -> - Plus = Mid - ), - pcdata_generation( Chars, Mid, Minus ). - - /* pcdata_7bit(+Char) represents the ascii character set in its - * simplest format, using the character entities & " < and > - * which are common to both XML and HTML. The numeric entity ' is used in - * place of ', because browsers don't recognize it in HTML. - */ - :- private(pcdata_7bit//1). - :- mode(pcdata_7bit(?nonvar), zero_or_one). - :- info(pcdata_7bit//1, [ - comment is 'Represents the ascii character set in its simplest format, using the character entities & " < and > which are common to both XML and HTML. The numeric entity ' is used in place of ', because browsers don''t recognize it in HTML.', - argnames is ['Char']]). - - pcdata_7bit( 0 ) --> "". - pcdata_7bit( 1 ) --> "". - pcdata_7bit( 2 ) --> "". - pcdata_7bit( 3 ) --> "". - pcdata_7bit( 4 ) --> "". - pcdata_7bit( 5 ) --> "". - pcdata_7bit( 6 ) --> "". - pcdata_7bit( 7 ) --> "". - pcdata_7bit( 8 ) --> "". - pcdata_7bit( 9 ) --> [9]. - pcdata_7bit( 10 ) --> [10]. - pcdata_7bit( 11 ) --> "". - pcdata_7bit( 12 ) --> "". - pcdata_7bit( 13 ) --> [13]. - pcdata_7bit( 14 ) --> "". - pcdata_7bit( 15 ) --> "". - pcdata_7bit( 16 ) --> "". - pcdata_7bit( 17 ) --> "". - pcdata_7bit( 18 ) --> "". - pcdata_7bit( 19 ) --> "". - pcdata_7bit( 20 ) --> "". - pcdata_7bit( 21 ) --> "". - pcdata_7bit( 22 ) --> "". - pcdata_7bit( 23 ) --> "". - pcdata_7bit( 24 ) --> "". - pcdata_7bit( 25 ) --> "". - pcdata_7bit( 26 ) --> "". - pcdata_7bit( 27 ) --> "". - pcdata_7bit( 28 ) --> "". - pcdata_7bit( 29 ) --> "". - pcdata_7bit( 30 ) --> "". - pcdata_7bit( 31 ) --> "". - pcdata_7bit( 32 ) --> " ". - pcdata_7bit( 33 ) --> "!". - pcdata_7bit( 34 ) --> """. - pcdata_7bit( 35 ) --> "#". - pcdata_7bit( 36 ) --> "$". - pcdata_7bit( 37 ) --> "%". - pcdata_7bit( 38 ) --> "&". - pcdata_7bit( 39 ) --> "'". - pcdata_7bit( 40 ) --> "(". - pcdata_7bit( 41 ) --> ")". - pcdata_7bit( 42 ) --> "*". - pcdata_7bit( 43 ) --> "+". - pcdata_7bit( 44 ) --> ",". - pcdata_7bit( 45 ) --> "-". - pcdata_7bit( 46 ) --> ".". - pcdata_7bit( 47 ) --> "/". - pcdata_7bit( 48 ) --> "0". - pcdata_7bit( 49 ) --> "1". - pcdata_7bit( 50 ) --> "2". - pcdata_7bit( 51 ) --> "3". - pcdata_7bit( 52 ) --> "4". - pcdata_7bit( 53 ) --> "5". - pcdata_7bit( 54 ) --> "6". - pcdata_7bit( 55 ) --> "7". - pcdata_7bit( 56 ) --> "8". - pcdata_7bit( 57 ) --> "9". - pcdata_7bit( 58 ) --> ":". - pcdata_7bit( 59 ) --> ";". - pcdata_7bit( 60 ) --> "<". - pcdata_7bit( 61 ) --> "=". - pcdata_7bit( 62 ) --> ">". - pcdata_7bit( 63 ) --> "?". - pcdata_7bit( 64 ) --> "@". - pcdata_7bit( 65 ) --> "A". - pcdata_7bit( 66 ) --> "B". - pcdata_7bit( 67 ) --> "C". - pcdata_7bit( 68 ) --> "D". - pcdata_7bit( 69 ) --> "E". - pcdata_7bit( 70 ) --> "F". - pcdata_7bit( 71 ) --> "G". - pcdata_7bit( 72 ) --> "H". - pcdata_7bit( 73 ) --> "I". - pcdata_7bit( 74 ) --> "J". - pcdata_7bit( 75 ) --> "K". - pcdata_7bit( 76 ) --> "L". - pcdata_7bit( 77 ) --> "M". - pcdata_7bit( 78 ) --> "N". - pcdata_7bit( 79 ) --> "O". - pcdata_7bit( 80 ) --> "P". - pcdata_7bit( 81 ) --> "Q". - pcdata_7bit( 82 ) --> "R". - pcdata_7bit( 83 ) --> "S". - pcdata_7bit( 84 ) --> "T". - pcdata_7bit( 85 ) --> "U". - pcdata_7bit( 86 ) --> "V". - pcdata_7bit( 87 ) --> "W". - pcdata_7bit( 88 ) --> "X". - pcdata_7bit( 89 ) --> "Y". - pcdata_7bit( 90 ) --> "Z". - pcdata_7bit( 91 ) --> "[". - pcdata_7bit( 92 ) --> [92]. - pcdata_7bit( 93 ) --> "]". - pcdata_7bit( 94 ) --> "^". - pcdata_7bit( 95 ) --> "_". - pcdata_7bit( 96 ) --> "`". - pcdata_7bit( 97 ) --> "a". - pcdata_7bit( 98 ) --> "b". - pcdata_7bit( 99 ) --> "c". - pcdata_7bit( 100 ) --> "d". - pcdata_7bit( 101 ) --> "e". - pcdata_7bit( 102 ) --> "f". - pcdata_7bit( 103 ) --> "g". - pcdata_7bit( 104 ) --> "h". - pcdata_7bit( 105 ) --> "i". - pcdata_7bit( 106 ) --> "j". - pcdata_7bit( 107 ) --> "k". - pcdata_7bit( 108 ) --> "l". - pcdata_7bit( 109 ) --> "m". - pcdata_7bit( 110 ) --> "n". - pcdata_7bit( 111 ) --> "o". - pcdata_7bit( 112 ) --> "p". - pcdata_7bit( 113 ) --> "q". - pcdata_7bit( 114 ) --> "r". - pcdata_7bit( 115 ) --> "s". - pcdata_7bit( 116 ) --> "t". - pcdata_7bit( 117 ) --> "u". - pcdata_7bit( 118 ) --> "v". - pcdata_7bit( 119 ) --> "w". - pcdata_7bit( 120 ) --> "x". - pcdata_7bit( 121 ) --> "y". - pcdata_7bit( 122 ) --> "z". - pcdata_7bit( 123 ) --> "{". - pcdata_7bit( 124 ) --> "|". - pcdata_7bit( 125 ) --> "}". - pcdata_7bit( 126 ) --> "~". - pcdata_7bit( 127 ) --> "". - - pcdata_8bits_plus( Codes ) --> - "&#", chars( Codes ), ";". - - /* pcdata_format( +Chars, +Format0, ?Format1 ) holds when Format0 and Format1 - * are the statuses of XML formatting before and after Chars - which may be - * null. - */ - :- private(pcdata_format/3). - :- mode(pcdata_format(+nonvar, +nonvar, ?nonvar), zero_or_one). - :- info(pcdata_format/3, [ - comment is 'Holds when Format0 and Format1 are the statuses of XML formatting before and after Chars - which may be null.', - argnames is ['Chars', 'Format0', 'Format1']]). - - pcdata_format( [], Format, Format ). - pcdata_format( [_Char|_Chars], _Format, false ). - - /* cdata_generation( +Chars ) is a DCG representing Chars, a list of character - * codes as a legal XML CDATA string. Any character codes disallowed by the XML - * specification are not encoded. - */ - :- private(cdata_generation//1). - :- mode(cdata_generation(+list), zero_or_one). - :- info(cdata_generation//1, [ - comment is 'Holds when Format0 and Format1 are the statuses of XML formatting before and after Chars - which may be null.', - argnames is ['Chars']]). - - cdata_generation( [] ) --> "". - cdata_generation( [Char|Chars] ) --> - ( {legal_xml_unicode( Char )}, !, [Char] - ; "" - ), - cdata_generation( Chars ). - - legal_xml_unicode( 9 ). - legal_xml_unicode( 10 ). - legal_xml_unicode( 13 ). - legal_xml_unicode( Code ) :- - Code >= 32, - Code =< 55295. - legal_xml_unicode( Code ) :- - Code >= 57344, - Code =< 65533. - legal_xml_unicode( Code ) :- - Code >= 65536, - Code =< 1114111. - - otherwise. - - /* For reference, this is a comprehensive recognizer for namechar, based on - * the definition of in http://www.w3.org/TR/2000/REC-xml-20001006 . - - namechar --> - ( letter - ; unicode_digit - ; "." - ; "-" - ; "_" - ; ":" - ; combiningchar - ; extender - ). - - letter --> (basechar ; ideographic). - - basechar --> - ( range( 16'0041, 16'005A ) - ; range( 16'0061, 16'007A ) - ; range( 16'00C0, 16'00D6 ) - ; range( 16'00D8, 16'00F6 ) - ; range( 16'00F8, 16'00FF ) - ; range( 16'0100, 16'0131 ) - ; range( 16'0134, 16'013E ) - ; range( 16'0141, 16'0148 ) - ; range( 16'014A, 16'017E ) - ; range( 16'0180, 16'01C3 ) - ; range( 16'01CD, 16'01F0 ) - ; range( 16'01F4, 16'01F5 ) - ; range( 16'01FA, 16'0217 ) - ; range( 16'0250, 16'02A8 ) - ; range( 16'02BB, 16'02C1 ) - ; [16'0386] - ; range( 16'0388, 16'038A ) - ; [16'038C] - ; range( 16'038E, 16'03A1 ) - ; range( 16'03A3, 16'03CE ) - ; range( 16'03D0, 16'03D6 ) - ; [16'03DA] - ; [16'03DC] - ; [16'03DE] - ; [16'03E0] - ; range( 16'03E2, 16'03F3 ) - ; range( 16'0401, 16'040C ) - ; range( 16'040E, 16'044F ) - ; range( 16'0451, 16'045C ) - ; range( 16'045E, 16'0481 ) - ; range( 16'0490, 16'04C4 ) - ; range( 16'04C7, 16'04C8 ) - ; range( 16'04CB, 16'04CC ) - ; range( 16'04D0, 16'04EB ) - ; range( 16'04EE, 16'04F5 ) - ; range( 16'04F8, 16'04F9 ) - ; range( 16'0531, 16'0556 ) - ; [16'0559] - ; range( 16'0561, 16'0586 ) - ; range( 16'05D0, 16'05EA ) - ; range( 16'05F0, 16'05F2 ) - ; range( 16'0621, 16'063A ) - ; range( 16'0641, 16'064A ) - ; range( 16'0671, 16'06B7 ) - ; range( 16'06BA, 16'06BE ) - ; range( 16'06C0, 16'06CE ) - ; range( 16'06D0, 16'06D3 ) - ; [16'06D5] - ; range( 16'06E5, 16'06E6 ) - ; range( 16'0905, 16'0939 ) - ; [16'093D] - ; range( 16'0958, 16'0961 ) - ; range( 16'0985, 16'098C ) - ; range( 16'098F, 16'0990 ) - ; range( 16'0993, 16'09A8 ) - ; range( 16'09AA, 16'09B0 ) - ; [16'09B2] - ; range( 16'09B6, 16'09B9 ) - ; range( 16'09DC, 16'09DD ) - ; range( 16'09DF, 16'09E1 ) - ; range( 16'09F0, 16'09F1 ) - ; range( 16'0A05, 16'0A0A ) - ; range( 16'0A0F, 16'0A10 ) - ; range( 16'0A13, 16'0A28 ) - ; range( 16'0A2A, 16'0A30 ) - ; range( 16'0A32, 16'0A33 ) - ; range( 16'0A35, 16'0A36 ) - ; range( 16'0A38, 16'0A39 ) - ; range( 16'0A59, 16'0A5C ) - ; [16'0A5E] - ; range( 16'0A72, 16'0A74 ) - ; range( 16'0A85, 16'0A8B ) - ; [16'0A8D] - ; range( 16'0A8F, 16'0A91 ) - ; range( 16'0A93, 16'0AA8 ) - ; range( 16'0AAA, 16'0AB0 ) - ; range( 16'0AB2, 16'0AB3 ) - ; range( 16'0AB5, 16'0AB9 ) - ; [16'0ABD] - ; [16'0AE0] - ; range( 16'0B05, 16'0B0C ) - ; range( 16'0B0F, 16'0B10 ) - ; range( 16'0B13, 16'0B28 ) - ; range( 16'0B2A, 16'0B30 ) - ; range( 16'0B32, 16'0B33 ) - ; range( 16'0B36, 16'0B39 ) - ; [16'0B3D] - ; range( 16'0B5C, 16'0B5D ) - ; range( 16'0B5F, 16'0B61 ) - ; range( 16'0B85, 16'0B8A ) - ; range( 16'0B8E, 16'0B90 ) - ; range( 16'0B92, 16'0B95 ) - ; range( 16'0B99, 16'0B9A ) - ; [16'0B9C] - ; range( 16'0B9E, 16'0B9F ) - ; range( 16'0BA3, 16'0BA4 ) - ; range( 16'0BA8, 16'0BAA ) - ; range( 16'0BAE, 16'0BB5 ) - ; range( 16'0BB7, 16'0BB9 ) - ; range( 16'0C05, 16'0C0C ) - ; range( 16'0C0E, 16'0C10 ) - ; range( 16'0C12, 16'0C28 ) - ; range( 16'0C2A, 16'0C33 ) - ; range( 16'0C35, 16'0C39 ) - ; range( 16'0C60, 16'0C61 ) - ; range( 16'0C85, 16'0C8C ) - ; range( 16'0C8E, 16'0C90 ) - ; range( 16'0C92, 16'0CA8 ) - ; range( 16'0CAA, 16'0CB3 ) - ; range( 16'0CB5, 16'0CB9 ) - ; [16'0CDE] - ; range( 16'0CE0, 16'0CE1 ) - ; range( 16'0D05, 16'0D0C ) - ; range( 16'0D0E, 16'0D10 ) - ; range( 16'0D12, 16'0D28 ) - ; range( 16'0D2A, 16'0D39 ) - ; range( 16'0D60, 16'0D61 ) - ; range( 16'0E01, 16'0E2E ) - ; [16'0E30] - ; range( 16'0E32, 16'0E33 ) - ; range( 16'0E40, 16'0E45 ) - ; range( 16'0E81, 16'0E82 ) - ; [16'0E84] - ; range( 16'0E87, 16'0E88 ) - ; [16'0E8A] - ; [16'0E8D] - ; range( 16'0E94, 16'0E97 ) - ; range( 16'0E99, 16'0E9F ) - ; range( 16'0EA1, 16'0EA3 ) - ; [16'0EA5] - ; [16'0EA7] - ; range( 16'0EAA, 16'0EAB ) - ; range( 16'0EAD, 16'0EAE ) - ; [16'0EB0] - ; range( 16'0EB2, 16'0EB3 ) - ; [16'0EBD] - ; range( 16'0EC0, 16'0EC4 ) - ; range( 16'0F40, 16'0F47 ) - ; range( 16'0F49, 16'0F69 ) - ; range( 16'10A0, 16'10C5 ) - ; range( 16'10D0, 16'10F6 ) - ; [16'1100] - ; range( 16'1102, 16'1103 ) - ; range( 16'1105, 16'1107 ) - ; [16'1109] - ; range( 16'110B, 16'110C ) - ; range( 16'110E, 16'1112 ) - ; [16'113C] - ; [16'113E] - ; [16'1140] - ; [16'114C] - ; [16'114E] - ; [16'1150] - ; range( 16'1154, 16'1155 ) - ; [16'1159] - ; range( 16'115F, 16'1161 ) - ; [16'1163] - ; [16'1165] - ; [16'1167] - ; [16'1169] - ; range( 16'116D, 16'116E ) - ; range( 16'1172, 16'1173 ) - ; [16'1175] - ; [16'119E] - ; [16'11A8] - ; [16'11AB] - ; range( 16'11AE, 16'11AF ) - ; range( 16'11B7, 16'11B8 ) - ; [16'11BA] - ; range( 16'11BC, 16'11C2 ) - ; [16'11EB] - ; [16'11F0] - ; [16'11F9] - ; range( 16'1E00, 16'1E9B ) - ; range( 16'1EA0, 16'1EF9 ) - ; range( 16'1F00, 16'1F15 ) - ; range( 16'1F18, 16'1F1D ) - ; range( 16'1F20, 16'1F45 ) - ; range( 16'1F48, 16'1F4D ) - ; range( 16'1F50, 16'1F57 ) - ; [16'1F59] - ; [16'1F5B] - ; [16'1F5D] - ; range( 16'1F5F, 16'1F7D ) - ; range( 16'1F80, 16'1FB4 ) - ; range( 16'1FB6, 16'1FBC ) - ; [16'1FBE] - ; range( 16'1FC2, 16'1FC4 ) - ; range( 16'1FC6, 16'1FCC ) - ; range( 16'1FD0, 16'1FD3 ) - ; range( 16'1FD6, 16'1FDB ) - ; range( 16'1FE0, 16'1FEC ) - ; range( 16'1FF2, 16'1FF4 ) - ; range( 16'1FF6, 16'1FFC ) - ; [16'2126] - ; range( 16'212A, 16'212B ) - ; [16'212E] - ; range( 16'2180, 16'2182 ) - ; range( 16'3041, 16'3094 ) - ; range( 16'30A1, 16'30FA ) - ; range( 16'3105, 16'312C ) - ; range( 16'AC00, 16'D7A3 ) - ). - ideographic --> - ( range( 16'4E00, 16'9FA5 ) - ; [16'3007] - ; range( 16'3021, 16'3029 ) - ). - combiningchar --> - ( range( 16'0300, 16'0345 ) - ; range( 16'0360, 16'0361 ) - ; range( 16'0483, 16'0486 ) - ; range( 16'0591, 16'05A1 ) - ; range( 16'05A3, 16'05B9 ) - ; range( 16'05BB, 16'05BD ) - ; [16'05BF] - ; range( 16'05C1, 16'05C2 ) - ; [16'05C4] - ; range( 16'064B, 16'0652 ) - ; [16'0670] - ; range( 16'06D6, 16'06DC ) - ; range( 16'06DD, 16'06DF ) - ; range( 16'06E0, 16'06E4 ) - ; range( 16'06E7, 16'06E8 ) - ; range( 16'06EA, 16'06ED ) - ; range( 16'0901, 16'0903 ) - ; [16'093C] - ; range( 16'093E, 16'094C ) - ; [16'094D] - ; range( 16'0951, 16'0954 ) - ; range( 16'0962, 16'0963 ) - ; range( 16'0981, 16'0983 ) - ; [16'09BC] - ; [16'09BE] - ; [16'09BF] - ; range( 16'09C0, 16'09C4 ) - ; range( 16'09C7, 16'09C8 ) - ; range( 16'09CB, 16'09CD ) - ; [16'09D7] - ; range( 16'09E2, 16'09E3 ) - ; [16'0A02] - ; [16'0A3C] - ; [16'0A3E] - ; [16'0A3F] - ; range( 16'0A40, 16'0A42 ) - ; range( 16'0A47, 16'0A48 ) - ; range( 16'0A4B, 16'0A4D ) - ; range( 16'0A70, 16'0A71 ) - ; range( 16'0A81, 16'0A83 ) - ; [16'0ABC] - ; range( 16'0ABE, 16'0AC5 ) - ; range( 16'0AC7, 16'0AC9 ) - ; range( 16'0ACB, 16'0ACD ) - ; range( 16'0B01, 16'0B03 ) - ; [16'0B3C] - ; range( 16'0B3E, 16'0B43 ) - ; range( 16'0B47, 16'0B48 ) - ; range( 16'0B4B, 16'0B4D ) - ; range( 16'0B56, 16'0B57 ) - ; range( 16'0B82, 16'0B83 ) - ; range( 16'0BBE, 16'0BC2 ) - ; range( 16'0BC6, 16'0BC8 ) - ; range( 16'0BCA, 16'0BCD ) - ; [16'0BD7] - ; range( 16'0C01, 16'0C03 ) - ; range( 16'0C3E, 16'0C44 ) - ; range( 16'0C46, 16'0C48 ) - ; range( 16'0C4A, 16'0C4D ) - ; range( 16'0C55, 16'0C56 ) - ; range( 16'0C82, 16'0C83 ) - ; range( 16'0CBE, 16'0CC4 ) - ; range( 16'0CC6, 16'0CC8 ) - ; range( 16'0CCA, 16'0CCD ) - ; range( 16'0CD5, 16'0CD6 ) - ; range( 16'0D02, 16'0D03 ) - ; range( 16'0D3E, 16'0D43 ) - ; range( 16'0D46, 16'0D48 ) - ; range( 16'0D4A, 16'0D4D ) - ; [16'0D57] - ; [16'0E31] - ; range( 16'0E34, 16'0E3A ) - ; range( 16'0E47, 16'0E4E ) - ; [16'0EB1] - ; range( 16'0EB4, 16'0EB9 ) - ; range( 16'0EBB, 16'0EBC ) - ; range( 16'0EC8, 16'0ECD ) - ; range( 16'0F18, 16'0F19 ) - ; [16'0F35] - ; [16'0F37] - ; [16'0F39] - ; [16'0F3E] - ; [16'0F3F] - ; range( 16'0F71, 16'0F84 ) - ; range( 16'0F86, 16'0F8B ) - ; range( 16'0F90, 16'0F95 ) - ; [16'0F97] - ; range( 16'0F99, 16'0FAD ) - ; range( 16'0FB1, 16'0FB7 ) - ; [16'0FB9] - ; range( 16'20D0, 16'20DC ) - ; [16'20E1] - ; range( 16'302A, 16'302F ) - ; [16'3099] - ; [16'309A] - ). - - unicode_digit --> - ( range( 16'0030, 16'0039 ) - ; range( 16'0660, 16'0669 ) - ; range( 16'06F0, 16'06F9 ) - ; range( 16'0966, 16'096F ) - ; range( 16'09E6, 16'09EF ) - ; range( 16'0A66, 16'0A6F ) - ; range( 16'0AE6, 16'0AEF ) - ; range( 16'0B66, 16'0B6F ) - ; range( 16'0BE7, 16'0BEF ) - ; range( 16'0C66, 16'0C6F ) - ; range( 16'0CE6, 16'0CEF ) - ; range( 16'0D66, 16'0D6F ) - ; range( 16'0E50, 16'0E59 ) - ; range( 16'0ED0, 16'0ED9 ) - ; range( 16'0F20, 16'0F29 ) - ). - - extender --> - ( [16'00B7] - ; [16'02D0] - ; [16'02D1] - ; [16'0387] - ; [16'0640] - ; [16'0E46] - ; [16'0EC6] - ; [16'3005] - ; range( 16'3031, 16'3035 ) - ; range( 16'309D, 16'309E ) - ; range( 16'30FC, 16'30FE ) - ). - - range( Low, High ) --> - [Char], - {Char >= Low, Char =< High}. -*/ - -:- end_object. diff --git a/Logtalk/examples/NOTES.txt b/Logtalk/examples/NOTES.txt deleted file mode 100644 index efb61b325..000000000 --- a/Logtalk/examples/NOTES.txt +++ /dev/null @@ -1,209 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This folder contains several examples of Logtalk programs. A brief -description of each example is included below. - -Each example folder contains a "NOTES.txt" file and a loader helper -file that may be used to load all the example entities. In addition, -most examples contain a "SCRIPT.txt" file with instructions on how to -load the example and sample queries for your to try. - -Most of these examples need objects, protocols, and categories that -are defined in the Logtalk standard library or in other examples. See -the "NOTES.txt" files inside the library folder, plus the "NOTES.txt" -and "SCRIPT.txt" files inside each example folder. - -Some examples may redefine objects already loaded from other examples. -You may want to restart Logtalk after trying each example. - -Some of the examples have been adopted from public available Prolog -code or from known Prolog text books and are copyrighted by the respective -authors. - -These are programming examples, meaning that you should study the source -files to fully understand them. However, note that some examples purpose -is to illustrate general principles rather than being adequate, efficient -solutions for deployment code. - -All examples are formatted using four spaces tabs. - -By default, compiling an example generates a XML documenting file for -each compiled entity (object, category, or protocol). See the "xml" -folder for instructions on how to browse the XML files for on-line -reading or how to convert the files to a print-ready format such as PDF. - - -Here is a short description of each included example: - -aliases - example of using the alias/3 predicate directive to provide - alternative names to inherited predicates in order to improve - readability or to solve multi-inheritance conflicts - -assignvars - example of using assignable variables in the context of parametric - objects in order to represent object state - -benchmarks - simple benchmarks for helping measuring performance of Logtalk - message sending between Prolog compilers and for comparing - performance of message sending calls with predicate calls in - plain Prolog - -birds - bird identification expert system - (example adopted from the Adventure in Prolog Amzi! book) - -bottles - 99 bottles of beer on the wall! Sing along! - -bricks - example of representation and handling of relations using events; - illustrates how to use events to avoid breaking object encapsulation - -classvars - example of implementation of class variables - (as found in Smalltalk; i.e. shared instance variables) - -dcgs - examples of using DCG rules inside objects and categories - -diamonds - examples of problems and solutions for the "diamond problem" - (multi-inheritance conflicts and ambiguities) - -dynpred - example of using some of the built-in database handling methods - in order to implement dynamic object state - -encodings - very simple example of using the new, experimental encoding/1 - directive (requires Logtalk to be run with the SWI-Prolog compiler) - -engines - example of category composition (importation of categories by - other categories) using car engines - -errors - example showing the Logtalk compiler warning and error reporting - for common programming errors - -hello_world - the unavoidable "hello world" programming example - -hooks - simple example of using compiler hook objects and predicates - -inheritance - examples of public, protected, and private inheritance using both - prototypes and classes/instances - -instmethods - example of instance defined methods; also illustrates the use of - "super calls" to call overridden method definitions - -lo - examples adopted from the Francis G. McCabe L&O system - -logic - example of a translator of first-order predicate logic propositions - to conjunctive normal form and to clausal form - -lpa - examples adopted from the LPA Prolog++ system - -metapredicates - example of using meta-predicates in Logtalk objects - -metainterpreters - some examples of simple meta-interpreters defined as categories - that can be imported by "database" objects - -mi - simple multi-inheritance examples - -miscellaneous - unsorted examples - -modules - simple example of compiling Prolog module files as objects - -msglog - example of using events and monitors for recording, replaying, - and printing user messages - -operators - example of using operators local to objects and categories - -parametric - simple example of parametric objects - -poem - examples adopted from the Ben Staveley-Taylor POEM system - -points - example adopted from SICStus Objects documentation; defines - a simple class hierarchy of points illustrating how to use - categories as object components - -polygons - example of representation and handling of relations using events - -profiling - examples of using of events and monitors to implement profilers - -proxies - example of using parametric object proxies for an efficient - representation of objects with read-only state - -puzzles - several examples of logical puzzles - -reflection - example of a simple class-based reflective system - -relations - objects implementing predicates for dealing with relations and - constrained relations between objects; used by other examples - -roots - objects, protocols, and categories needed by most of the other - examples; illustrates how you can define object creation and - abolishing methods, complete with initialization and termination - options - -searching - state-space searching framework - (example adopted from Ivan Bratko's "Prolog Programming for - Artificial Intelligence" book) - -shapes - simple geometric shapes implemented as both a prototype hierarchy - and a class hierarchy - -sicstus - examples adopted from SICStus Objects documentation - -symdiff - example of using parametric objects to implement symbolic - expression differentiation and simplification - -tabling - simple example of using tabling directives within objects - -testing - some examples of writing unit tests - -threads - several simple examples of multi-threading programming - (requires Logtalk to be run with either YAP or SWI-Prolog) - -viewpoints - example on how to implement property sharing and value sharing - with prototypes diff --git a/Logtalk/examples/aliases/NOTES.txt b/Logtalk/examples/aliases/NOTES.txt deleted file mode 100644 index d0761151c..000000000 --- a/Logtalk/examples/aliases/NOTES.txt +++ /dev/null @@ -1,13 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT -file. - -For a description of this example, please see the comments in the -aliases.lgt source file. diff --git a/Logtalk/examples/aliases/SCRIPT.txt b/Logtalk/examples/aliases/SCRIPT.txt deleted file mode 100644 index b2e1b2f19..000000000 --- a/Logtalk/examples/aliases/SCRIPT.txt +++ /dev/null @@ -1,84 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(aliases(loader)). -... - - -% check the object square(_) public protocol: - -| ?- square(_)::current_predicate(Predicate). - -Predicate = side/1 ; -Predicate = width/1 ; -Predicate = height/1 ; -Predicate = area/1 -yes - - -% test the side/1 alias: - -| ?- square(2)::side(Side). - -Side = 2 -yes - -| ?- square(2)::predicate_property(side(_), Property). - -Property = public ; -Property = static ; -Property = declared_in(rectangle(_G264, _G265)) ; -Property = defined_in(rectangle(_G297, _G298)) ; -Property = alias(width(_G182)) -yes - -| ?- square(2)::predicate_property(width(_), Property). - -Property = public ; -Property = static ; -Property = declared_in(rectangle(_G262, _G263)) ; -Property = defined_in(rectangle(_G293, _G294)) -yes - - -% check the object circle(_) public protocol: - -| ?- circle(_)::current_predicate(Predicate). - -Predicate = r/1 ; -Predicate = rx/1 ; -Predicate = ry/1 ; -Predicate = area/1 -yes - - -% test the r/1 alias: - -| ?- circle(3)::r(Radius). - -Radius = 3 -yes - -| ?- circle(3)::predicate_property(r(_), Property). - -Property = public ; -Property = static ; -Property = declared_in(ellipse(_G266, _G267)) ; -Property = defined_in(ellipse(_G299, _G300)) ; -Property = alias(rx(_G177)) -yes - -| ?- circle(3)::predicate_property(rx(_), Property). - -Property = public ; -Property = static ; -Property = declared_in(ellipse(_G261, _G262)) ; -Property = defined_in(ellipse(_G292, _G293)) -yes diff --git a/Logtalk/examples/aliases/aliases.lgt b/Logtalk/examples/aliases/aliases.lgt deleted file mode 100644 index ca721765d..000000000 --- a/Logtalk/examples/aliases/aliases.lgt +++ /dev/null @@ -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. diff --git a/Logtalk/examples/aliases/loader.lgt b/Logtalk/examples/aliases/loader.lgt deleted file mode 100644 index fcad6fff5..000000000 --- a/Logtalk/examples/aliases/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(aliases)). diff --git a/Logtalk/examples/assignvars/NOTES.txt b/Logtalk/examples/assignvars/NOTES.txt deleted file mode 100644 index d2cf92c58..000000000 --- a/Logtalk/examples/assignvars/NOTES.txt +++ /dev/null @@ -1,20 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This example illustrates the use of assignable variables and parametric -objects as alternative implementation to dynamic object predicates for -storing (backtracable) object state. For more information on assignable -variables please consult the URL: - - http://www.kprolog.com/en/logical_assignment/ - -The objects in this example make use of the library category "assignvars". -This category contains an adaptation of the pure logical subset implementation -of assignable variables by Nobukuni Kino, which can be found on the URL above. diff --git a/Logtalk/examples/assignvars/SCRIPT.txt b/Logtalk/examples/assignvars/SCRIPT.txt deleted file mode 100644 index 551dada6e..000000000 --- a/Logtalk/examples/assignvars/SCRIPT.txt +++ /dev/null @@ -1,69 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the "assignvars" category and the example: - -| ?- logtalk_load(assignvars(loader)). -... - - -% rectangle example: - -?- rectangle(2, 3, _)::(init, position(X0, Y0), move(3, 7), position(X1, Y1), move(2, 5), position(X2, Y2)). - -X0 = 0 -Y0 = 0 -X1 = 3 -Y1 = 7 -X2 = 2 -Y2 = 5 - -Yes - - -% finite state machine example: - -| ?- fsm(T, I, F), fsm(T, I, F)::recognise([0,1,1,2,1,2,0]). - -red-0-red -red-1-green -green-1-yellow -yellow-2-red -red-1-green -green-2-red -red-0-red - -T = [red-0-red, red-1-green, red-2-red, yellow-0-red, yellow-1-green, yellow-2-red, green-0-yellow, ... -... -yellow, ... -...] -I = red -F = [red] - -Yes - - -% finite state machine example: - -| ?- fsm(T, I, F), !, fsm(T, I, F)::recognise([0,1,1,2,1,2,1,0]). - -red-0-red -red-1-green -green-1-yellow -yellow-2-red -red-1-green -green-2-red -red-1-green -green-0-yellow -backtracking... -backtracking... -backtracking... -backtracking... -backtracking... -backtracking... -backtracking... -backtracking... - -No diff --git a/Logtalk/examples/assignvars/fsm3.lgt b/Logtalk/examples/assignvars/fsm3.lgt deleted file mode 100644 index 9d2131c54..000000000 --- a/Logtalk/examples/assignvars/fsm3.lgt +++ /dev/null @@ -1,63 +0,0 @@ - - -% fsm(Transitions, Initial, Final) -% -% fsm(-list, -nonvar, -list) - -fsm([red-0-red, red-1-green, red-2-red, % a simple finite state machine example - yellow-0-red, yellow-1-green, yellow-2-red, - green-0-yellow, green-1-yellow, green-2-red], - red, - [red]). - - -:- object(fsm(_Transitions, _Initial, _Final), - imports(private::assignvars)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2005/1/8, - comment is 'A simple implementation of finite-state machines using assignable variables and parametric objects. Adapted from a similar example by Nobukuni Kino.', - parnames is ['Transitions', 'Initial state', 'Final states']]). - - :- public(recognise/1). - :- mode(recognise(+list), zero_or_more). - :- info(recognise/1, - [comment is 'Recognise a list of events.', - argnames is ['Events']]). - - recognise(Events) :- - parameter(2, Initial), - ::assignable(Current, Initial), - recognise(Events, Current). - - recognise([], State) :- - ::State => Current, - final_state(Current). - recognise([Event| Events], State) :- - ::State => Current, - transition(Event, Current, Next), - (write(Current-Event-Next), nl - ; - write('backtracking...'), nl, fail), - ::State <= Next, - recognise(Events, State). - - transition(Event, Current, Next) :- - parameter(1, Transitions), - transition(Transitions, Event, Current, Next). - - transition([Current-Event-Next| _], Event, Current, Next). - transition([_| Transitions], Event, Current, Next):- - transition(Transitions, Event, Current, Next). - - final_state(State) :- - parameter(3, Final), - final_state(Final, State). - - final_state([State| _], State). - final_state([_| States], State) :- - final_state(States, State). - -:- end_object. diff --git a/Logtalk/examples/assignvars/loader.lgt b/Logtalk/examples/assignvars/loader.lgt deleted file mode 100644 index 27cc6b734..000000000 --- a/Logtalk/examples/assignvars/loader.lgt +++ /dev/null @@ -1,4 +0,0 @@ - -:- initialization(( - logtalk_load(library(assignvars), [reload(skip)]), % allow for static binding - logtalk_load([fsm3, rectangle3]))). diff --git a/Logtalk/examples/assignvars/rectangle3.lgt b/Logtalk/examples/assignvars/rectangle3.lgt deleted file mode 100644 index 5df721423..000000000 --- a/Logtalk/examples/assignvars/rectangle3.lgt +++ /dev/null @@ -1,52 +0,0 @@ - -:- object(rectangle(_Width, _Height, _Position), - imports(private::assignvars)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2005/1/8, - comment is 'A simple implementation of a geometric rectangle using assignable variables and parametric objects.', - parnames is ['Width', 'Height', 'Position']]). - - :- public(init/0). - :- mode(init, one). - :- info(init/0, - [comment is 'Initialize rectangle position.']). - - :- public(area/1). - :- mode(area(-integer), one). - :- info(area/1, - [comment is 'Rectangle area.', - argnames is ['Area']]). - - :- public(move/2). - :- mode(move(+integer, +integer), one). - :- info(move/2, [ - comment is 'Moves a rectangle to a new position.', - argnames is ['X', 'Y']]). - - :- public(position/2). - :- mode(position(?integer, ?integer), zero_or_one). - :- info(position/2, [ - comment is 'Rectangle current position.', - argnames is ['X', 'Y']]). - - init :- - parameter(3, Position), - ::assignable(Position, (0, 0)). - - area(Area) :- - parameter(1, Width), - parameter(2, Height), - Area is Width*Height. - - move(X, Y) :- - parameter(3, Position), - ::Position <= (X, Y). - - position(X, Y) :- - parameter(3, Position), - ::Position => (X, Y). - -:- end_object. diff --git a/Logtalk/examples/benchmarks/NOTES.txt b/Logtalk/examples/benchmarks/NOTES.txt deleted file mode 100644 index 5dff75d1c..000000000 --- a/Logtalk/examples/benchmarks/NOTES.txt +++ /dev/null @@ -1,83 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder provides simple benchmark tests for comparing Logtalk message -sending performance with direct predicates calls in plain Prolog. -These benchmarks may also be used for comparing Logtalk message sending -performance across Prolog compilers. - -This example is made of four loader files and five source files: - - loader_events.lgt - loads all source files with event support turned on - loader_no_events.lgt - loads all source files with event support turned off - loader_static_binding.lgt - loads all source files with event support turned off and using - static binding - loader.lgt - the same as the loader_static_binding.lgt file - - benchmarks.lgt - contains the benchmark goals and testing predicates - plain.lgt - contains a definition for a list length predicate and a predicate - for testing performance of the built-in predicates assertz/1 and - retract/1 - module.pl (not loaded by default; see below) - contains the same definition of a list length predicate - encapsulated in a module - objects.lgt - contains an object encapsulating the same definition of a list - length predicate, plus two descendant objects to simulate a small - hierarchy (used for testing calls to imported category predicates) - database.lgt - contains predicates for testing the performance of the built-in - database methods assertz/1 and retract/1 - category.lgt - contains a single predicate used when comparing performance of - calls to imported category predicates using direct calls and using - messages to "self" - -You may have noticed above that the benchmark predicates and the predicates -for plain Prolog testing are both encapsulated in Logtalk source files. The -Logtalk compiler just copies the plain Prolog code to the generated Prolog -files. The reason for using the .lgt extension for these files is simply to -make it possible to load all the example code using calls to the predicates -logtalk_load/1-2. - -By default, the benchmark tests on the SCRIPT file use a list of 20 elements -as an argument to the list length predicates. When dynamic binding is used, -increasing the list length leads to decreasing performance differences between -plain Prolog and Logtalk as the list length computation time far outweighs the -overhead of the message sending mechanism. Likewise, decreasing the list -length leads to increasing performance differences between plain Prolog and -Logtalk (up to the point you will be measuring the Logtalk message sending -mechanism overhead compared to plain Prolog predicate calls). In real-life -applications, only testing can give you a balanced view on the trade-offs -between plain Prolog performance and Logtalk programming features. - -By default, the loader files used to load the example code do not load the -module.pl file. Edit these files if your Prolog compiler supports a module -system and you want to run some comparative performance tests between plain -Prolog, Prolog modules, and Logtalk objects. Note that you may need to edit -the code on the module.pl file to make any necessary compatibility changes -for your Prolog compiler module system. For most Prolog module systems, the -performance of module calls is close or even identical to the performance of -plain Prolog calls when using imported predicates and implicit qualification. -When using explicit module qualification, performance can be significantly -worse. - -When static binding is used, messages to objects are, whenever possible, -translated to direct predicate calls. Thus performance should be about the -same as in plain Prolog predicate calls. However, due to the overhead of -three extra arguments per object predicate (used for passing the execution -context), the performance of Logtalk optimized calls might be slightly -worse than the equivalent plain Prolog predicate calls. diff --git a/Logtalk/examples/benchmarks/SCRIPT.txt b/Logtalk/examples/benchmarks/SCRIPT.txt deleted file mode 100644 index 8b1fdd90a..000000000 --- a/Logtalk/examples/benchmarks/SCRIPT.txt +++ /dev/null @@ -1,78 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example by choosing one of the loader files -% (you must quit and restart Logtalk for each testing scenario): - - -% run benchmarks with event support turned on: - -| ?- logtalk_load(benchmarks(loader_events)). -... - - -% run benchmarks with event support turned off: - -| ?- logtalk_load(benchmarks(loader_no_events)). -... - - -% run benchmarks with event support turned off and using static binding: - -| ?- logtalk_load(benchmarks(loader_static_binding)). -... - - -% list all the benchmark tests: - -| ?- benchmarks::benchmark(Id, Goal). - -Goal = my_length([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],_) -Id = s1 ? ; - -Goal = object::length([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],_) -Id = s2 ? ; - -Goal = leaf::obj_local -Id = c1 ? ; - -Goal = leaf::ctg_direct -Id = c2 ? ; - -Goal = leaf::ctg_self -Id = c3 ? ; - -Goal = create_object(xpto,[],[],[]),abolish_object(xpto) -Id = d1 ? ; - -Goal = plain_dyndb -Id = d2 ? ; - -Goal = database::this_dyndb -Id = d3 ? ; - -Goal = database::self_dyndb -Id = d4 ? ; - -Goal = database::obj_dyndb -Id = d5 - -yes - - -% run all the benchmark tests the default number of times: - -| ?- benchmarks::run. -... - - -% or run specific benchmark tests individually, for example: - - -| ?- benchmarks::run(s1, 1000000). -... diff --git a/Logtalk/examples/benchmarks/benchmark.lgt b/Logtalk/examples/benchmarks/benchmark.lgt deleted file mode 100644 index 7df4c9c0d..000000000 --- a/Logtalk/examples/benchmarks/benchmark.lgt +++ /dev/null @@ -1,122 +0,0 @@ - -% benchmark a goal using a default number of repetitions and printing some -% useful statistics - -benchmark(Goal) :- - N = 100000, - benchmark(Goal, N, Looptime, Goaltime, Average, Speed), - report(Goal, N, Looptime, Goaltime, Average, Speed). - - -benchmark(Goal, N) :- - benchmark(Goal, N, Looptime, Goaltime, Average, Speed), - report(Goal, N, Looptime, Goaltime, Average, Speed). - - -benchmark(Goal, N, Looptime, Goaltime, Average, Speed) :- - '$lgt_cpu_time'(Seconds1), % defined in the config files - do_benchmark(N, true), - '$lgt_cpu_time'(Seconds2), - Looptime is Seconds2 - Seconds1, - '$lgt_cpu_time'(Seconds3), - do_benchmark(N, Goal), - '$lgt_cpu_time'(Seconds4), - Goaltime is Seconds4 - Seconds3, - Average is (Goaltime - Looptime)/N, - Speed is 1.0/Average. - - -report(Id, Goal, N, Looptime, Goaltime, Average, Speed) :- - write(Id), write(': '), - report(Goal, N, Looptime, Goaltime, Average, Speed). - - -report(Goal, N, Looptime, Goaltime, Average, Speed) :- - writeq(Goal), nl, - write('Number of repetitions: '), write(N), nl, - write('Loop time: '), write(Looptime), nl, - write('Goal time: '), write(Goaltime), nl, - write('Average time per call: '), write(Average), nl, - write('Number of calls per second: '), write(Speed), nl, - nl. - - -% repeat a goal N times using a failure-driven loop to avoid the interference -% of Prolog compiler memory management mechanism (such as garbage collection) -% on the results - -do_benchmark(N, Goal) :- - repeat(N), % another option would be to use a between/3 built-in predicate - call(Goal), - fail. - -do_benchmark(_, _). - - -% some Prolog compilers define the predicate repeat/1 as a built-in predicate; -% if that's the case of the Prolog compiler you are using, then comment out -% the definition that follows - -repeat(_). - -repeat(N) :- - N > 1, - N2 is N - 1, - repeat(N2). - - -% generate a list containing the first N non-negative integers - -generate_list(N, List) :- - N >= 0, - generate_list(0, N, List). - - -generate_list(N, N, []) :- - !. - -generate_list(M, N, [M| Ms]) :- - M < N, - M2 is M + 1, - generate_list(M2, N, Ms). - - -% utility predicate for running all benchmark tests - -benchmarks :- - N = 100000, - benchmark_goal(Id, Goal), - benchmark(Goal, N, Looptime, Goaltime, Average, Speed), - report(Id, Goal, N, Looptime, Goaltime, Average, Speed), - fail. - -benchmarks. - - -% some benchmark tests for static code: - -benchmark_goal('S1', my_length(List, _)) :- - generate_list(30, List). - -benchmark_goal('S2', object::length(List, _)) :- - generate_list(30, List). - -benchmark_goal('S3', '$lgt_send_to_object_nv'(object, length(List, _), user)) :- - generate_list(30, List). - -benchmark_goal('S4', '$lgt_send_to_object_ne_nv'(object, length(List, _), user)) :- - generate_list(30, List). - - -% some benchmark tests for dynamic code: - -benchmark_goal('D1', (create_object(xpto, [], [], []), abolish_object(xpto))). - -benchmark_goal('D2', db_test_plain). - -benchmark_goal('D3', '$lgt_send_to_object_ne_nv'(database, db_test_this, user)). - -benchmark_goal('D4', '$lgt_send_to_object_ne_nv'(database, db_test_self, user)). - -benchmark_goal('D5', '$lgt_send_to_object_ne_nv'(database, db_test_obj, user)). - diff --git a/Logtalk/examples/benchmarks/benchmarks.lgt b/Logtalk/examples/benchmarks/benchmarks.lgt deleted file mode 100644 index d6fb6e950..000000000 --- a/Logtalk/examples/benchmarks/benchmarks.lgt +++ /dev/null @@ -1,162 +0,0 @@ - -:- object(benchmarks). - - :- info([ - version is 3.0, - author is 'Paulo Moura', - date is 2007/06/11, - comment is 'Benchmark utility predicates and standard set of benchmarks.']). - - :- public(run/0). - :- mode(run, one). - :- info(run/0, [ - comment is 'Runs all benchmarks the default number of times.']). - - :- public(run/1). - :- mode(run(+integer), one). - :- info(run/1, [ - comment is 'Runs all benchmarks the specified number of times.', - argnames is ['N']]). - - :- public(run/2). - :- mode(run(+atom, +integer), one). - :- info(run/2, [ - comment is 'Runs a specific benchmark the specified number of times.', - argnames is ['Id', 'N']]). - - :- public(benchmark/2). - :- mode(move(?atom, -callable), zero_or_more). - :- info(move/2, [ - comment is 'Table of benchmark identifiers and benchmark goals.', - argnames is ['Id', 'Goal']]). - - % run all benchmarks the default number of times: - run :- - run(100000). - - % run all benchmark tests N times: - run(N) :- - benchmark(Id, Goal), - run(Id, N, Looptime, Goaltime, Average, Speed), - report(Id, Goal, N, Looptime, Goaltime, Average, Speed), - fail. - run(_). - - % run a specific benchmark test: - run(Id, N) :- - benchmark(Id, Goal), - run(Id, N, Looptime, Goaltime, Average, Speed), - report(Id, Goal, N, Looptime, Goaltime, Average, Speed). - - run(Id, N, Looptime, Goaltime, Average, Speed) :- - {'$lgt_cpu_time'(Seconds1)}, % defined in the config files - do_benchmark(empty_loop, N), - {'$lgt_cpu_time'(Seconds2)}, - Looptime is Seconds2 - Seconds1, - {'$lgt_cpu_time'(Seconds3)}, - do_benchmark(Id, N), - {'$lgt_cpu_time'(Seconds4)}, - Goaltime is Seconds4 - Seconds3, - Average is (Goaltime - Looptime)/N, - Speed is 1.0/Average. - - report(Id, Goal, N, Looptime, Goaltime, Average, Speed) :- - write(Id), write(': '), - writeq(Goal), nl, - write('Number of repetitions: '), write(N), nl, - write('Loop time: '), write(Looptime), nl, - write('Goal time: '), write(Goaltime), nl, - write('Average time per call: '), write(Average), nl, - write('Number of calls per second: '), write(Speed), nl, - nl. - - % some benchmark tests for static code: - benchmark(s1, my_length(List, _)) :- - {generate_list(20, List)}. - benchmark(s2, object::length(List, _)) :- - {generate_list(20, List)}. - - % some benchmark tests for category predicate calls: - benchmark(c1, leaf::obj_local). - benchmark(c2, leaf::ctg_direct). - benchmark(c3, leaf::ctg_self). - - % some benchmark tests for dynamic code: - benchmark(d1, (create_object(xpto, [], [], []), abolish_object(xpto))). - benchmark(d2, plain_dyndb(_)). - benchmark(d3, database::this_dyndb(_)). - benchmark(d4, database::self_dyndb(_)). - benchmark(d5, database::obj_dyndb(_)). - - % repeat a goal N times without using call/1 and using a failure-driven loop to - % avoid the interference of Prolog compiler memory management mechanism (such as - % garbage collection) on the results - do_benchmark(empty_loop, N) :- - {my_repeat(N)}, - fail. - do_benchmark(empty_loop, _). - - do_benchmark(s1, N) :- - {generate_list(20, List)}, - {my_repeat(N)}, - {my_length(List, _)}, - fail. - do_benchmark(s1, _). - - do_benchmark(s2, N) :- - {generate_list(20, List)}, - {my_repeat(N)}, - object::length(List, _), - fail. - do_benchmark(s2, _). - - do_benchmark(c1, N) :- - {my_repeat(N)}, - leaf::obj_local, - fail. - do_benchmark(c1, _). - - do_benchmark(c2, N) :- - {my_repeat(N)}, - leaf::ctg_direct, - fail. - do_benchmark(c2, _). - - do_benchmark(c3, N) :- - {my_repeat(N)}, - leaf::ctg_self, - fail. - do_benchmark(c3, _). - - do_benchmark(d1, N) :- - {my_repeat(N)}, - create_object(xpto, [], [], []), - abolish_object(xpto), - fail. - do_benchmark(d1, _). - - do_benchmark(d2, N) :- - {my_repeat(N)}, - {plain_dyndb(N)}, - fail. - do_benchmark(d2, _). - - do_benchmark(d3, N) :- - {my_repeat(N)}, - database::this_dyndb(N), - fail. - do_benchmark(d3, _). - - do_benchmark(d4, N) :- - {my_repeat(N)}, - database::self_dyndb(N), - fail. - do_benchmark(d4, _). - - do_benchmark(d5, N) :- - {my_repeat(N)}, - database::obj_dyndb(N), - fail. - do_benchmark(d5, _). - -:- end_object. diff --git a/Logtalk/examples/benchmarks/category.lgt b/Logtalk/examples/benchmarks/category.lgt deleted file mode 100644 index 9557569e8..000000000 --- a/Logtalk/examples/benchmarks/category.lgt +++ /dev/null @@ -1,24 +0,0 @@ - -:- category(category). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2007/06/10, - comment is 'Defines a simple predicate for comparing performance of calls from within an object to imported category predicates.']). - - :- public(ctg_pred/0). - - ctg_pred :- - {generate_list(20, List)}, - length(List, _). - - length(List, Length) :- - length(List, 0, Length). - - length([], Length, Length). - length([_| Tail], Acc, Length) :- - Acc2 is Acc + 1, - length(Tail, Acc2, Length). - -:- end_category. diff --git a/Logtalk/examples/benchmarks/database.lgt b/Logtalk/examples/benchmarks/database.lgt deleted file mode 100644 index b817551c5..000000000 --- a/Logtalk/examples/benchmarks/database.lgt +++ /dev/null @@ -1,47 +0,0 @@ - -:- object(database). - - :- info([ - version is 2.0, - author is 'Paulo Moura', - date is 2007/04/17, - comment is 'Dynamic database benchmark utility predicates.']). - - :- public(this_dyndb/1). - :- mode(this_dyndb(+nonvar), one). - :- info(this_dyndb/1, [ - comment is 'Asserts and retracts a predicate in "this".', - argnames is ['Term']]). - - :- public(self_dyndb/1). - :- mode(self_dyndb(+nonvar), one). - :- info(self_dyndb/1, [ - comment is 'Asserts and retracts a predicate using ::/1.', - argnames is ['Term']]). - - :- public(obj_dyndb/1). - :- mode(obj_dyndb(+nonvar), one). - :- info(obj_dyndb/1, [ - comment is 'Asserts and retracts a predicate using ::/2.', - argnames is ['Term']]). - - :- private([pred_this/1, pred_self/1, pred_obj/1]). - :- dynamic([pred_this/1, pred_self/1, pred_obj/1]). - - % direct calls to assertz/1 and retract/1: - this_dyndb(N) :- - assertz(pred_this(N)), - retract(pred_this(N)). - - % calls to assertz/1 and retract/1 using ::/1: - self_dyndb(N) :- - ::assertz(pred_self(N)), - ::retract(pred_self(N)). - - % calls to assertz/1 and retract/1 using ::/2: - obj_dyndb(N) :- - this(This), - This::assertz(pred_obj(N)), - This::retract(pred_obj(N)). - -:- end_object. diff --git a/Logtalk/examples/benchmarks/loader.lgt b/Logtalk/examples/benchmarks/loader.lgt deleted file mode 100644 index 3837d1bd7..000000000 --- a/Logtalk/examples/benchmarks/loader.lgt +++ /dev/null @@ -1,8 +0,0 @@ - -% uncomment the next line if your Prolog compiler supports modules -%:- ensure_loaded(module). - -:- initialization(( - logtalk_load([category], [events(off), reload(skip)]), - logtalk_load([objects, database], [events(off), reload(skip)]), - logtalk_load([plain, benchmarks], [events(off)]))). diff --git a/Logtalk/examples/benchmarks/loader_events.lgt b/Logtalk/examples/benchmarks/loader_events.lgt deleted file mode 100644 index 934c31b01..000000000 --- a/Logtalk/examples/benchmarks/loader_events.lgt +++ /dev/null @@ -1,6 +0,0 @@ - -% uncomment the next line if your Prolog compiler supports modules -%:- ensure_loaded(module). - -:- initialization( - logtalk_load([category, objects, database, plain, benchmarks], [events(on)])). diff --git a/Logtalk/examples/benchmarks/loader_no_events.lgt b/Logtalk/examples/benchmarks/loader_no_events.lgt deleted file mode 100644 index b21fac75f..000000000 --- a/Logtalk/examples/benchmarks/loader_no_events.lgt +++ /dev/null @@ -1,6 +0,0 @@ - -% uncomment the next line if your Prolog compiler supports modules -%:- ensure_loaded(module). - -:- initialization( - logtalk_load([category, objects, database, plain, benchmarks], [events(off)])). diff --git a/Logtalk/examples/benchmarks/loader_static_binding.lgt b/Logtalk/examples/benchmarks/loader_static_binding.lgt deleted file mode 100644 index 3837d1bd7..000000000 --- a/Logtalk/examples/benchmarks/loader_static_binding.lgt +++ /dev/null @@ -1,8 +0,0 @@ - -% uncomment the next line if your Prolog compiler supports modules -%:- ensure_loaded(module). - -:- initialization(( - logtalk_load([category], [events(off), reload(skip)]), - logtalk_load([objects, database], [events(off), reload(skip)]), - logtalk_load([plain, benchmarks], [events(off)]))). diff --git a/Logtalk/examples/benchmarks/module.pl b/Logtalk/examples/benchmarks/module.pl deleted file mode 100644 index 4c327e079..000000000 --- a/Logtalk/examples/benchmarks/module.pl +++ /dev/null @@ -1,28 +0,0 @@ - -% you may need to update the module directive that follows for -% compatibility with your Prolog compiler module system - -:- module(module, [mod_length/2]). - - -mod_length(List, Length) :- - ( integer(Length) -> - Length >= 0, - mod_make_list(Length, List) - ; mod_length(List, 0, Length) - ). - - -mod_make_list(0, []):- - !. - -mod_make_list(N, [_| Tail]):- - M is N-1, - mod_make_list(M, Tail). - - -mod_length([], Length, Length). - -mod_length([_| Tail], Acc, Length) :- - Acc2 is Acc + 1, - mod_length(Tail, Acc2, Length). diff --git a/Logtalk/examples/benchmarks/object.lgt b/Logtalk/examples/benchmarks/object.lgt deleted file mode 100644 index d022ae895..000000000 --- a/Logtalk/examples/benchmarks/object.lgt +++ /dev/null @@ -1,24 +0,0 @@ - -:- object(object). - - :- public(length/2). - - length(List, Length) :- - integer(Length) -> - Length >= 0, - make_list(Length, List) - ; - length(List, 0, Length). - - make_list(0, []) :- - !. - make_list(N, [_| Tail]):- - M is N-1, - make_list(M, Tail). - - length([], Length, Length). - length([_| Tail], Acc, Length) :- - Acc2 is Acc + 1, - length(Tail, Acc2, Length). - -:- end_object. diff --git a/Logtalk/examples/benchmarks/objects.lgt b/Logtalk/examples/benchmarks/objects.lgt deleted file mode 100644 index 9dfb42951..000000000 --- a/Logtalk/examples/benchmarks/objects.lgt +++ /dev/null @@ -1,65 +0,0 @@ - -:- object(object, - imports(category)). - - :- info([ - version is 3.0, - author is 'Paulo Moura', - date is 2007/06/11, - comment is 'Example object for benchmarking library predicate calls and imported category predicate calls.']). - - :- public(length/2). - - length(List, Length) :- - length(List, 0, Length). - - length([], Length, Length). - length([_| Tail], Acc, Length) :- - Acc2 is Acc + 1, - length(Tail, Acc2, Length). - - :- public(ctg_self/0). - % call an imported category predicate by sending a message to self; - % performance will depend on the distance between "self" and "this" - % (always uses dynamic binding) - ctg_self :- - ::ctg_pred. - - :- public(ctg_direct/0). - % call an imported category predicate directly by using the :/1 control construct; - % (static binding may be used, depending on how the category is compiled) - ctg_direct :- - :ctg_pred. - - :- public(obj_local/0). - % call a local object predicate directly; used for comparing performance with - % calls to category predicates using the ::/1 and :/1 control constructs - obj_local :- - {generate_list(20, List)}, - length(List, _). - -:- end_object. - - -:- object(descendant, - extends(object)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2007/04/17, - comment is 'Example object used for simulating a small hierarchy.']). - -:- end_object. - - -:- object(leaf, - extends(descendant)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2007/04/17, - comment is 'Example object used for simulating a small hierarchy.']). - -:- end_object. diff --git a/Logtalk/examples/benchmarks/plain.lgt b/Logtalk/examples/benchmarks/plain.lgt deleted file mode 100644 index a24f8c373..000000000 --- a/Logtalk/examples/benchmarks/plain.lgt +++ /dev/null @@ -1,42 +0,0 @@ - -my_length(List, Length) :- - my_length(List, 0, Length). - -my_length([], Length, Length). -my_length([_| Tail], Acc, Length) :- - Acc2 is Acc + 1, - my_length(Tail, Acc2, Length). - - -:- dynamic(pred_plain/1). - -plain_dyndb(N) :- - assertz(pred_plain(N)), - retract(pred_plain(N)). - - -my_between(Lower, _, Lower). -my_between(Lower, Upper, Integer) :- - Lower < Upper, - Next is Lower + 1, - my_between(Next, Upper, Integer). - - -my_repeat(_). -my_repeat(N) :- - N > 1, - N2 is N - 1, - my_repeat(N2). - - -% generate a list containing the first N non-negative integers - -generate_list(N, List) :- - generate_list(0, N, List). - -generate_list(N, N, []) :- - !. -generate_list(M, N, [M| Ms]) :- - M < N, - M2 is M + 1, - generate_list(M2, N, Ms). diff --git a/Logtalk/examples/birds/NOTES.txt b/Logtalk/examples/birds/NOTES.txt deleted file mode 100644 index d058f2c56..000000000 --- a/Logtalk/examples/birds/NOTES.txt +++ /dev/null @@ -1,58 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains an example of a bird identification expert system -adopted with permission from the book "Adventure in Prolog" by Amzi! inc. -The book is available on-line in HTML format at the URL: - - http://www.amzi.com - -Please refer to the book for more information on the original example. - - -The bird identification hierarchy is organized as a prototype hierarchy -as follows: - - - - - -order - falconiforms - falcon - peregrine_falcon - sparrow_hawk - vulture - california_condor - turkey_vulture - passerformes - flycatcher - ash_throated_flycatcher - great_crested_flycatcher - swallow - barn_swallow - cliff_swallow - purple_martin - tubenose - fulmar - albatross - black_footed_albatross - laysan_albatross - waterfowl - duck - female_mallard - male_mallard - pintail - goose - canada_goose - snow_goose - swan - trumpeter_swan - whistling_swan diff --git a/Logtalk/examples/birds/SCRIPT.txt b/Logtalk/examples/birds/SCRIPT.txt deleted file mode 100644 index 874d31bbe..000000000 --- a/Logtalk/examples/birds/SCRIPT.txt +++ /dev/null @@ -1,78 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(birds(loader)). -... - - -% ask the expert system for help in identifying a bird: - -| ?- expert::identify. -Bird identification expert system - -bill:sharp_hooked? (yes or no): yes. -eats:birds? (yes or no): yes. -feet:curved_talons? (yes or no): yes. -head:large? (yes or no): yes. - -What is the value for tail? -1 : narrow_at_tip -2 : forked -3 : long_rusty -4 : square -5 : other -Enter the number of choice> 1. - -wings:long_pointed? (yes or no): yes. - -Possible identification : peregrine_falcon - -No (more) candidates found. - -(16379 ms) yes - - -% identify another bird: - -| ?- expert::identify. -Bird identification expert system - -bill:sharp_hooked? (yes or no): no. -bill:flat? (yes or no): no. -bill:short? (yes or no): no. -bill:hooked? (yes or no): yes. - -What is the value for flight? -1 : ponderous -2 : powerful -3 : agile -4 : flap_glide -5 : other -Enter the number of choice> 2. - -color:dark? (yes or no): yes. -live:at_sea? (yes or no): yes. -nostrils:external_tubular? (yes or no): yes. - -What is the value for size? -1 : large -2 : plump -3 : medium -4 : small -Enter the number of choice> 1. - -wings:long_narrow? (yes or no): yes. - -Possible identification : black_footed_albatross - -No (more) candidates found. - -(34624 ms) yes -| ?- diff --git a/Logtalk/examples/birds/birds.lgt b/Logtalk/examples/birds/birds.lgt deleted file mode 100644 index 22a255c22..000000000 --- a/Logtalk/examples/birds/birds.lgt +++ /dev/null @@ -1,320 +0,0 @@ - -:- object(order, - imports(descriptors, proto_hierarchy)). - -:- end_object. - - - - :- object(falconiforms, - imports(descriptors), - extends(order)). - - order(falconiforms). - eats(meat). - feet(curved_talons). - bill(sharp_hooked). - - :- end_object. - - - :- object(falcon, - imports(descriptors), - extends(falconiforms)). - - family(falcon). - wings(long_pointed). - head(large). - tail(narrow_at_tip). - - :- end_object. - - - :- object(peregrine_falcon, - imports(descriptors), - extends(falcon)). - - eats(birds). - - :- end_object. - - - :- object(sparrow_hawk, - imports(descriptors), - extends(falcon)). - - eats(insects). - - :- end_object. - - - :- object(vulture, - imports(descriptors), - extends(falconiforms)). - - family(vulture). - feed(scavange). - wings(broad). - - :- end_object. - - - :- object(california_condor, - imports(descriptors), - extends(vulture)). - - flight_profile(flat). - - :- end_object. - - - :- object(turkey_vulture, - imports(descriptors), - extends(vulture)). - - flight_profile(v_shaped). - - :- end_object. - - - - :- object(passerformes, - imports(descriptors), - extends(order)). - - order(passerformes). - feet(one_long_backward_toe). - - :- end_object. - - - :- object(flycatcher, - imports(descriptors), - extends(passerformes)). - - family(flycatcher). - bill(flat). - eats(flying_insects). - - :- end_object. - - - :- object(ash_throated_flycatcher, - imports(descriptors), - extends(flycatcher)). - - throat(white). - - :- end_object. - - - :- object(great_crested_flycatcher, - imports(descriptors), - extends(flycatcher)). - - tail(long_rusty). - - :- end_object. - - - :- object(swallow, - imports(descriptors), - extends(passerformes)). - - family(swallow). - wings(long_pointed). - tail(forked). - bill(short). - - :- end_object. - - - :- object(barn_swallow, - imports(descriptors), - extends(swallow)). - - tail(forked). - - :- end_object. - - - :- object(cliff_swallow, - imports(descriptors), - extends(swallow)). - - tail(square). - - :- end_object. - - - :- object(purple_martin, - imports(descriptors), - extends(swallow)). - - color(dark). - - :- end_object. - - - - :- object(tubenose, - imports(descriptors), - extends(order)). - - order(tubenose). - nostrils(external_tubular). - live(at_sea). - bill(hooked). - - :- end_object. - - - :- object(fulmar, - imports(descriptors), - extends(tubenose)). - - size(medium). - flight(flap_glide). - - :- end_object. - - - :- object(albatross, - imports(descriptors), - extends(tubenose)). - - family(albatross). - size(large). - wings(long_narrow). - - :- end_object. - - - :- object(black_footed_albatross, - imports(descriptors), - extends(albatross)). - - color(dark). - - :- end_object. - - - :- object(laysan_albatross, - imports(descriptors), - extends(albatross)). - - color(white). - - :- end_object. - - - - :- object(waterfowl, - imports(descriptors), - extends(order)). - - order(waterfowl). - feet(webbed). - bill(flat). - - :- end_object. - - - :- object(duck, - imports(descriptors), - extends(waterfowl)). - - family(duck). - feed(on_water_surface). - flight(agile). - - :- end_object. - - - :- object(female_mallard, - imports(descriptors), - extends(duck)). - - voice(quack). - color(mottled_brown). - - :- end_object. - - - :- object(male_mallard, - imports(descriptors), - extends(duck)). - - voice(quack). - head(green). - - :- end_object. - - - :- object(pintail, - imports(descriptors), - extends(duck)). - - voice(short_whistle). - - :- end_object. - - - :- object(goose, - imports(descriptors), - extends(waterfowl)). - - family(goose). - size(plump). - flight(powerful). - - :- end_object. - - - :- object(canada_goose, - imports(descriptors), - extends(goose)). - - head(black). - cheek(white). - - :- end_object. - - - :- object(snow_goose, - imports(descriptors), - extends(goose)). - - color(white). - - :- end_object. - - - :- object(swan, - imports(descriptors), - extends(waterfowl)). - - family(swan). - neck(long). - color(white). - flight(ponderous). - - :- end_object. - - - :- object(trumpeter_swan, - imports(descriptors), - extends(swan)). - - voice(loud_trumpeting). - - :- end_object. - - - :- object(whistling_swan, - imports(descriptors), - extends(swan)). - - voice(muffled_musical_whistle). - - :- end_object. diff --git a/Logtalk/examples/birds/descriptors.lgt b/Logtalk/examples/birds/descriptors.lgt deleted file mode 100644 index 98a0fd2bb..000000000 --- a/Logtalk/examples/birds/descriptors.lgt +++ /dev/null @@ -1,56 +0,0 @@ - -:- category(descriptors). - - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/2/18, - comment is 'Bird descriptors predicates.', - source is 'Example adopted from an Amzi! Inc Prolog book.']). - - - :- public([ - bill/1, - cheek/1, - color/1, - eats/1, - family/1, - feed/1, - feet/1, - flight/1, - flight_profile/1, - head/1, - live/1, - neck/1, - nostrils/1, - order/1, - size/1, - tail/1, - throat/1, - voice/1, - wings/1]). - - :- public(descriptor/1). - - - descriptor(bill/1). - descriptor(cheek/1). - descriptor(color/1). - descriptor(eats/1). - descriptor(feed/1). - descriptor(feet/1). - descriptor(flight/1). - descriptor(flight_profile/1). - descriptor(head/1). - descriptor(live/1). - descriptor(neck/1). - descriptor(nostrils/1). - descriptor(size/1). - descriptor(tail/1). - descriptor(throat/1). - descriptor(voice/1). - descriptor(wings/1). - - -:- end_category. diff --git a/Logtalk/examples/birds/expert.lgt b/Logtalk/examples/birds/expert.lgt deleted file mode 100644 index 440f2c7b7..000000000 --- a/Logtalk/examples/birds/expert.lgt +++ /dev/null @@ -1,167 +0,0 @@ - -:- object(expert, - imports(protected::descriptors)). - - - :- info([ - author is 'Paulo Moura', - version is 1.1, - date is 2005/3/6, - comment is 'Expert system for bird identification.', - source is 'Example adopted from an Amzi! Inc Prolog book.']). - - - :- public(identify/0). - - :- mode(identify, one). - - :- info(identify/0, - [comment is 'Starts a bird identification session.']). - - - :- private(known_/3). - :- dynamic(known_/3). - - :- mode(known_(?nonvar, ?nonvar, ?nonvar), zero_or_more). - - :- info(known_/3, [ - comment is 'Table of already known facts.', - argnames is ['Answer', 'Attribute', 'Value']]). - - - identify :- - ::retractall(known_(_, _, _)), - write('Bird identification expert system'), nl, nl, - forall( - (order::leaf(Bird), check(Bird)), - (nl, write('Possible identification: '), write(Bird), nl)), - nl, write('No (more) candidates found.'). - - - check(Bird) :- - forall( - (::descriptor(Functor/Arity), - functor(Predicate, Functor, Arity), - Bird::Predicate), - call(Predicate)). - - - bill(X):- - ask(bill, X). - - cheek(X):- - ask(cheek, X). - - color(X):- - ask(color, X). - - eats(X):- - ask(eats, X). - - feed(X):- - ask(feed,X). - - feet(X):- - ask(feet, X). - - flight(X):- - menuask(flight, X, [ponderous, powerful, agile, flap_glide, other]). - - flight_profile(X):- - menuask(flight_profile, X, [flat, v_shaped, other]). - - head(X):- - ask(head,X). - - live(X) :- - ask(live, X). - - neck(X):- - ask(neck, X). - - nostrils(X):- - ask(nostrils, X). - - size(X):- - menuask(size, X, [large, plump, medium, small]). - - tail(X):- - menuask(tail, X, [narrow_at_tip, forked, long_rusty, square, other]). - - throat(X):- - ask(throat, X). - - voice(X):- - ask(voice,X). - - wings(X):- - ask(wings, X). - - - ask(Attribute,Value):- - ::known_(yes, Attribute, Value), - !. - - ask(Attribute,Value):- - ::known_(_, Attribute, Value), - !, fail. - - ask(Attribute,_):- - ::known_(yes, Attribute, _), - !, fail. - - ask(Attribute, Value):- - write(Attribute), write(': '), write(Value), - write('? (yes or no): '), - read(Answer), - ::asserta(known_(Answer, Attribute, Value)), - Answer = yes. - - - menuask(Attribute,Value, _):- - ::known_(yes, Attribute, Value), - !. - - menuask(Attribute, _, _):- - ::known_(yes, Attribute, _), - !, fail. - - menuask(Attribute, AskValue, Menu):- - nl, write('What is the value for '), write(Attribute), write('?'), nl, - display_menu(Menu), - write('Enter the number of choice> '), - read(Num),nl, - pick_menu(Num, AnswerValue, Menu), - ::asserta(known_(yes,Attribute,AnswerValue)), - AskValue = AnswerValue. - - - display_menu(Menu):- - display_menu(Menu, 1). - - - display_menu([], _). - - display_menu([Item| Rest], N):- - write(N), write(' : '), write(Item), nl, - NN is N + 1, - display_menu(Rest, NN). - - - pick_menu(N, Val, Menu):- - integer(N), - pic_menu(1, N, Val, Menu), !. - - pick_menu(Val, Val, _). - - - pic_menu(_, _, none_of_the_above, []). - - pic_menu(N, N, Item, [Item| _]). - - pic_menu(Ctr, N, Val, [_| Rest]):- - NextCtr is Ctr + 1, - pic_menu(NextCtr, N, Val, Rest). - - -:- end_object. diff --git a/Logtalk/examples/birds/loader.lgt b/Logtalk/examples/birds/loader.lgt deleted file mode 100644 index 13964c87f..000000000 --- a/Logtalk/examples/birds/loader.lgt +++ /dev/null @@ -1,4 +0,0 @@ - -:- initialization(( - logtalk_load(library(hierarchies_loader), [reload(skip)]), % allow for static binding - logtalk_load([descriptors, birds, expert]))). diff --git a/Logtalk/examples/bottles/NOTES.txt b/Logtalk/examples/bottles/NOTES.txt deleted file mode 100644 index b0bc8f133..000000000 --- a/Logtalk/examples/bottles/NOTES.txt +++ /dev/null @@ -1,15 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT -file. - -This folder contains a Logtalk version of the programming problem -"99 bottles of beer on the wall" , contributed to the web site: - - http://99-bottles-of-beer.net/ diff --git a/Logtalk/examples/bottles/SCRIPT.txt b/Logtalk/examples/bottles/SCRIPT.txt deleted file mode 100644 index aee3884d5..000000000 --- a/Logtalk/examples/bottles/SCRIPT.txt +++ /dev/null @@ -1,13 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% just load the example, which contains an initialization/1 directive -% that runs it: - -| ?- logtalk_load(bottles(loader)). -... diff --git a/Logtalk/examples/bottles/bottles.lgt b/Logtalk/examples/bottles/bottles.lgt deleted file mode 100644 index 5aa2468f6..000000000 --- a/Logtalk/examples/bottles/bottles.lgt +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************* - * 99 Bottles of Beer - * Paulo Moura - January 21, 2007 - * bottles.lgt - * To execute start Logtalk and use the query - * logtalk_load(bottles). - *******************************************************/ - -:- object(bottles). - - :- initialization(sing(99)). - - sing(0) :- - write('No more bottles of beer on the wall, no more bottles of beer.'), nl, - write('Go to the store and buy some more, 99 bottles of beer on the wall.'), nl, nl. - sing(N) :- - N > 0, - N2 is N -1, - beers(N), write(' of beer on the wall, '), beers(N), write(' of beer.'), nl, - write('Take one down and pass it around, '), beers(N2), write(' of beer on the wall.'), nl, nl, - sing(N2). - - beers(0) :- - write('no more bottles'). - beers(1) :- - write('1 bottle'). - beers(N) :- - N > 1, - write(N), write(' bottles'). - -:- end_object. diff --git a/Logtalk/examples/bottles/loader.lgt b/Logtalk/examples/bottles/loader.lgt deleted file mode 100644 index 8260ba95d..000000000 --- a/Logtalk/examples/bottles/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(bottles)). diff --git a/Logtalk/examples/bricks/NOTES.txt b/Logtalk/examples/bricks/NOTES.txt deleted file mode 100644 index 76e6f1a74..000000000 --- a/Logtalk/examples/bricks/NOTES.txt +++ /dev/null @@ -1,25 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -You will also need to load the following files in the library directory: -events_loader, types_loader, metapredicates_loader, and hierarchies_loader. -Alternatively, you may load the library all_loader file to load all library -entities. - -This folder contains an example of representation and handling of -relations using events. We have instances of class brick and a binary -brick_stack relation between the bricks. Every time we move a brick, we -want the bricks on top of it to move along. If we break the stack by -moving a middle brick, we want to automatically destroy the -corresponding relation tuple. - -It's instructive to use the event debugger in the Logtalk library (loader -file debugging_loader.lgt) to better understand this example. Set spy points -in all brick instances and then activate the debugger. diff --git a/Logtalk/examples/bricks/SCRIPT.txt b/Logtalk/examples/bricks/SCRIPT.txt deleted file mode 100644 index a5fb554e5..000000000 --- a/Logtalk/examples/bricks/SCRIPT.txt +++ /dev/null @@ -1,215 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(bricks(loader)). -... - - -% create four bricks, all standing on the "ground" (use your imagination... ;-) - -| ?- brick::(new(a, [position-(8, 1)]), new(b, [position-(6, 1)]), new(c, [position-(4, 1)]), new(d, [position-(2, 1)])). -yes - -% set up ascii stack monitor so we can watch the bricks moving - -| ?- after_event_registry::set_monitor(_, move(_,_), _, stack_monitor). -yes - - -% make the stack - -| ?- brick_stack::(add_tuple([c,d]), add_tuple([b,c]), add_tuple([a,b])). -|.c...... -|.d...b.a ---------- -|.b...... -|.c...... -|.d.....a ---------- -|.a -|.b -|.c -|.d ---- -yes - - -% check results - -| ?- brick_stack::tuple(Tuple), write(Tuple), nl, fail. -[c,d] -[b,c] -[a,b] -no - -| ?- before_event_registry::monitors(Mb), after_event_registry::monitors(Ma). -Ma = [brick_stack, stack_monitor] -Mb = [brick_stack] -yes - - -% move all stack to new position by moving bottom brick; check results - -| ?- d::move(9, 1). -|.a....... -|.b....... -|.c....... -|........d ----------- -|.a....... -|.b....... -|........c -|........d ----------- -|.a....... -|........b -|........c -|........d ----------- -|........a -|........b -|........c -|........d ----------- -yes - -| ?- a::position(Xa, Ya), b::position(Xb, Yb), c::position(Xc, Yc), d::position(Xd, Yd). -Xa = 9, -Xb = 9, -Xc = 9, -Xd = 9, -Ya = 4, -Yb = 3, -Yc = 2, -Yd = 1 -yes - -| ?- brick_stack::tuple(Tuple), write(Tuple), nl, fail. -[c,d] -[b,c] -[a,b] -no - - -% break stack in half by moving b to the "ground"; check results - -| ?- b::move(3, 1). -|........a -|......... -|........c -|..b.....d ----------- -|..a.....c -|..b.....d ----------- -yes - -| ?- a::position(Xa, Ya), b::position(Xb, Yb), c::position(Xc, Yc), d::position(Xd, Yd). -Xa = 3, -Xb = 3, -Xc = 9, -Xd = 9, -Ya = 2, -Yb = 1, -Yc = 2, -Yd = 1 -yes - -| ?- brick_stack::tuple(Tuple), write(Tuple), nl, fail. -[c,d] -[a,b] -no - - -% create new brick_stack tuple ; check results - -| ?- brick_stack::add_tuple([d, a]). -|..d...... -|..a.....c -|..b...... ----------- -|..c -|..d -|..a -|..b ----- -yes - -| ?- a::position(Xa, Ya), b::position(Xb, Yb), c::position(Xc, Yc), d::position(Xd, Yd). -Xa = 3, -Xb = 3, -Xc = 3, -Xd = 3, -Ya = 2, -Yb = 1, -Yc = 4, -Yd = 3 -yes - -| ?- brick_stack::tuple(Tuple), write(Tuple), nl, fail. -[c,d] -[a,b] -[d,a] -no - - -% move all stack to new position by moving bottom brick; check results - -| ?- b::move(5, 1). -|..c.. -|..d.. -|..a.. -|....b ------- -|..c.. -|..d.. -|....a -|....b ------- -|..c.. -|....d -|....a -|....b ------- -|....c -|....d -|....a -|....b ------- -yes - -| ?- a::position(Xa, Ya), b::position(Xb, Yb), c::position(Xc, Yc), d::position(Xd, Yd). -Xa = 5, -Xb = 5, -Xc = 5, -Xd = 5, -Ya = 2, -Yb = 1, -Yc = 4, -Yd = 3 -yes - -| ?- brick_stack::tuple(Tuple), write(Tuple), nl, fail. -[c,d] -[a,b] -[d,a] -no - - -% clean up instances, tuples and monitors - -| ?- brick_stack::remove_all_tuples. -yes - -| ?- after_event_registry::del_monitors(_, _, _, stack_monitor). -yes - -| ?- brick::delete_all. -yes diff --git a/Logtalk/examples/bricks/bricks.lgt b/Logtalk/examples/bricks/bricks.lgt deleted file mode 100644 index fd947cb9b..000000000 --- a/Logtalk/examples/bricks/bricks.lgt +++ /dev/null @@ -1,141 +0,0 @@ - -:- object(brick, - instantiates(class), - specializes(object)). - - :- info([ - version is 1.1, - date is 2000/10/31, - author is 'Paulo Moura', - comment is 'Two-dimensional brick (or should I say square?) class.']). - - :- public(position/2). - :- mode(position(?integer, ?integer), zero_or_one). - :- info(position/2, [ - comment is 'Brick current position.', - argnames is ['X', 'Y']]). - - :- private(position_/2). - :- dynamic(position_/2). - :- mode(position_(?integer, ?integer), zero_or_one). - :- info(position_/2, [ - comment is 'Stores brick current position.', - argnames is ['X', 'Y']]). - - :- public(move/2). - :- mode(move(+integer, +integer), one). - :- info(move/2, [ - comment is 'Moves a brick to a new position.', - argnames is ['X', 'Y']]). - - position(X, Y) :- - ::position_(X, Y). - - move(X, Y) :- - ::retractall(position_(_, _)), - ::assertz(position_(X, Y)). - - default_init_option(position-(0, 0)). - default_init_option(Default) :- - ^^default_init_option(Default). - - process_init_option(position-(X, Y)) :- - ::assertz(position_(X, Y)). - process_init_option(Option) :- - ^^process_init_option(Option). - - valid_init_option(position-(X, Y)) :- - !, - integer(X), - integer(Y). - valid_init_option(Option) :- - ^^valid_init_option(Option). - - instance_base_name(b). - -:- end_object. - - -:- object(brick_stack, - instantiates(constrained_relation)). - - :- info([ - version is 1.0, - date is 1998/3/23, - author is 'Paulo Moura', - comment is 'Stack of bricks as a constrained binary relation.']). - - descriptor_([top, bottom]). - - domain_(top, brick). - domain_(bottom, brick). - - key_([top, bottom]). - - cardinality_(top, 0, 1). - cardinality_(bottom, 0, 1). - - delete_option_(top, cascade). - delete_option_(bottom, restrict). - - add_tuple([A, B]) :- - B::position(Xb, Yb), - Ya2 is Yb + 1, - {A::move(Xb, Ya2)}, - ^^add_tuple([A, B]). - - activ_points_(top, before, []). - activ_points_(top, after, [move(_, _)]). - - activ_points_(bottom, before, []). - activ_points_(bottom, after, [move(_, _)]). - - propagate(after, move(X, Y), Top, top, [Top, Bottom]) :- - !, - Y2 is Y - 1, - (Bottom::position(X, Y2) -> - true - ; - ::remove_tuple([Top, Bottom])). - - propagate(after, move(X, Y), Bottom, bottom, [Top, Bottom]) :- - !, - Y2 is Y + 1, - {Top::move(X, Y2)}. - -:- end_object. - - -:- object(stack_monitor, - implements(monitoring)). - - :- info([ - version is 1.1, - date is 2006/12/14, - author is 'Paulo Moura', - comment is 'Monitor for brick movements printing an ascii representation of each brick position.']). - - :- uses(loop). - :- uses(list). - - after(_, move(_, _), _) :- - findall( - (Brick, X, Y), - (instantiates_class(Brick, brick), Brick::position(X, Y)), - Bricks), - setof(X, Brick^Y^ (list::member((Brick,X,Y), Bricks)), Xs), - list::last(Xs, Xmax), - setof(Y, Brick^X^ (list::member((Brick,X,Y), Bricks)), Ys), - list::last(Ys, Ymax), - loop::fordownto(Y, Ymax, 1, - (write('|'), - loop::forto(X, 1, Xmax, - (list::member((Brick, X, Y), Bricks) -> - write(Brick) - ; - write('.'))), - nl)), - write('-'), - loop::forto(X, 1, Xmax, write('-')), nl. - -:- end_object. diff --git a/Logtalk/examples/bricks/loader.lgt b/Logtalk/examples/bricks/loader.lgt deleted file mode 100644 index 129cd1fb7..000000000 --- a/Logtalk/examples/bricks/loader.lgt +++ /dev/null @@ -1,6 +0,0 @@ - -:- initialization(( - logtalk_load(library(all_loader), [reload(skip)]), % allow for static binding - logtalk_load(roots(loader), [reload(skip)]), % allow for static binding - logtalk_load(relations(loader), [reload(skip)]), % allow for static binding - logtalk_load(bricks, [events(on)]))). diff --git a/Logtalk/examples/classvars/NOTES.txt b/Logtalk/examples/classvars/NOTES.txt deleted file mode 100644 index ec01e1ac0..000000000 --- a/Logtalk/examples/classvars/NOTES.txt +++ /dev/null @@ -1,20 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains an example that shows how to implement class variables -as defined in Smalltalk. The name shared instance variables is however much -more accurate. In systems like Logtalk, which enables the use of explicit -metaclasses, true class variables are just the class (as an object) own -instance variables! - -This example defines a root class (root) and three instances (instance1, -instance2, and instance3). The root class defines a shared instance variable -(using a dynamic predicate) and the setter and getter methods which implement -the variable sharing behavior. \ No newline at end of file diff --git a/Logtalk/examples/classvars/SCRIPT.txt b/Logtalk/examples/classvars/SCRIPT.txt deleted file mode 100644 index 82844987e..000000000 --- a/Logtalk/examples/classvars/SCRIPT.txt +++ /dev/null @@ -1,38 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(classvars(loader)). -... - - -% get the value of the class variable for each instance: - -| ?- instance1::cv(Value1), instance2::cv(Value2), instance3::cv(Value3). - -Value1 = 0 -Value2 = 0 -Value3 = 0 -yes - - -% change the value of the class variable via instance1: - -| ?- instance1::set_cv(1). - -yes - - -% get the value of the class variable for the other instances: - -| ?- instance2::cv(Value2), instance3::cv(Value3). - -Value2 = 1 -Value3 = 1 -yes diff --git a/Logtalk/examples/classvars/classvars.lgt b/Logtalk/examples/classvars/classvars.lgt deleted file mode 100644 index 2db21c23a..000000000 --- a/Logtalk/examples/classvars/classvars.lgt +++ /dev/null @@ -1,42 +0,0 @@ - -:- object(root, % avoid infinite metaclass regression by - instantiates(root)). % making the class its own metaclass - - :- private(cv_/1). - :- dynamic(cv_/1). - :- mode(cv_(?integer), zero_or_one). - - :- public(cv/1). - :- mode(cv(?integer), zero_or_one). - - :- public(set_cv/1). - :- mode(set_cv(+integer), one). - - cv_(0). % cv_/1 value is stored locally, in this class - - cv(Value) :- - cv_(Value). % retrive cv_/1 value, shared for all instances - - set_cv(Value) :- - retractall(cv_(_)), % retract old cv_/1 value from this class - asserta(cv_(Value)). % assert the new value into this class - -:- end_object. - - -:- object(instance1, - instantiates(root)). - -:- end_object. - - -:- object(instance2, - instantiates(root)). - -:- end_object. - - -:- object(instance3, - instantiates(root)). - -:- end_object. diff --git a/Logtalk/examples/classvars/loader.lgt b/Logtalk/examples/classvars/loader.lgt deleted file mode 100644 index 263eab4e9..000000000 --- a/Logtalk/examples/classvars/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(classvars)). diff --git a/Logtalk/examples/dcgs/NOTES.txt b/Logtalk/examples/dcgs/NOTES.txt deleted file mode 100644 index 55dee1d5b..000000000 --- a/Logtalk/examples/dcgs/NOTES.txt +++ /dev/null @@ -1,57 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains the following examples of using DCGs inside -objects and categories: - - calculator - canonical DCG example of parsing arithmetic expressions - enigma - solve a cellphone enigma against a dictionary of words - bom - bill of materials DCG example (see below for original source) - sentences - simple parsing of natural language sentences - parsetree - same as above but building and returning the parse tree - xml - conversion between XML and Prolog terms - url - parsing of URLs, decomposing them in components - shell - parsing of command-line shell commands - faa - command language DCG example (see below for original source) - walker - parsing of walker movements and calculation of distance - travelled - bypass - using the {} DCG construct together with the {} Logtalk control - construct - tokenizer - natural language tokenizer example - macaddr - validator for MAC addresses - morse - decoder for Morse code messages; illustrate how to use scope - directives to declare grammar rule non-terminals - -This folder contains an example ("tokenizer") adopted with permission from -a Michael A. Covington example (http://www.ai.uga.edu/~mc/). See the file -"tokenizer.lgt" for more details. - -This folder contains two examples of DCGs ("bom" and "faa") adopted with -permission from the Amzi! Prolog documentation. The documentation is -available on-line in HTML format at the URL: - - http://www.amzi.com/ - -Please refer to the Amzi! Prolog documentation for more information on the -original examples. diff --git a/Logtalk/examples/dcgs/SCRIPT.txt b/Logtalk/examples/dcgs/SCRIPT.txt deleted file mode 100644 index 091b70cc5..000000000 --- a/Logtalk/examples/dcgs/SCRIPT.txt +++ /dev/null @@ -1,178 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(dcgs(loader)). -... - - -% DCG rules implementing a simple calculator: - -| ?- calculator::parse("1+2-3*4", Result). - -Result = -9 -yes - - -% recognize MAC addresses: - -| ?- macaddr::valid("00:1e:4a:ef:72:8b"). - -yes - - -% decode Morse code messages: - -?- morse::phrase(morse(Message), "... --- ..."). - -Message = [sos] -yes - - -% solve a cellphone keypad encoded enigma: - -| ?- enigma::solve("4 96853 5683 86 4283 346637 9484 968 8664448", Message). - -Message = [i, would, love, to, have, dinner, with, you, tonight] -yes - - -% recognizing gramatically correct sentences: - -| ?- sentence::parse([the, girl, likes, the, boy], Result). - -Result = true -yes - -| ?- sentence::parse([the, girl, scares, the, boy], Result). - -Result = false -yes - - -% generating parse trees for sentences: - -| ?- parsetree::parse([the, girl, likes, the, boy], Tree). - -Tree = s(np(d(the), n(girl)), vp(v(likes), np(d(the), n(boy)))) -yes - - -% bill of materials example: - -| ?- bom::parts(bike, L). - -L = [frame, crank, pedal, pedal, chain, spokes, rim, hub, spokes, rim, hub] -yes - -| ?- bom::parts(wheel, L). - -L = [spokes, rim, hub] -yes - - -% parsing command-line shell input: - -| ?- shell::parse("pwd; cd ..; ls -a", L). - -L = [pwd,'cd ..','ls -a'] ? - -yes - - -% convert a string to a list of tokens (words, numbers, ponctuation): - -| ?- tokenizer::tokens(" We owe $1,048,576.24 to Agent 007 for Version 3.14159! ", Tokens). - -Tokens = [we,owe,$,1048576.24,to,agent,7,for,version,3.14159,!] ? - -yes - - -% walker movements: - -| ?- walker::walk([n(5), e(4), s(2), nw(8), s(5), se(1), n(4)], Ending). - -Ending = -0.94974746830583223,6.9497474683058318 ? - -yes - - -% conversion between compound terms and XML: - -| ?- xml::convert(word(child, children), word(singular, plural), XML). - -XML = 'childchildren' -yes - -| ?- xml::convert(Term, Interpretation, 'childchildren'). - -Term = word(child, children) -Interpretation = word(singular, plural) -yes - - -% parsing URLs: - -| ?- url::parse("http://logtalk.org", Components). - -Components = [protocol(http), address([www, logtalk, org]), path([]), file('')] -yes - -| ?- url::parse("http://logtalk.org/", Components). - -Components = [protocol(http), address([www, logtalk, org]), path(['']), file('')] -yes - -| ?- url::parse("http://logtalk.org/cvs", Components). - -Components = [protocol(http), address([www, logtalk, org]), path([cvs]), file('')] -yes - -| ?- url::parse("http://logtalk.org/cvs.html", Components). - -Components = [protocol(http), address([www, logtalk, org]), path([]), file('cvs.html')] -yes - -| ?- url::parse("http://193.136.64.5/files/update", Components). - -Components = [protocol(http), address([193, 136, 64, 5]), path([files, update]), file('')] -yes - - -% command language example: - -| ?- faa::main. -Fly Amzi! Air -enter command> list flights -aa101 -aa102 -aa103 -enter command> book elana aa102 -enter command> book tom aa102 -enter command> list passengers aa102 -elana -tom -enter command> exit -yes - - -% double bypass using the {}/1 control constructs of grammar rules and Logtalk: - -| ?- bypass::phrase(foo, _, _). - -bar predicate called -yes - - -% run the Logtalk DCG translator on the test cases: - -| ?- dcgtest::run. - -... diff --git a/Logtalk/examples/dcgs/bom.lgt b/Logtalk/examples/dcgs/bom.lgt deleted file mode 100644 index 4fc48b752..000000000 --- a/Logtalk/examples/dcgs/bom.lgt +++ /dev/null @@ -1,33 +0,0 @@ - -:- object(bom). - - :- info([ - version is 1.0, - date is 2004/5/11, - author is 'Paulo Moura', - comment is 'Adaptation of the bill of materials DCG example from the Amzi! Prolog manual.']). - - :- public(parts/2). - :- mode(parts(+atom, -list), one). - :- info(parts/2, [ - comment is 'Returns the list of parts for building an object.', - argnames is ['Object', 'Parts']]). - - parts(Object, Parts) :- - phrase(Object, Parts). - - bike --> frame, drivechain, wheel, wheel. - - wheel --> spokes, rim, hub. - - drivechain --> crank, pedal, pedal, chain. - - spokes --> [spokes]. - crank --> [crank]. - pedal --> [pedal]. - chain --> [chain]. - rim --> [rim]. - hub --> [hub]. - frame --> [frame]. - -:- end_object. diff --git a/Logtalk/examples/dcgs/bypass.lgt b/Logtalk/examples/dcgs/bypass.lgt deleted file mode 100644 index 197cc54be..000000000 --- a/Logtalk/examples/dcgs/bypass.lgt +++ /dev/null @@ -1,15 +0,0 @@ - -bar :- % test predicate - write('bar predicate called'), nl. - - -:- object(bypass). - - :- public(foo//0). - :- mode(foo, one). - :- info(foo//0, [ - comment is 'Just the almighty and famous old foo.']). - - foo --> {{bar}}. % the external pair of {}'s have the usual DCG semantics; - % the internal pair of {}'s is the Logtalk compiler bypass control construct -:- end_object. diff --git a/Logtalk/examples/dcgs/calculator.lgt b/Logtalk/examples/dcgs/calculator.lgt deleted file mode 100644 index 371d66518..000000000 --- a/Logtalk/examples/dcgs/calculator.lgt +++ /dev/null @@ -1,23 +0,0 @@ - -:- object(calculator, - implements(parsep)). - - - parse(Expression, Value) :- - phrase(expr(Value), Expression). - - - expr(Z) --> term(X), "+", expr(Y), {Z is X + Y}. - expr(Z) --> term(X), "-", expr(Y), {Z is X - Y}. - expr(X) --> term(X). - - term(Z) --> number(X), "*", term(Y), {Z is X * Y}. - term(Z) --> number(X), "/", term(Y), {Z is X / Y}. - term(Z) --> number(Z). - - number(C) --> "+", number(C). - number(C) --> "-", number(X), {C is -X}. - number(X) --> [C], {0'0 =< C, C =< 0'9, X is C - 0'0}. - - -:- end_object. diff --git a/Logtalk/examples/dcgs/dcgtest.lgt b/Logtalk/examples/dcgs/dcgtest.lgt deleted file mode 100644 index 6e0b6ec92..000000000 --- a/Logtalk/examples/dcgs/dcgtest.lgt +++ /dev/null @@ -1,118 +0,0 @@ - -:- object(dcgtest). - - :- info([ - version is 1.0, - date is 2004/9/27, - author is 'Paulo Moura', - comment is 'Test cases for the Logtalk DCG translator.']). - - :- public(run/0). - :- mode(run, one). - :- info(run/0, [ - comment is 'Runs the Logtalk DCG translator on the test cases.']). - - run :- - write('Testing expand_term/2 predicate ...'), nl, nl, - gr_tr_test(N, GR, Result), - write(N), write(': '), writeq(GR), write(' --- '), - write(Result), write(' expected'), nl, - ( catch( - expand_term(GR, Clause), - Error, - (write(' error: '), write(Error), nl, fail)) -> - write(' '), writeq(Clause) - ; write(' expansion failed!') - ), - nl, nl, - fail. - run. - - write_error(Error) :- - write(' ERROR: '), writeq(Error), nl, fail. - - % terminal tests with list notation: - gr_tr_test(101, (p --> []), success). - gr_tr_test(102, (p --> [b]), success). - gr_tr_test(103, (p --> [abc, xyz]), success). - gr_tr_test(104, (p --> [abc | xyz]), error). - gr_tr_test(105, (p --> [[], {}, 3, 3.2, a(b)]), success). - gr_tr_test(106, (p --> [_]), success). - - % terminal tests with string notation: - gr_tr_test(151, (p --> "b"), success). - gr_tr_test(152, (p --> "abc", "q"), success). - gr_tr_test(153, (p --> "abc" ; "q"), success). - - % simple non-terminal tests: - gr_tr_test(201, (p --> b), success). - gr_tr_test(202, (p --> 3), error). - gr_tr_test(203, (p(X) --> b(X)), success). - - % conjunction tests: - gr_tr_test(301, (p --> b, c), success). - gr_tr_test(311, (p --> true, c), success). - gr_tr_test(312, (p --> fail, c), success). - gr_tr_test(313, (p(X) --> call(X), c), success). - - % disjunction tests: - gr_tr_test(351, (p --> b ; c), success). - gr_tr_test(352, (p --> q ; []), success). - gr_tr_test(353, (p --> [a] ; [b]), success). - - % if-then-else tests: - gr_tr_test(401, (p --> b -> c), success). - gr_tr_test(411, (p --> b -> c; d), success). - gr_tr_test(421, (p --> b -> c1, c2 ; d), success). - gr_tr_test(422, (p --> b -> c ; d1, d2), success). - gr_tr_test(431, (p --> b1, b2 -> c ; d), success). - gr_tr_test(441, (p --> [x] -> [] ; q), success). - - % negation tests: - gr_tr_test(451, (p --> \+ b, c), success). - gr_tr_test(452, (p --> b, \+ c, d), success). - - % cut tests: - gr_tr_test(501, (p --> !, [a]), success). - gr_tr_test(502, (p --> b, !, c, d), success). - gr_tr_test(503, (p --> b, !, c ; d), success). - gr_tr_test(504, (p --> [a], !, {fail}), success). - gr_tr_test(505, (p(a), [X] --> !, [X, a], q), success). - gr_tr_test(506, (p --> a, ! ; b), success). - - % {}/1 tests: - gr_tr_test(601, (p --> {b}), success). - gr_tr_test(602, (p --> {3}), error). - gr_tr_test(603, (p --> {c,d}), success). - gr_tr_test(604, (p --> '{}'((c,d))), success). - gr_tr_test(605, (p --> {a}, {b}, {c}), success). - gr_tr_test(606, (p --> {q} -> [a] ; [b]), success). - gr_tr_test(607, (p --> {q} -> [] ; b), success). - gr_tr_test(608, (p --> [foo], {write(x)}, [bar]), success). - gr_tr_test(609, (p --> [foo], {write(hello)},{nl}), success). - gr_tr_test(610, (p --> [foo], {write(hello), nl}), success). - - % "metacall" tests: - gr_tr_test(701, (p --> X), success). - gr_tr_test(702, (p --> _), success). - - % non-terminals corresponding to "graphic" characters - % or built-in operators/predicates: - gr_tr_test(801, ('[' --> b, c), success). - gr_tr_test(802, ((=) --> b, c), success). - - % pushback tests: - gr_tr_test(901, (p, [t] --> b, c), success). - gr_tr_test(902, (p, [t] --> b, [t]), success). - gr_tr_test(903, (p, [t] --> b, [s, t]), success). - gr_tr_test(904, (p, [t] --> b, [s], [t]), success). - gr_tr_test(905, (p(X), [X] --> [X]), success). - gr_tr_test(906, (p(X, Y), [X, Y] --> [X, Y]), success). - gr_tr_test(907, (p(a), [X] --> !, [X, a], q), success). - gr_tr_test(908, (p, [a,b] --> [foo], {write(hello), nl}), success). - gr_tr_test(909, (p, [t1], [t2] --> b, c), error). - gr_tr_test(910, (p, b --> b), error). - gr_tr_test(911, ([t], p --> b), error). - gr_tr_test(911, ([t1], p, [t2] --> b), error). - -:- end_object. diff --git a/Logtalk/examples/dcgs/enigma.lgt b/Logtalk/examples/dcgs/enigma.lgt deleted file mode 100644 index c459a14fd..000000000 --- a/Logtalk/examples/dcgs/enigma.lgt +++ /dev/null @@ -1,76 +0,0 @@ - -:- object(enigma). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2006/01/22, - comment is 'Example of using DCG rules to decrypt a enigma where words are made of numbers corresponding to the characters on a cellphone keypad.']). - - :- public(solve/2). - :- mode(solve(+string, -list(atom)), zero_or_one). - :- info(solve/2, [ - comment is 'Solves a cellphone enigma against a dictionary of words.', - argnames is ['Enigma', 'Message']]). - - solve(Enigma, Message) :- - phrase(message(Message), Enigma). - - message([Word| Words]) --> separator, word(Chars), {atom_chars(Word, Chars), dictionary(Word)}, !, message(Words). - message([]) --> separator. - - word([Char| Chars]) --> character(Char), word(Chars). - word([]) --> []. - - separator --> " ", !, separator. - separator --> []. - - character(a) --> "2". - character(b) --> "2". - character(c) --> "2". - - character(d) --> "3". - character(e) --> "3". - character(f) --> "3". - - character(g) --> "4". - character(h) --> "4". - character(i) --> "4". - - character(j) --> "5". - character(k) --> "5". - character(l) --> "5". - - character(m) --> "6". - character(n) --> "6". - character(o) --> "6". - - character(p) --> "7". - character(q) --> "7". - character(r) --> "7". - character(s) --> "7". - - character(t) --> "8". - character(u) --> "8". - character(v) --> "8". - - character(w) --> "9". - character(x) --> "9". - character(y) --> "9". - character(z) --> "9". - - dictionary(dinner). - dictionary(have). - dictionary(i). - dictionary(love). - dictionary(miss). - dictionary(much). - dictionary(me). - dictionary(you). - dictionary(so). - dictionary(to). - dictionary(tonight). - dictionary(with). - dictionary(would). - -:- end_object. diff --git a/Logtalk/examples/dcgs/faa.lgt b/Logtalk/examples/dcgs/faa.lgt deleted file mode 100644 index 4014dea7d..000000000 --- a/Logtalk/examples/dcgs/faa.lgt +++ /dev/null @@ -1,94 +0,0 @@ - -:- object(faa). - - :- info([ - version is 1.0, - date is 2004/5/10, - author is 'Paulo Moura', - comment is 'Adaptation of the command language DCG example from the Amzi! Prolog manual.']). - - :- public(main/0). - :- mode(main, one). - :- info(main/0, [ - comment is 'Starts iteractive command language interpreter.']). - - :- private(booked/2). - :- dynamic(booked/2). - :- mode(booked(?atom, ?atom), zero_or_more). - :- info(booked/2, [ - comment is 'Booked places in flight.', - argnames is ['Passenger', 'Flight']]). - - main :- - write('Fly Amzi! Air'), nl, - repeat, - do_command(Command), - Command == exit. - - do_command(Command) :- - write('enter command> '), - read_tokens(Tokens), - phrase(command(List), Tokens), - Command =.. List, - call(Command), - !. - - read_tokens(Tokens) :- - read_codes(Codes), - codes_to_tokens(Codes, Tokens). - - read_codes(Codes) :- - get_code(Code), - read_codes(Code, Codes). - - read_codes(10, [[]]) :- - !. - read_codes(13, [[]]) :- - !. - read_codes(32, [[]| Rest]) :- - !, read_codes(Rest). - read_codes(Code, [[Code| Codes]| Rest]) :- - read_codes([Codes| Rest]). - - codes_to_tokens([], []). - codes_to_tokens([List| Lists], [Token| Tokens]) :- - atom_codes(Token, List), - codes_to_tokens(Lists, Tokens). - - command([Op| Args]) --> operation(Op), arguments(Args). - - arguments([Arg| Args]) --> argument(Arg), arguments(Args). - arguments([]) --> []. - - operation(report) --> [list]. - operation(book) --> [book]. - operation(exit) --> ([exit]; [quit]; [bye]). - - argument(passengers) --> [passengers]. - argument(flights) --> [flights]. - - argument(Flight) --> [Flight], {flight(Flight)}. - argument(Passenger) --> [Passenger]. - - flight(aa101). - flight(aa102). - flight(aa103). - - report(flights) :- - flight(Flight), - write(Flight), nl, - fail. - report(_). - - report(passengers, Flight) :- - booked(Passenger, Flight), - write(Passenger), nl, - fail. - report(_, _). - - book(Passenger, Flight) :- - assertz(booked(Passenger, Flight)). - - exit. - -:- end_object. diff --git a/Logtalk/examples/dcgs/loader.lgt b/Logtalk/examples/dcgs/loader.lgt deleted file mode 100644 index bdd30b39b..000000000 --- a/Logtalk/examples/dcgs/loader.lgt +++ /dev/null @@ -1,19 +0,0 @@ - -:- initialization( - logtalk_load([ - parsep, - calculator, - enigma, - parsetree, - sentences, - tokenizer, - morse, - macaddr, - url, - xml, - shell, - walker, - bom, - faa, - bypass, - dcgtest])). diff --git a/Logtalk/examples/dcgs/macaddr.lgt b/Logtalk/examples/dcgs/macaddr.lgt deleted file mode 100644 index 097848f05..000000000 --- a/Logtalk/examples/dcgs/macaddr.lgt +++ /dev/null @@ -1,17 +0,0 @@ - -:- object(macaddr). - - :- public(valid/1). - - valid(Address) :- - phrase(mac, Address). - - mac --> digits, ":", digits, ":", digits, ":", digits, ":", digits, ":", digits. - - digits --> digit, digit. - - digit --> [C], {0'0 =< C, C =< 0'9}. - digit --> [C], {0'a =< C, C =< 0'f}. - digit --> [C], {0'A =< C, C =< 0'F}. - -:- end_object. diff --git a/Logtalk/examples/dcgs/morse.lgt b/Logtalk/examples/dcgs/morse.lgt deleted file mode 100644 index 6284b4680..000000000 --- a/Logtalk/examples/dcgs/morse.lgt +++ /dev/null @@ -1,86 +0,0 @@ - -:- object(morse). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2007/06/14, - comment is 'Morse code decoder.']). - - :- public(morse//1). - :- mode(morse(-list(atom)), zero_or_one). - :- info(morse//1, [ - comment is 'Recognizes a message in Morse code, returning the corresponding list of words.', - argnames is ['Words']]). - - morse([Word| Words]) --> word(Characters), {atom_chars(Word, Characters)}, " ", morse(Words). - morse([Word]) --> word(Characters), {atom_chars(Word, Characters)}. - - word([Character| Characters]) --> character(LM), {code(Character, LM)}, " ", word(Characters). - word([Character]) --> character(Symbols), {code(Character, Symbols)}. - - character([Symbol| Symbols]) --> symbol([Symbol]), character(Symbols). - character([Symbol]) --> symbol([Symbol]). - - symbol(".") --> ".". - symbol("-") --> "-". - - code(a, ".-"). - code(b, "-..."). - code(c, "-.-."). - code(d, "-.."). - code(e, "."). - code(f, "..-."). - code(g, "--."). - code(h, "...."). - code(i, ".."). - code(j, ".---"). - code(k, "-.-"). - code(l, ".-.."). - code(m, "--"). - code(n, "-."). - code(o, "---"). - code(p, ".--."). - code(q, "--.-"). - code(r, ".-."). - code(s, "..."). - code(t, "-"). - code(u, "..-"). - code(v, "...-"). - code(w, ".--"). - code(x, "-..-"). - code(y, "-.--"). - code(z, "--.."). - - code('1', ".----"). - code('2', "..---"). - code('3', "...--"). - code('4', "....-"). - code('5', "....."). - code('6', "-...."). - code('7', "--..."). - code('8', "---.."). - code('9', "----."). - code('0', "-----"). - - code('.', ".-.-.-"). - code(',', "--..--"). - code('?', "..--.."). - code('''', ".----."). - code('!', "-.-.--"). - %code('!', "— — — ·"). - code('/', "-..-."). - code('(', "-.--."). - code(')', "-.--.-"). - code('&', ".-..."). - code(':', "---..."). - code(';', "-.-.-."). - code('=', "-...-"). - code('+', ".-.-."). - code('-', "-....-"). - code('_', "..--.-"). - code('"', ".-..-."). - code('$', "...-..-"). - code('@', ".--.-"). - -:- end_object. diff --git a/Logtalk/examples/dcgs/parsep.lgt b/Logtalk/examples/dcgs/parsep.lgt deleted file mode 100644 index 7b295bc77..000000000 --- a/Logtalk/examples/dcgs/parsep.lgt +++ /dev/null @@ -1,20 +0,0 @@ - -:- protocol(parsep). - - - :- info([ - version is 1.0, - date is 2003/3/17, - author is 'Paulo Moura', - comment is 'Parse protocol for using DCG rules.']). - - - :- public(parse/2). - :- mode(parse(?list, ?nonvar), zero_or_more). - - :- info(parse/2, [ - comment is 'Parses a list using the defined set of DCG rules.', - argnames is ['List', 'Result']]). - - -:- end_protocol. \ No newline at end of file diff --git a/Logtalk/examples/dcgs/parsetree.lgt b/Logtalk/examples/dcgs/parsetree.lgt deleted file mode 100644 index 90d86648f..000000000 --- a/Logtalk/examples/dcgs/parsetree.lgt +++ /dev/null @@ -1,29 +0,0 @@ - -:- object(parsetree, - implements(parsep)). - - - parse(List, Tree) :- - phrase(sentence(Tree), List). - - - sentence(s(NP,VP)) --> noun_phrase(NP), verb_phrase(VP). - - noun_phrase(np(D,NP)) --> determiner(D), noun(NP). - noun_phrase(NP) --> noun(NP). - - verb_phrase(vp(V)) --> verb(V). - verb_phrase(vp(V,NP)) --> verb(V), noun_phrase(NP). - - - determiner(d(the)) --> [the]. - determiner(d(a)) --> [a]. - - noun(n(boy)) --> [boy]. - noun(n(girl)) --> [girl]. - - verb(v(likes)) --> [likes]. - verb(v(hates)) --> [hates]. - - -:- end_object. diff --git a/Logtalk/examples/dcgs/sentences.lgt b/Logtalk/examples/dcgs/sentences.lgt deleted file mode 100644 index 3f56c88db..000000000 --- a/Logtalk/examples/dcgs/sentences.lgt +++ /dev/null @@ -1,53 +0,0 @@ - - -% Categories allows us to neatly organize the different "kinds" -% of words on this example: determiners, nouns, and verbs - - -:- category(determiners). - - :- private(determiner//0). % private category non-terminals become private - % non-terminals of the objects importing the category - determiner --> [the]. - determiner --> [a]. - -:- end_category. - - -:- category(nouns). - - :- private(noun//0). - - noun --> [boy]. - noun --> [girl]. - -:- end_category. - - -:- category(verbs). - - :- private(verb//0). - - verb --> [likes]. - verb --> [hates]. - -:- end_category. - - -:- object(sentence, - implements(parsep), - imports(determiners, nouns, verbs)). - - parse(List, true) :- - phrase(sentence, List). - parse(_, false). - - sentence --> noun_phrase, verb_phrase. - - noun_phrase --> ::determiner, ::noun. % the ::/1 control construct is used to call grammar - noun_phrase --> ::noun. % rules encapsulated on the imported categories - - verb_phrase --> ::verb. - verb_phrase --> ::verb, noun_phrase. - -:- end_object. diff --git a/Logtalk/examples/dcgs/shell.lgt b/Logtalk/examples/dcgs/shell.lgt deleted file mode 100644 index 8e7cd98fe..000000000 --- a/Logtalk/examples/dcgs/shell.lgt +++ /dev/null @@ -1,54 +0,0 @@ - -:- object(shell). - - - :- info([ - version is 1.0, - date is 2004/4/29, - author is 'Paulo Moura', - comment is 'Simple example of command-line shell parsing.']). - - - :- public(parse/2). - - :- mode(parse(@list, -list), zero_or_one). - - :- info(parse/2, [ - comment is 'Parses a sequence of commands.', - argnames is ['Sequence', 'Commands']]). - - - parse(Sequence, Commands) :- - phrase(commands(Commands), Sequence). - - - commands([C| Cs]) --> - command(C), separator, commands(Cs). - commands([C]) --> - command(C). - - separator --> ";". - - whitespace --> " ", whitespace. - whitespace --> []. - - command(Cd) --> - whitespace, "cd", whitespace, cdargs(Args), whitespace, - {atom_concat(cd, Args, Cd)}. - command(Ls) --> - whitespace, "ls", whitespace, lsargs(Args), whitespace, - {atom_concat(ls, Args, Ls)}. - command(pwd) --> - whitespace, "pwd", whitespace. - - cdargs(' ~') --> "~". - cdargs(' ..') --> "..". - cdargs(' .') --> ".". - cdargs('') --> []. - - lsargs(' -l') --> "-l". - lsargs(' -a') --> "-a". - lsargs('') --> []. - - -:- end_object. diff --git a/Logtalk/examples/dcgs/tokenizer.lgt b/Logtalk/examples/dcgs/tokenizer.lgt deleted file mode 100644 index e6ea518c4..000000000 --- a/Logtalk/examples/dcgs/tokenizer.lgt +++ /dev/null @@ -1,114 +0,0 @@ - -% Natural Language Processing in Prolog using Definite Clause Grammar rules -% -% This example is a straightforward adaptation of the original plain Prolog -% code described in the paper: -% -% Tokenization using DCG Rules -% Michael A. Covington -% Artificial Intelligence Center -% The University of Georgia -% Athens, Georgia 30602-7415 U.S.A. -% 2000 April 21 -% -% A copy of the paper is available at: -% -% http://www.ai.uga.edu/~mc/projpaper.ps -% -% Usage example: -% -% | ?- tokenizer::tokens(" We owe $1,048,576.24 to Agent 007 for Version 3.14159! ", Tokens). - -:- object(tokenizer). - - :- info([ - version is 1.0, - date is 2006/2/11, - author is 'Michael A. Covington', - comment is 'Natural language tokenizer example using DCG rules.']). - - :- public(tokens/2). - :- mode(tokens(+string, -list), zero_or_more). - :- info(tokens/2, [ - comment is 'Parses a string into a list of tokens.', - argnames is ['String', 'Tokens']]). - - tokens(String, Tokens) :- - phrase(token_list(Tokens), String). - - % A token list is a series of zero or more tokens. - % Its argument consists of the list of tokens, as atoms and numbers. - % The cut ensures that the maximum number of characters is gathered into each token. - - token_list([T| Rest]) --> blank0, token(T), !, token_list(Rest). - token_list([]) --> blank0. - - % blank0 is a series of zero or more blanks. - - blank0 --> [C], {char_type(C, blank)}, !, blank0. - blank0 --> []. - - % Several kinds of tokens. - % This is where lists of characters get converted into atoms or numbers. - - token(T) --> special(L), {atom_codes(T, L)}. - token(T) --> word(W), {atom_codes(T, W)}. - token(T) --> numeral(N), {number_codes(T, N)}. - - % A word is a series of one or more letters. - % The rules are ordered so that we first try to gather as many - % characters into one digit_string as possible. - - word([L| Rest]) --> letter(L), word(Rest). - word([L]) --> letter(L). - - % A numeral is a list of characters that constitute a number. - % The argument of numeral(...) is the list of character codes. - - numeral([C1, C2, C3| N]) --> ",", digit(C1), digit(C2), digit(C3), numeral(N). - numeral([C1, C2, C3]) --> ",", digit(C1), digit(C2), digit(C3). - numeral([C| N]) --> digit(C), numeral(N). % multiple digits - numeral([C]) --> digit(C). % single digit - numeral(N) --> decimal_part(N). % decimal point and more digits - - decimal_part([46| Rest]) --> ".", digit_string(Rest). - - digit_string([D| N]) --> digit(D), digit_string(N). - digit_string([D]) --> digit(D). - - % Various kinds of characters... - - digit(C) --> [C], {char_type(C, numeric)}. - - special([C]) --> [C], {char_type(C, special)}. - - letter(C) --> [C], {char_type(C, lowercase)}. - letter(C) --> [U], {char_type(U, uppercase), C is U + 32}. % Conversion to lowercase - - % char_type(+Code, ?Type) - % Classifies a character (ASCII code) as blank, numeric, uppercase, lowercase, or special. - % Adapted from Covington 1994. - - char_type(Code, Type) :- % blanks, other ctrl codes - Code =< 32, - !, - Type = blank. - - char_type(Code, Type) :- % digits - 48 =< Code, Code =< 57, - !, - Type = numeric. - - char_type(Code, Type) :- % lowercase letters - 97 =< Code, Code =< 122, - !, - Type = lowercase. - - char_type(Code, Type) :- % uppercase letters - 65 =< Code, Code =< 90, - !, - Type = uppercase. - - char_type(_, special). % all others - -:- end_object. diff --git a/Logtalk/examples/dcgs/url.lgt b/Logtalk/examples/dcgs/url.lgt deleted file mode 100644 index a7281a717..000000000 --- a/Logtalk/examples/dcgs/url.lgt +++ /dev/null @@ -1,67 +0,0 @@ -:- object(url). - - - :- info([ - version is 1.0, - date is 2003/7/7, - author is 'Paulo Moura', - comment is 'Simple example of URL parsing.']). - - - :- public(parse/2). - - :- mode(parse(@list, -list), zero_or_one). - - :- info(parse/2, [ - comment is 'Parses a URL into its components.', - argnames is ['URL', 'Components']]). - - - parse(URL, [protocol(Protocol), address(Address), path(Path), file(File)]) :- - phrase(url(Protocol, Address, Path, File), URL). - - - url(Protocol, Address, Path, File) --> protocol(Protocol), "://", address(Address), path(Path), file(File). - - - protocol(ftp) --> "ftp". - protocol(http) --> "http". - protocol(https) --> "https". - protocol(rtsp) --> "rtsp". - - - address(Address) --> ip_number(Address). - address([Identifier| Identifiers]) --> identifier(Identifier), dot_identifiers(Identifiers). - - - ip_number([N1, N2, N3, N4]) --> ip_subnumber(N1), ".", ip_subnumber(N2), ".", ip_subnumber(N3), ".", ip_subnumber(N4). - - ip_subnumber(N) --> [N1, N2, N3], {N is N3 - 0'0 + 10*(N2 - 0'0) + 100*(N1 - 0'0), N >= 0, N =< 255}. - ip_subnumber(N) --> [N1, N2], {N is N2 - 0'0 + 10*(N1 - 0'0), N >= 0, N =< 255}. - ip_subnumber(N) --> [N1], {N is N1 - 0'0, N >= 0, N =< 255}. - - - identifier(Identifier) --> characters(Codes), {atom_codes(Identifier, Codes)}. - - - characters([]) --> []. - characters([Code| Codes]) --> [Code], {character(Code)}, characters(Codes). - - - character(Code) :- Code @>= 0'a, Code @=< 0'z, !. - character(Code) :- Code @>= 0'A, Code @=< 0'Z. - - - dot_identifiers([]) --> []. - dot_identifiers([Identifier| Identifiers]) --> ".", identifier(Identifier), dot_identifiers(Identifiers). - - - path([]) --> []. - path([Identifier| Path]) --> "/", identifier(Identifier), path(Path). - - - file('') --> []. - file(File) --> "/", identifier(Name), ".", identifier(Extension), {atom_concat(Name, '.', Aux), atom_concat(Aux, Extension, File)}. - - -:- end_object. diff --git a/Logtalk/examples/dcgs/walker.lgt b/Logtalk/examples/dcgs/walker.lgt deleted file mode 100644 index e11b0f52c..000000000 --- a/Logtalk/examples/dcgs/walker.lgt +++ /dev/null @@ -1,43 +0,0 @@ - -:- object(walker). - - - :- info([ - version is 1.0, - date is 2004/4/29, - author is 'Paulo Moura', - comment is 'Walker movements.']). - - - :- public(walk/2). - - :- mode(walk(@list, -position), one). - - :- info(walk/2, [ - comment is 'Parses a sequence of walker moves, returning ending position.', - argnames is ['Moves', 'Ending']]). - - - walk(Moves, Ending) :- - phrase(walk(Ending), Moves). - - - walk(Ending) --> - moves((0, 0), Ending). - - moves(Start, Ending) --> - move(Start, Temp), moves(Temp, Ending). - moves(Ending, Ending) --> - []. - - move((X0, Y0), (X, Y)) --> [ n(S)], {X is X0, Y is Y0 + S}. - move((X0, Y0), (X, Y)) --> [ne(S)], {X is X0 + S / sqrt(2), Y is Y0 + S / sqrt(2)}. - move((X0, Y0), (X, Y)) --> [ e(S)], {X is X0 + S, Y = Y0}. - move((X0, Y0), (X, Y)) --> [se(S)], {X is X0 + S / sqrt(2), Y is Y0 - S / sqrt(2)}. - move((X0, Y0), (X, Y)) --> [ s(S)], {X is X0, Y is Y0 - S}. - move((X0, Y0), (X, Y)) --> [sw(S)], {X is X0 - S / sqrt(2), Y is Y0 - S / sqrt(2)}. - move((X0, Y0), (X, Y)) --> [ w(S)], {X is X0 - S, Y = Y0}. - move((X0, Y0), (X, Y)) --> [nw(S)], {X is X0 - S / sqrt(2), Y is Y0 + S / sqrt(2)}. - - -:- end_object. diff --git a/Logtalk/examples/dcgs/xml.lgt b/Logtalk/examples/dcgs/xml.lgt deleted file mode 100644 index dbdbf4455..000000000 --- a/Logtalk/examples/dcgs/xml.lgt +++ /dev/null @@ -1,78 +0,0 @@ - -:- object(xml). - - - :- info([ - version is 1.0, - date is 2003/7/7, - author is 'Paulo Moura', - comment is 'Conversion between compound terms and XML.']). - - - :- public(convert/3). - - :- mode(convert(@compound, @compound, -atom), zero_or_one). - :- mode(convert(-compound, -compound, +atom), zero_or_one). - - :- info(convert/3, [ - comment is 'Converts between a compound term and an interpretation and XML.', - argnames is ['Term', 'Interpretation', 'XML']]). - - - convert(Term, Interpretation, XML) :- - var(XML) -> - phrase(term(Term, Interpretation), List), - atom_codes(XML, List) - ; - atom_codes(XML, List), - phrase(term(Term, Interpretation), List). - - - term(Term, Interpretation) --> - {nonvar(Term), nonvar(Interpretation), - Interpretation =.. [Functor| Tags], Term =.. [Functor| Args]}, - open_tag(Functor), - arguments(Tags, Args), - close_tag(Functor). - - term(Term, Interpretation) --> - {var(Term), var(Interpretation)}, - open_tag(Functor), - arguments(Tags, Args), - close_tag(Functor), - {Interpretation =.. [Functor| Tags], Term =.. [Functor| Args]}. - - - arguments([], []) --> - []. - - arguments([Tag| Tags], [Arg| Args]) --> - open_tag(Tag), - value(Arg), - close_tag(Tag), - arguments(Tags, Args). - - - open_tag(Tag) --> - "<", value(Tag), ">". - - close_tag(Tag) --> - "". - - - value(Value) --> - {nonvar(Value), atom_codes(Value, Codes)}, characters(Codes). - - value(Value) --> - {var(Value)}, characters(Codes), {atom_codes(Value, Codes)}. - - - characters([]) --> []. - characters([Code| Codes]) --> [Code], {character(Code)}, characters(Codes). - - - character(Code) :- Code @>= 0'a, Code @=< 0'z, !. - character(Code) :- Code @>= 0'A, Code @=< 0'Z. - - -:- end_object. diff --git a/Logtalk/examples/diamonds/NOTES.txt b/Logtalk/examples/diamonds/NOTES.txt deleted file mode 100644 index 7af30d88e..000000000 --- a/Logtalk/examples/diamonds/NOTES.txt +++ /dev/null @@ -1,50 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT -file. - -This example illustrates some variants of the "diamond problem" -(multi-inheritance conflicts and ambiguities) and its respective -solutions on Logtalk. - -This classical problem can be simply described by constructing a -"diamond" of objects and inheritance links as follows: - - A -- contains default definition for a predicate m/0 - / \ - B C -- contains redefinitions of the predicate m/0 - \ / - D -- inherits both redefinitions of the predicate m/0 - -As such, the object D inherits two conflicting definitions for the -predicate m/0, one from object B and one from object C. If we send -the message m/0 to object D, is ambiguous which inherited definition -should be used to answer it. Depending on the nature of the objects -A, B, C, and D, the correct answer can be the redefinition of m/0 in -object B, the redefinition m/0 in object C, or both redefinitions. -A programming language supporting multi-inheritance should provide -programming mechanisms allowing easy implementation of each possible -solution. - -Note that, in the context of Logtalk, the diamond problem may occur with -prototype hierarchies, class hierarchies, protocol hierarchies, or when -using category composition. - -This example deals with three variants of the diamond problem, illustrated -using prototype hierarchies: - - diamond1 - illustrates the inherited definition which is visible due to the - Logtalk predicate lookup algorithm - diamond2 - presents a solution for making the overridden inherited definition - the visible one - diamond3 - presents a solution which allows both inherited definitions to be - used in D diff --git a/Logtalk/examples/diamonds/SCRIPT.txt b/Logtalk/examples/diamonds/SCRIPT.txt deleted file mode 100644 index 3ecae69b8..000000000 --- a/Logtalk/examples/diamonds/SCRIPT.txt +++ /dev/null @@ -1,46 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(diamonds(loader)). -... - - -% first variant of the "diamond problem", defined in the "diamond1" source file: - -| ?- d1::m. - -Redefinition of method m/0 in object b1 -yes - - -% second variant of the "diamond problem", defined in the "diamond2" source file: - -| ?- d2::m. - -Redefinition of method m/0 in object c2 -yes - - -% third variant of the "diamond problem", defined in the "diamond3" source file: - -| ?- d3::b3_m. - -Redefinition of method m/0 in object b3 -yes - -| ?- d3::c3_m. - -Redefinition of method m/0 in object c3 -yes - -| ?- d3::m. - -Redefinition of method m/0 in object b3 -yes diff --git a/Logtalk/examples/diamonds/diamond1.lgt b/Logtalk/examples/diamonds/diamond1.lgt deleted file mode 100644 index 2faaa75aa..000000000 --- a/Logtalk/examples/diamonds/diamond1.lgt +++ /dev/null @@ -1,57 +0,0 @@ -/* -These objects illustrate a variant of the "diamond problem" using -a prototype hierarchy. - -In this simple case, the inherited definition which will be used in the -bottom object is determined by the Logtalk predicate lookup algorithm. -*/ - - -% root object, declaring and defining a predicate m/0: - -:- object(a1). - - :- public(m/0). - - m :- - this(This), - write('Default definition of method m/0 in object '), - write(This), nl. - -:- end_object. - - -% an object descending from the root object, which redefines predicate m/0: - -:- object(b1, - extends(a1)). - - m :- - this(This), - write('Redefinition of method m/0 in object '), - write(This), nl. - -:- end_object. - - -% another object descending from the root object, which also redefines predicate m/0: - -:- object(c1, - extends(a1)). - - m :- - this(This), - write('Redefinition of method m/0 in object '), - write(This), nl. - -:- end_object. - - -% bottom object, descending from the two previous objects and, as such, inheriting -% two definitions for the predicate m/0: - -:- object(d1, - extends(b1, c1)). - - -:- end_object. diff --git a/Logtalk/examples/diamonds/diamond2.lgt b/Logtalk/examples/diamonds/diamond2.lgt deleted file mode 100644 index 367a442d1..000000000 --- a/Logtalk/examples/diamonds/diamond2.lgt +++ /dev/null @@ -1,64 +0,0 @@ -/* -These objects illustrate a variant of the "diamond problem" using -a prototype hierarchy. - -In this simple case, a solution for making the overridden definition inherited -by the bottom object the visible one is implemented using the alias/3 predicate -directive. -*/ - - -% root object, declaring and defining a predicate m/0: - -:- object(a2). - - :- public(m/0). - - m :- - this(This), - write('Default definition of method m/0 in object '), - write(This), nl. - -:- end_object. - - -% an object descending from the root object, which redefines predicate m/0: - -:- object(b2, - extends(a2)). - - m :- - this(This), - write('Redefinition of method m/0 in object '), - write(This), nl. - -:- end_object. - - -% another object descending from the root object, which also redefines predicate m/0: - -:- object(c2, - extends(a2)). - - m :- - this(This), - write('Redefinition of method m/0 in object '), - write(This), nl. - -:- end_object. - - -% bottom object, descending from the two previous objects and, as such, inheriting -% two definitions for the predicate m/0; the overridden definition inherited from -% object "c2" is renamed using the alias/3 directive and then we redefine the -% predicate m/0 to call the renamed definition: - -:- object(d2, - extends(b2, c2)). - - :- alias(c2, m/0, c2_m/0). - - m :- - ::c2_m. - -:- end_object. diff --git a/Logtalk/examples/diamonds/diamond3.lgt b/Logtalk/examples/diamonds/diamond3.lgt deleted file mode 100644 index f44a195fc..000000000 --- a/Logtalk/examples/diamonds/diamond3.lgt +++ /dev/null @@ -1,61 +0,0 @@ -/* -These objects illustrate a variant of the "diamond problem" using -a prototype hierarchy. - -In this simple case, a solution is presented for making two conflicting -definitions inherited by the bottom object visible through the use of the -alias/3 predicate directive. -*/ - - -% root object, declaring and defining a predicate m/0: - -:- object(a3). - - :- public(m/0). - - m :- - this(This), - write('Default definition of method m/0 in object '), - write(This), nl. - -:- end_object. - - -% an object descending from the root object, which redefines predicate m/0: - -:- object(b3, - extends(a3)). - - m :- - this(This), - write('Redefinition of method m/0 in object '), - write(This), nl. - -:- end_object. - - -% another object descending from the root object, which also redefines predicate m/0: - -:- object(c3, - extends(a3)). - - m :- - this(This), - write('Redefinition of method m/0 in object '), - write(This), nl. - -:- end_object. - - -% bottom object, descending from the two previous objects and, as such, inheriting -% two definitions for the predicate m/0; both inherited definitions are renamed -% using the alias/3 directive: - -:- object(d3, - extends(b3, c3)). - - :- alias(b3, m/0, b3_m/0). - :- alias(c3, m/0, c3_m/0). - -:- end_object. diff --git a/Logtalk/examples/diamonds/loader.lgt b/Logtalk/examples/diamonds/loader.lgt deleted file mode 100644 index a6a4def23..000000000 --- a/Logtalk/examples/diamonds/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load([diamond1, diamond2, diamond3])). diff --git a/Logtalk/examples/dynpred/NOTES.txt b/Logtalk/examples/dynpred/NOTES.txt deleted file mode 100644 index 8ad0f4da5..000000000 --- a/Logtalk/examples/dynpred/NOTES.txt +++ /dev/null @@ -1,34 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains examples of using some of the built-in database -handling methods. Two hierarchies are provided, one prototype-based, -and the other class-based, in order to illustrate the differences -between asserting predicates in a class and in a prototype. - -The following objects are defined: - - root - root of the prototype hierarchy; declares and defines a public, - dynamic predicate - descendant - simple prototype extending the root prototype - - class - root of the class hierarchy; declares and defines a public predicate - metaclass - class metaclass - instance - simple instance of class class - - prototype - simple prototype used to illustrate how the scope of asserted - predicates depends on the target object (this, self, or a explicit - object) diff --git a/Logtalk/examples/dynpred/SCRIPT.txt b/Logtalk/examples/dynpred/SCRIPT.txt deleted file mode 100644 index f0829ebe3..000000000 --- a/Logtalk/examples/dynpred/SCRIPT.txt +++ /dev/null @@ -1,97 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(dynpred(loader)). -... - - -% sending to descendant the message p/1, returns the definition in root: - -| ?- descendant::p(Value). - -Value = root -yes - - -% asserting a local definition for p/1 in descendant overrides the inherited -% definition: - -| ?- descendant::(assertz(p(descendant)), p(Value)). - -Value = descendant -yes - - -% if we retract the local definition, again the definition inherited from root -% will be used: - -| ?- descendant::(retractall(p(_)), p(Value)). - -Value = root -yes - - -% class does not understand the message p1/1 (the predicate is declared only -% for the class descendant instances): - -| ?- class::p1(X). - -error(existence_error(predicate_declaration, p1(_)), class::p1(_), user) - - -% the same message is valid for the class instances: - -| ?- instance::p1(X). - -X = class -yes - - -% if we assert a clause for a new predicate, p2/1, in the class -% (a side-effect being a dynamic declaration of the predicate): - -| ?- class::assertz(p2(class)). - -yes - - -% the new predicate, like p1/1, is not available for the class: - -| ?- class::p2(Value). - -error(existence_error(predicate_declaration, p2(_)), class::p2(_), user) - - -% but is available for the class instances, the same way as p1/1: - -| ?- instance::p2(X). - -X = class -yes - - -% using a prototype, assert three new predicates (the method object_assert/0 -% asserts the predicate public_predicate/0 from outside the prototype; the -% method self_assert/0 asserts the predicate protected_predicate/0 in self; -% the method this_assert/0 asserts the predicate private_predicate/0 in this): - -| ?- prototype::(object_assert, self_assert, this_assert). - -yes - - -% and check the resulting scope of each predicate: - -| ?- prototype::dynamic_predicates. - -public_predicate/0 - public -protected_predicate/0 - protected -private_predicate/0 - private -yes diff --git a/Logtalk/examples/dynpred/classes.lgt b/Logtalk/examples/dynpred/classes.lgt deleted file mode 100644 index 1adfdede7..000000000 --- a/Logtalk/examples/dynpred/classes.lgt +++ /dev/null @@ -1,21 +0,0 @@ - -:- object(metaclass, % avoid infinite metaclass regression by - instantiates(metaclass)). % making the class its own metaclass - -:- end_object. - - -:- object(class, - instantiates(metaclass)). - - :- public(p1/1). - - p1(class). - -:- end_object. - - -:- object(instance, - instantiates(class)). - -:- end_object. diff --git a/Logtalk/examples/dynpred/loader.lgt b/Logtalk/examples/dynpred/loader.lgt deleted file mode 100644 index 500020e04..000000000 --- a/Logtalk/examples/dynpred/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load([protos, classes, prototype])). diff --git a/Logtalk/examples/dynpred/protos.lgt b/Logtalk/examples/dynpred/protos.lgt deleted file mode 100644 index 9f103930d..000000000 --- a/Logtalk/examples/dynpred/protos.lgt +++ /dev/null @@ -1,15 +0,0 @@ - -:- object(root). - - :- public(p/1). - :- dynamic(p/1). - - p(root). - -:- end_object. - - -:- object(descendant, - extends(root)). - -:- end_object. diff --git a/Logtalk/examples/dynpred/prototype.lgt b/Logtalk/examples/dynpred/prototype.lgt deleted file mode 100644 index 6793e2ad1..000000000 --- a/Logtalk/examples/dynpred/prototype.lgt +++ /dev/null @@ -1,42 +0,0 @@ - -:- object(prototype). - - - :- public(object_assert/0). - :- public(self_assert/0). - :- public(this_assert/0). - - :- public(dynamic_predicates/0). - - - object_assert :- - self(Self), - Self::assertz(public_predicate). - - - self_assert :- - ::assertz(protected_predicate). - - - this_assert :- - assertz(private_predicate). - - - dynamic_predicates :- - current_predicate(Functor/Arity), - functor(Predicate, Functor, Arity), - predicate_property(Predicate, (dynamic)), - predicate_property(Predicate, Scope), - scope(Scope), - writeq(Functor/Arity), write(' - '), writeq(Scope), nl, - fail. - - dynamic_predicates. - - - scope(private). - scope(protected). - scope((public)). - - -:- end_object. diff --git a/Logtalk/examples/encodings/NOTES.txt b/Logtalk/examples/encodings/NOTES.txt deleted file mode 100644 index f298ac1d2..000000000 --- a/Logtalk/examples/encodings/NOTES.txt +++ /dev/null @@ -1,35 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This is a very simple example of using the new, experimental encoding/1 -directive, which is fully based on the directive with the same name found -on recent development releases of SWI-Prolog. Currently, this example -requires Logtalk to be run with the SWI-Prolog compiler. - -The "babel.lgt" source file uses UTF-8 encoding. The "latin.lgt" source -file uses ISO-8859-1 (Latin 1) encoding. Be sure to use a text editor that -supports these encodings when opening these files. In addition, you may -need to configure your text editor to open the source file using the -declared encoding. If you are using the SWI-Prolog GUI application on -Windows, be sure to select a font which supports Unicode characters. - -The current Logtalk version accepts any atom as an argument for the encoding/1 -directive. As, by default, Logtalk automatically generates a XML documenting -file for each compiled entity, the following table is used to set the encoding -of the XML file: - - Logtalk source file XML file - ascii us-ascii - iso_latin_1 iso-8859-1 - unicode_be utf-16 - unicode_le utf-16 - utf8 utf-8 - -Note that the values on the left column are the ones recognized by SWI-Prolog. diff --git a/Logtalk/examples/encodings/SCRIPT.txt b/Logtalk/examples/encodings/SCRIPT.txt deleted file mode 100644 index 88c6064b4..000000000 --- a/Logtalk/examples/encodings/SCRIPT.txt +++ /dev/null @@ -1,61 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(encodings(loader)). -... - - -% query the table of "Hello world!" messages: - -| ?- babel::hello_world(Code, Text). - -Code = el -Text = 'Γειάσου κόσμος!' ; - -Code = en -Text = 'Hello world!' ; - -Code = es -Text = '¡Hola mundo!' ; - -Code = ja -Text = 'こんにちは世界!' ; - -Code = ko -Text = '여보세요 세계!' ; - -Code = nl -Text = 'Hello wereld!' ; - -Code = pt -Text = 'Olá mundo!' ; - -Code = ru -Text = 'Здравствулте! мир!' ; - -Code = zh -Text = '你好世界!' - -Yes - - -% query the table of names: - -| ?- latin::name(Name). - -Name = 'António Simões' ; - -Name = 'Cátia Conceição' ; - -Name = 'João Raínho' ; - -Name = 'Luís Araújo' - -Yes diff --git a/Logtalk/examples/encodings/babel.lgt b/Logtalk/examples/encodings/babel.lgt deleted file mode 100644 index 7b4f1bcfc..000000000 --- a/Logtalk/examples/encodings/babel.lgt +++ /dev/null @@ -1,29 +0,0 @@ - -:- encoding(utf8). % this directive, when present, must be the first term in a source file - - -:- object(babel). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2005/04/06, - comment is 'Simple test of the encoding/1 directive.']). - - :- public(hello_world/2). - :- mode(hello_world(?atom, ?atom), zero_or_more). - :- info(hello_world/2, [ - comment is 'Table of "hello world" messages in several languages (using ISO 639-2 two letter language codes for indexing).', - argnames is ['Language', 'Text']]). - - hello_world(el, 'Γειάσου κόσμος!'). - hello_world(en, 'Hello world!'). - hello_world(es, '¡Hola mundo!'). - hello_world(ja, 'こんにちは世界!'). - hello_world(ko, '여보세요 세계!'). - hello_world(nl, 'Hallo wereld!'). - hello_world(pt, 'Olá mundo!'). - hello_world(ru, 'Здравствулте! мир!'). - hello_world(zh, '你好世界!'). - -:- end_object. diff --git a/Logtalk/examples/encodings/latin.lgt b/Logtalk/examples/encodings/latin.lgt deleted file mode 100644 index 4960a7902..000000000 --- a/Logtalk/examples/encodings/latin.lgt +++ /dev/null @@ -1,24 +0,0 @@ - -:- encoding(iso_latin_1). % this directive, when present, must be the first term in a source file - - -:- object(latin). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2005/04/24, - comment is 'Simple test of the encoding/1 directive.']). - - :- public(name/1). - :- mode(name(?atom), zero_or_more). - :- info(name/1, [ - comment is 'Table of person names.', - argnames is ['Name']]). - - name('Antnio Simes'). - name('Ctia Conceio'). - name('Joo Ranho'). - name('Lus Arajo'). - -:- end_object. diff --git a/Logtalk/examples/encodings/loader.lgt b/Logtalk/examples/encodings/loader.lgt deleted file mode 100644 index 714d5cba9..000000000 --- a/Logtalk/examples/encodings/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load([babel, latin])). diff --git a/Logtalk/examples/engines/NOTES.txt b/Logtalk/examples/engines/NOTES.txt deleted file mode 100644 index 4ae41d2a4..000000000 --- a/Logtalk/examples/engines/NOTES.txt +++ /dev/null @@ -1,13 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT -file. - -For a description of this example, please see the comments in the -engines.lgt source file. diff --git a/Logtalk/examples/engines/SCRIPT.txt b/Logtalk/examples/engines/SCRIPT.txt deleted file mode 100644 index d9fbc1142..000000000 --- a/Logtalk/examples/engines/SCRIPT.txt +++ /dev/null @@ -1,62 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(engines(loader)). -... - - -% both cars provide the same interface, declared in the protocol -% that is implemented by the categories imported by each object: - -| ?- sedan::current_predicate(P). - -P = reference/1 ; -P = capacity/1 ; -P = cylinders/2 ; -P = horsepower_rpm/2 ; -P = bore_stroke/2 ; -P = fuel/1 -yes - - -| ?- coupe::current_predicate(P). - -P = reference/1 ; -P = capacity/1 ; -P = cylinders/2 ; -P = horsepower_rpm/2 ; -P = bore_stroke/2 ; -P = fuel/1 ; -yes - - -% the sedan engine properties are the ones defined in the corresponding -% imported category (classic): - -| ?- sedan::(reference(Name), cylinders(Cylinders), horsepower_rpm(HP, RPM)). - -Name = 'M180.940' -Cylinders = 6 -HP = 94 -RPM = 4800 -yes - - -% the coupe engine properties are the ones defined in the corresponding -% imported category (sport) plus the ones inherited from the top category -% (classic) which are not overridden: - -| ?- coupe::(reference(Name), cylinders(Cylinders), horsepower_rpm(HP, RPM)). - -Name = 'M180.941' -Cylinders = 6 -HP = 110 -RPM = 5000 -yes diff --git a/Logtalk/examples/engines/engines.lgt b/Logtalk/examples/engines/engines.lgt deleted file mode 100644 index c008f354c..000000000 --- a/Logtalk/examples/engines/engines.lgt +++ /dev/null @@ -1,67 +0,0 @@ -/* -This is a simple example of category composition, i.e. importation of -categories by other categories in order to provide modified components -for building objects, using car engines. - -The example defines a car engine protocol (enginep), a standard engine -(classic), and an improved version of it (sport). Both engines are then -imported in two car models (sedan and coupe). -*/ - - -% first we define a protocol for describing the characteristics of an engine: - -:- protocol(enginep). - - :- public(reference/1). - :- public(capacity/1). - :- public(cylinders/1). - :- public(horsepower_rpm/2). - :- public(bore_stroke/2). - :- public(fuel/1). - -:- end_protocol. - - -% second, we can define a typical engine as a category, which will be used -% when "assembling" cars: - -:- category(classic, - implements(enginep)). - - reference('M180.940'). - capacity(2195). - cylinders(6). - horsepower_rpm(94, 4800). - bore_stroke(80, 72.8). - fuel(gasoline). - -:- end_category. - - -% next, we define a souped up version of the previous engine, which differs -% from the standard one only in its reference and in its horsepower: - -:- category(sport, - imports(classic)). - - reference('M180.941'). - horsepower_rpm(110, 5000). - -:- end_category. - - -% with engines (and other components), we may start "assembling" some cars: - -:- object(sedan, - imports(classic)). - - -:- end_object. - - -:- object(coupe, - imports(sport)). - - -:- end_object. diff --git a/Logtalk/examples/engines/loader.lgt b/Logtalk/examples/engines/loader.lgt deleted file mode 100644 index 151353009..000000000 --- a/Logtalk/examples/engines/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(engines)). diff --git a/Logtalk/examples/errors/NOTES.txt b/Logtalk/examples/errors/NOTES.txt deleted file mode 100644 index 6d1caea58..000000000 --- a/Logtalk/examples/errors/NOTES.txt +++ /dev/null @@ -1,21 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example, please see the SCRIPT file. - -This folder contains examples of objects, categories, and protocols -containing errors that will trigger Logtalk compiler warnings and -errors. The goal of this example is to help the user to get acquainted -to the Logtalk compiler warning and error reporting. Open the object -source files in a text editor to better understand how the compiler -deals with common programming errors. - -Note that the warnings and errors that you will get while compiling -your source files depend on your compiler flags (defined explicitly -as parameters for the logtalk_compile/2 or logtalk_load/2 built-in -predicates or by default in your Prolog configuration file). diff --git a/Logtalk/examples/errors/SCRIPT.txt b/Logtalk/examples/errors/SCRIPT.txt deleted file mode 100644 index 42acce92d..000000000 --- a/Logtalk/examples/errors/SCRIPT.txt +++ /dev/null @@ -1,18 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -The entities on this example are divided in two sets. The first set -results on compiler warning messages, while the second set results -in compiler error messages. To load each sets of entities, compile -and load the corresponding loader files: - -| ?- logtalk_load(errors(warnings_loader)). -... - -| ?- logtalk_load(errors(errors_loader)). -... diff --git a/Logtalk/examples/errors/catdynpred.lgt b/Logtalk/examples/errors/catdynpred.lgt deleted file mode 100644 index 942c0002b..000000000 --- a/Logtalk/examples/errors/catdynpred.lgt +++ /dev/null @@ -1,13 +0,0 @@ - -:- category(catdynpred). - - % dynamic predicates may be declared inside categories but ... - :- public(dynpred/1). - :- dynamic(dynpred/1). - - % ... clauses for dynamic predicates are not allowed - dynpred(1). - dynpred(2). - dynpred(3). - -:- end_object. diff --git a/Logtalk/examples/errors/ccredef.lgt b/Logtalk/examples/errors/ccredef.lgt deleted file mode 100644 index 7d3bccd1b..000000000 --- a/Logtalk/examples/errors/ccredef.lgt +++ /dev/null @@ -1,7 +0,0 @@ - -:- object(ccredef). - - % Logtalk built-in control constructs cannot be redefined - ::(_). - -:- end_object. diff --git a/Logtalk/examples/errors/errors_loader.lgt b/Logtalk/examples/errors/errors_loader.lgt deleted file mode 100644 index 6e771a0be..000000000 --- a/Logtalk/examples/errors/errors_loader.lgt +++ /dev/null @@ -1,12 +0,0 @@ - -:- initialization(( - catch(logtalk_load(lgtmthdredef, [report(on)]), _, true), - catch(logtalk_load(invclause, [report(on)]), _, true), - catch(logtalk_load(unknowndir, [report(on)]), _, true), - catch(logtalk_load(noninstdir, [report(on)]), _, true), - catch(logtalk_load(invargdir, [report(on)]), _, true), - catch(logtalk_load(unmatchdir, [report(on)]), _, true), - catch(logtalk_load(catdynpred, [report(on)]), _, true), - catch(logtalk_load(ccredef, [report(on)]), _, true), - catch(logtalk_load(usesrepeated, [report(on)]), _, true), - catch(logtalk_load(usesconflict, [report(on)]), _, true))). diff --git a/Logtalk/examples/errors/invargdir.lgt b/Logtalk/examples/errors/invargdir.lgt deleted file mode 100644 index 5b3a03e57..000000000 --- a/Logtalk/examples/errors/invargdir.lgt +++ /dev/null @@ -1,7 +0,0 @@ - -:- object(invargdir). - - % invalid directive argument - :- public(1234). - -:- end_object. diff --git a/Logtalk/examples/errors/invclause.lgt b/Logtalk/examples/errors/invclause.lgt deleted file mode 100644 index 76ea71b94..000000000 --- a/Logtalk/examples/errors/invclause.lgt +++ /dev/null @@ -1,8 +0,0 @@ - -:- object(invclause). - - % invalid clause head - 1234 :- - write(hello). - -:- end_object. diff --git a/Logtalk/examples/errors/lgtmthdredef.lgt b/Logtalk/examples/errors/lgtmthdredef.lgt deleted file mode 100644 index 1063ae96d..000000000 --- a/Logtalk/examples/errors/lgtmthdredef.lgt +++ /dev/null @@ -1,7 +0,0 @@ - -:- object(lgtmthdredef). - - % Logtalk built-in methods cannot be redefined - asserta(_). - -:- end_object. diff --git a/Logtalk/examples/errors/noninstdir.lgt b/Logtalk/examples/errors/noninstdir.lgt deleted file mode 100644 index e5bdf0ee3..000000000 --- a/Logtalk/examples/errors/noninstdir.lgt +++ /dev/null @@ -1,7 +0,0 @@ - -:- object(noninstdir). - - % misspelt directive functor - :- Public(predicate/0). - -:- end_object. diff --git a/Logtalk/examples/errors/unknowndir.lgt b/Logtalk/examples/errors/unknowndir.lgt deleted file mode 100644 index 7c63f17dc..000000000 --- a/Logtalk/examples/errors/unknowndir.lgt +++ /dev/null @@ -1,7 +0,0 @@ - -:- object(unknowndir). - - % unknown directive - :- index(predicate/3, [1, 2]). - -:- end_object. diff --git a/Logtalk/examples/errors/unmatchdir.lgt b/Logtalk/examples/errors/unmatchdir.lgt deleted file mode 100644 index 88c77f581..000000000 --- a/Logtalk/examples/errors/unmatchdir.lgt +++ /dev/null @@ -1,7 +0,0 @@ - -% misspelt opening object directive - -:- objecto(unmatchdir). - - -:- end_object. diff --git a/Logtalk/examples/errors/usesconflict.lgt b/Logtalk/examples/errors/usesconflict.lgt deleted file mode 100644 index 45c1b2f7f..000000000 --- a/Logtalk/examples/errors/usesconflict.lgt +++ /dev/null @@ -1,12 +0,0 @@ - -% conflict between uses/2 directive and a predicate definition - -:-object(usesconflict). - - :- uses(list, [member/2]). - - member(H, [H| _]). % an object (or category) cannot define a - member(H, [_| T]) :- % predicate referenced on a uses/2 directive - member(H, T). - -:- end_object. diff --git a/Logtalk/examples/errors/usesrepeated.lgt b/Logtalk/examples/errors/usesrepeated.lgt deleted file mode 100644 index e05a05067..000000000 --- a/Logtalk/examples/errors/usesrepeated.lgt +++ /dev/null @@ -1,9 +0,0 @@ - -% conflict between uses/2 directives - -:-object(usesrepeated). - - :- uses(list, [member/2]). % a predicate cannot be referenced - :- uses(set, [member/2]). % in more than one uses/2 directive - -:- end_object. diff --git a/Logtalk/examples/errors/warnings.lgt b/Logtalk/examples/errors/warnings.lgt deleted file mode 100644 index f41fde5f3..000000000 --- a/Logtalk/examples/errors/warnings.lgt +++ /dev/null @@ -1,74 +0,0 @@ - -:- object(misspell). - - % call to an undefined but declared predicate - :- public(foo/0). - - output :- - foo. - - % call to an undefined local predicate - output(A) :- - bar(A). - - % misspelt call to Prolog built-in predicate - output(A) :- - writr(A). - -:- end_object. - - - -% singleton variables in opening object directive -:- object(singletons(L)). - - % singleton variables in predicate clause - predicate(A) :- - write(C). - -:- end_object. - - - -:- object(plredef). - - % redefinition of a Prolog built-in predicate - write(_). - -:- end_object. - - - -:- object(lgtredef). - - % redefinition of Logtalk built-in predicate - current_object(_). - -:- end_object. - - - -% references to unknown entities in object opening directive - -:- object(unknownrefs, - implements(protocol), - imports(category), - extends(object)). - - -:- end_object. - - - -:- object(portability). - - :- public(predicate/0). - - % clause with calls to non-ISO Prolog standard predicates - predicate :- - compare(Result, first, second), - retractall(result(Result, _)), - sort([], []), - consult(file). - -:- end_object. diff --git a/Logtalk/examples/errors/warnings_loader.lgt b/Logtalk/examples/errors/warnings_loader.lgt deleted file mode 100644 index 0f3e5b159..000000000 --- a/Logtalk/examples/errors/warnings_loader.lgt +++ /dev/null @@ -1,5 +0,0 @@ - -:- initialization( - logtalk_load( - warnings, - [unknown(warning), misspelt(warning), singletons(warning), plredef(warning), lgtredef(warning), portability(warning), report(on)])). diff --git a/Logtalk/examples/expansion/NOTES.txt b/Logtalk/examples/expansion/NOTES.txt deleted file mode 100644 index 4ae41d2a4..000000000 --- a/Logtalk/examples/expansion/NOTES.txt +++ /dev/null @@ -1,13 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT -file. - -For a description of this example, please see the comments in the -engines.lgt source file. diff --git a/Logtalk/examples/expansion/SCRIPT.txt b/Logtalk/examples/expansion/SCRIPT.txt deleted file mode 100644 index 1727b8707..000000000 --- a/Logtalk/examples/expansion/SCRIPT.txt +++ /dev/null @@ -1,45 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(expansion(loader)). -... - - -% simple tests of the expand_term/2 built-in method: - -| ?- exp_public::expand_term(8, Term). - -Term = eight -yes - -| ?- exp_protected::expand_term(8, Term). - -Term = 8 -yes - -| ?- exp_private::expand_term(8, Term). - -Term = 8 -yes - -| ?- desc_public::test(8, Term). - -Term = eight -yes - -| ?- desc_protected::test(8, Term). - -Term = eight -yes - -| ?- desc_private::test(8, Term). - -Term = 8 -yes \ No newline at end of file diff --git a/Logtalk/examples/expansion/expansion.lgt b/Logtalk/examples/expansion/expansion.lgt deleted file mode 100644 index 9f1b584c2..000000000 --- a/Logtalk/examples/expansion/expansion.lgt +++ /dev/null @@ -1,65 +0,0 @@ - -:- category(number_conversion, - implements(term_expansionp)). - - term_expansion(0, zero). - term_expansion(1, one). - term_expansion(2, two). - term_expansion(3, three). - term_expansion(4, four). - term_expansion(5, five). - term_expansion(6, six). - term_expansion(7, seven). - term_expansion(8, eight). - term_expansion(9, nine). - -:- end_category. - - -:- category(conversion_test). - - :- public(test/2). - - test(Term, Expansion) :- - expand_term(Term, Expansion). - -:- end_category. - - -:- object(exp_public, - imports(public::number_conversion)). - -:- end_object. - - -:- object(desc_public, - imports(conversion_test), - extends(exp_public)). - -:- end_object. - - -:- object(exp_protected, - imports(protected::number_conversion)). - -:- end_object. - - -:- object(desc_protected, - imports(conversion_test), - extends(exp_protected)). - -:- end_object. - - -:- object(exp_private, - imports(private::number_conversion)). - -:- end_object. - - -:- object(desc_private, - imports(conversion_test), - extends(exp_private)). - -:- end_object. diff --git a/Logtalk/examples/expansion/loader.lgt b/Logtalk/examples/expansion/loader.lgt deleted file mode 100644 index 346dac1b2..000000000 --- a/Logtalk/examples/expansion/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load([library(term_expansionp), expansion])). diff --git a/Logtalk/examples/hello_world/NOTES.txt b/Logtalk/examples/hello_world/NOTES.txt deleted file mode 100644 index 037c002c0..000000000 --- a/Logtalk/examples/hello_world/NOTES.txt +++ /dev/null @@ -1,13 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -No self-respected programming language could do without a "Hello -World" example! - -To load this example and for sample queries, please see the SCRIPT -file. diff --git a/Logtalk/examples/hello_world/SCRIPT.txt b/Logtalk/examples/hello_world/SCRIPT.txt deleted file mode 100644 index dc59c17a3..000000000 --- a/Logtalk/examples/hello_world/SCRIPT.txt +++ /dev/null @@ -1,12 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% just load the example and check the output message: - -| ?- logtalk_load(hello_world(loader)). -... diff --git a/Logtalk/examples/hello_world/hello_world.lgt b/Logtalk/examples/hello_world/hello_world.lgt deleted file mode 100644 index 0d0c0dea7..000000000 --- a/Logtalk/examples/hello_world/hello_world.lgt +++ /dev/null @@ -1,6 +0,0 @@ - -:- object(hello_world). - - :- initialization((nl, write('********** Hello World! **********'), nl)). - -:- end_object. diff --git a/Logtalk/examples/hello_world/loader.lgt b/Logtalk/examples/hello_world/loader.lgt deleted file mode 100644 index 3b20a03d1..000000000 --- a/Logtalk/examples/hello_world/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(hello_world)). diff --git a/Logtalk/examples/hooks/NOTES.txt b/Logtalk/examples/hooks/NOTES.txt deleted file mode 100644 index 6581e034a..000000000 --- a/Logtalk/examples/hooks/NOTES.txt +++ /dev/null @@ -1,13 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains a very simple example of using the Logtalk compiler -hook to expand author abbreviations in info/1 directives into full names -and email addresses. diff --git a/Logtalk/examples/hooks/SCRIPT.txt b/Logtalk/examples/hooks/SCRIPT.txt deleted file mode 100644 index b0e9f0bf0..000000000 --- a/Logtalk/examples/hooks/SCRIPT.txt +++ /dev/null @@ -1,15 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(hooks(loader)). -... - - -% check the XML documenting file generated for "object" diff --git a/Logtalk/examples/hooks/hook.lgt b/Logtalk/examples/hooks/hook.lgt deleted file mode 100644 index a3cc267c2..000000000 --- a/Logtalk/examples/hooks/hook.lgt +++ /dev/null @@ -1,30 +0,0 @@ - -:- object(hook). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2006/01/29, - comment is 'Example of an object defining compiler hook predicates.']). - - :- public(hook/2). - :- mode(hook(@nonvar, -list), zero_or_one). - :- info(hook/2, [ - comment is 'Compiler hook predicate.', - arguments is ['Term'-'Source file term', 'Terms'-'Resulting list of terms']]). - - hook((:- info(Original)), [(:- info(New))]) :- - expand_author(Original, New). - - expand_author([], []). - expand_author([Info| Infos], [Info2| Infos2]) :- - ( Info = (author is Abbreviation) -> - author(Abbreviation, FullName), - Info2 = (author is FullName) - ; Info = Info2 - ), - expand_author(Infos, Infos2). - - author(pm, 'Paulo Moura, pmoura@logtalk.org'). - -:- end_object. diff --git a/Logtalk/examples/hooks/loader.lgt b/Logtalk/examples/hooks/loader.lgt deleted file mode 100644 index 7cad01d23..000000000 --- a/Logtalk/examples/hooks/loader.lgt +++ /dev/null @@ -1,4 +0,0 @@ - -:- initialization(( - logtalk_load(hook), - logtalk_load(object, [hook(hook::hook), xmldocs(on)]))). diff --git a/Logtalk/examples/hooks/object.lgt b/Logtalk/examples/hooks/object.lgt deleted file mode 100644 index cf010d4c4..000000000 --- a/Logtalk/examples/hooks/object.lgt +++ /dev/null @@ -1,10 +0,0 @@ - -:- object(object). - - :- info([ - version is 1.0, - author is pm, - date is 2006/01/29, - comment is 'Example object for illustrating the use of compiler hooks.']). - -:- end_object. diff --git a/Logtalk/examples/inheritance/NOTES.txt b/Logtalk/examples/inheritance/NOTES.txt deleted file mode 100644 index e859bef13..000000000 --- a/Logtalk/examples/inheritance/NOTES.txt +++ /dev/null @@ -1,39 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains examples of public, protected, and private inheritance, -for both prototype-based and class-based hierarchies. - -This example defines a category named "predicates" which specifies three -predicates, one public, one protected, and one private. This category is -imported by the root objects: "parent" for the prototype hierarchy and -"root" for the class hierarchy. Each root object have a set of three -descendants, each one using one of the inheritance types. - -The two object hierarchies are organized as follows: - - parent - prototype1 % public inheritance - descendant1 - prototype2 % protected inheritance - descendant2 - prototype3 % private inheritance - descendant3 - - root - subclass1 % public inheritance - instance1 - subclass2 % protected inheritance - instance2 - subclass3 % private inheritance - instance3 - -A second category named "interface", imported by all objects except the -sub-class instances, allows us to query the objects about their interfaces. diff --git a/Logtalk/examples/inheritance/SCRIPT.txt b/Logtalk/examples/inheritance/SCRIPT.txt deleted file mode 100644 index a370077e4..000000000 --- a/Logtalk/examples/inheritance/SCRIPT.txt +++ /dev/null @@ -1,121 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(inheritance(loader)). -... - - -% parent interface - -| ?- parent::interface. - -public/0 - public -protected/0 - protected -private/0 - private - -yes - - -% prototype1 extends public::parent - -| ?- prototype1::interface. - -public/0 - public -protected/0 - protected - -yes - - -% prototype2 extends protected::parent - -| ?- prototype2::interface. - -public/0 - protected -protected/0 - protected - -yes - - -% prototype3 extends private::parent - -| ?- prototype3::interface. - -public/0 - private -protected/0 - private - -yes - - -% descendant1 extends public::prototype1 - -| ?- descendant1::interface. - -public/0 - public -protected/0 - protected - -yes - - -% descendant2 extends public::prototype2 - -| ?- descendant2::interface. - -public/0 - protected -protected/0 - protected - -yes - - -% descendant3 extends public::prototype3 - -| ?- descendant3::interface. - -yes - - -% object (root of the inheritance graph) interface - -| ?- root::interface. - -public/0 - public -protected/0 - protected -private/0 - private - -yes - - -% instance1 instantiates subclass1 that specializes public::root - -| ?- instance1::interface. - -public/0 - public -protected/0 - protected - -yes - - -% instance2 instantiates subclass2 that specializes protected::root - -| ?- instance2::interface. - -public/0 - protected -protected/0 - protected - -yes - - -% instance3 instantiates subclass3 that specializes private::root - -| ?- instance3::interface. - -public/0 - private -protected/0 - private - -yes diff --git a/Logtalk/examples/inheritance/classes.lgt b/Logtalk/examples/inheritance/classes.lgt deleted file mode 100644 index 726e62a1c..000000000 --- a/Logtalk/examples/inheritance/classes.lgt +++ /dev/null @@ -1,71 +0,0 @@ -/* -This source file defines the following class-based hierarchy: - - root - subclass1 - instance1 - subclass2 - instance2 - subclass3 - instance3 - -The root object imports the category "predicates", which defines one -public predicate, public/0, one protected predicate, protected/0, and -one private predicate, private/0. - -All objects import the category "interface", which defines a predicate, -interface/0, for listing the object interface. -*/ - - -:- object(root, - imports(predicates, interface), - instantiates(root)). - - -:- end_object. - - -% public inheritance: -% root predicates will be inherited without scope changes -:- object(subclass1, - imports(interface), - specializes(public::root)). - -:- end_object. - - -:- object(instance1, - instantiates(subclass1)). - -:- end_object. - - -% protected inheritance: -% root public predicates will be inherited as protected predicates -:- object(subclass2, - imports(interface), - specializes(protected::root)). - -:- end_object. - - -:- object(instance2, - instantiates(subclass2)). - -:- end_object. - - -% private inheritance: -% root predicates will be inherited as private predicates -:- object(subclass3, - imports(interface), - specializes(private::root)). - -:- end_object. - - -:- object(instance3, - instantiates(subclass3)). - -:- end_object. diff --git a/Logtalk/examples/inheritance/interface.lgt b/Logtalk/examples/inheritance/interface.lgt deleted file mode 100644 index e7a3b6913..000000000 --- a/Logtalk/examples/inheritance/interface.lgt +++ /dev/null @@ -1,28 +0,0 @@ -/* -This category defines a predicate, interface/0, that prints an object -interface, i.e. predicate names and the corresponding scope properties. - -We need to encapsulate the interface/0 predicate in a category instead -of just defining it in a root object in order to be able to list private -object predicates. -*/ - -:- category(interface). - - :- public(interface/0). - :- mode(interface, one). - - interface :- - forall( - (::current_predicate(Functor/Arity), - functor(Pred, Functor, Arity), - Pred \= interface), - (::predicate_property(Pred, Prop), - scope_property(Prop), % we are only interested on scope properties - writeq(Functor/Arity), write(' - '), writeq(Prop), nl)). - - scope_property(public). - scope_property(protected). - scope_property(private). - -:- end_category. diff --git a/Logtalk/examples/inheritance/loader.lgt b/Logtalk/examples/inheritance/loader.lgt deleted file mode 100644 index e34f0fc77..000000000 --- a/Logtalk/examples/inheritance/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load([predicates, interface, prototypes, classes])). diff --git a/Logtalk/examples/inheritance/predicates.lgt b/Logtalk/examples/inheritance/predicates.lgt deleted file mode 100644 index 378aacadb..000000000 --- a/Logtalk/examples/inheritance/predicates.lgt +++ /dev/null @@ -1,27 +0,0 @@ -/* -This category defines a set of predicates, which are imported by the -roots of both the class-based and the prototype-based hierarchies of -this example. -*/ - -:- category(predicates). - - :- public(public/0). - :- mode(public, one). - - :- protected(protected/0). - :- mode(protected, one). - - :- private(private/0). - :- mode(private, one). - - public :- - write('Public predicate declared and defined in category "predicates".'), nl. - - protected :- - write('Protected predicate declared and defined in category "predicates".'), nl. - - private :- - write('Private predicate declared and defined in category "predicates".'), nl. - -:- end_category. diff --git a/Logtalk/examples/inheritance/prototypes.lgt b/Logtalk/examples/inheritance/prototypes.lgt deleted file mode 100644 index 06f62d67e..000000000 --- a/Logtalk/examples/inheritance/prototypes.lgt +++ /dev/null @@ -1,72 +0,0 @@ -/* -This source file defines the following prototype-based hierarchy: - - parent - prototype1 - descendant1 - prototype2 - descendant2 - prototype3 - descendant3 - -The root object imports the category "predicates", which defines one -public predicate, public/0, one protected predicate, protected/0, and -one private predicate, private/0. - -All objects import the category "interface", which defines a predicate, -interface/0, for listing the object interface. -*/ - - -:- object(parent, - imports(predicates, interface)). - -:- end_object. - - -% public inheritance: -% parent predicates will be inherited without scope changes -:- object(prototype1, - imports(interface), - extends(public::parent)). - -:- end_object. - - -:- object(descendant1, - imports(interface), - extends(prototype1)). - -:- end_object. - - -% protected inheritance: -% parent public predicates will be inherited as protected predicates -:- object(prototype2, - imports(interface), - extends(protected::parent)). - -:- end_object. - - -:- object(descendant2, - imports(interface), - extends(prototype2)). - -:- end_object. - - -% private inheritance: -% parent predicates will be inherited as private predicates -:- object(prototype3, - imports(interface), - extends(private::parent)). - -:- end_object. - - -:- object(descendant3, - imports(interface), - extends(prototype3)). - -:- end_object. diff --git a/Logtalk/examples/instmethods/NOTES.txt b/Logtalk/examples/instmethods/NOTES.txt deleted file mode 100644 index c27ec1802..000000000 --- a/Logtalk/examples/instmethods/NOTES.txt +++ /dev/null @@ -1,28 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains an example of instance defined methods. When using -classes and instances, methods must be declared in a class but the method -definitions may be stored in the instances, either overriding or specializing -the class definitions. - -This example defines the following objects: - - root - root class defining a method named method/0 - - instance1 - simple instance of root inheriting method/0 - - instance2 - instance of root overriding the inherited method method/0 - - instance3 - instance of root specializing the inherited method method/0 diff --git a/Logtalk/examples/instmethods/SCRIPT.txt b/Logtalk/examples/instmethods/SCRIPT.txt deleted file mode 100644 index 221752a49..000000000 --- a/Logtalk/examples/instmethods/SCRIPT.txt +++ /dev/null @@ -1,42 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(instmethods(loader)). -... - - -% instance1 definition for method "method" is found in its class: - -| ?- instance1::method. - -This is the default definition for the method, stored in class root. - -yes - - -% instance2 overrides definition of method "method" - -| ?- instance2::method. - -This is an overriding definition stored in the instance2 instance itself. - -yes - - -% instance3 specializes definition of method "method" - -| ?- instance3::method. - -This is a specializing definition stored in the instance3 instance itself. -It makes a super call to execute the default definition: - -This is the default definition for the method, stored in class root. - -yes diff --git a/Logtalk/examples/instmethods/instmethods.lgt b/Logtalk/examples/instmethods/instmethods.lgt deleted file mode 100644 index f856353e8..000000000 --- a/Logtalk/examples/instmethods/instmethods.lgt +++ /dev/null @@ -1,47 +0,0 @@ - -:- object(root, % avoid infinite metaclass regression by - instantiates(root)). % making the class its own metaclass - - :- public(method/0). - - method :- - this(This), - write('This is the default definition for the method, stored in class '), - writeq(This), write('.'), nl. - -:- end_object. - - - -:- object(instance1, % this instance simply inherits the method/0 predicate - instantiates(root)). - -:- end_object. - - - -:- object(instance2, % this instance provides its own definition for the - instantiates(root)). % method/0 predicate - - method :- - this(This), - write('This is an overriding definition stored in the '), - writeq(This), - write(' instance itself.'), nl. - -:- end_object. - - - -:- object(instance3, % this instance specializes the inherited definition - instantiates(root)). % of the method/0 predicate - - method :- - this(This), - write('This is a specializing definition stored in the '), - writeq(This), - write(' instance itself.'), nl, - write('It makes a super call to execute the default definition:'), nl, nl, - ^^method. - -:- end_object. diff --git a/Logtalk/examples/instmethods/loader.lgt b/Logtalk/examples/instmethods/loader.lgt deleted file mode 100644 index 129fa34f4..000000000 --- a/Logtalk/examples/instmethods/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(instmethods)). diff --git a/Logtalk/examples/lo/NOTES.txt b/Logtalk/examples/lo/NOTES.txt deleted file mode 100644 index b7fa737b3..000000000 --- a/Logtalk/examples/lo/NOTES.txt +++ /dev/null @@ -1,16 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -The examples in this folder are adopted from the Logic&Objects system -by Francis G. McCabe. Detailed descriptions and the original source -code can be found on the McCabe's "Logic and Objects" book, published -by Prentice Hall. - -Note that, as Logtalk lacks the functional notation found on the -Logic&Objects system, my adaptation of the book examples may have -introduced some bugs not present in the original code. diff --git a/Logtalk/examples/lo/planner/NOTES.txt b/Logtalk/examples/lo/planner/NOTES.txt deleted file mode 100644 index 1ed2ccb62..000000000 --- a/Logtalk/examples/lo/planner/NOTES.txt +++ /dev/null @@ -1,10 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT -file. diff --git a/Logtalk/examples/lo/planner/SCRIPT.txt b/Logtalk/examples/lo/planner/SCRIPT.txt deleted file mode 100644 index a26e3c02c..000000000 --- a/Logtalk/examples/lo/planner/SCRIPT.txt +++ /dev/null @@ -1,21 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(lo_planner(loader)). -... - - -% plan a trip from london to the aiai conference in edinburgh: - -| ?- plan(london)::from(imperial, aiai, L). - -L = [[taxi(imperial,lhr)]-[fly(lhr,edin)]-[taxi(edin,aiai)]] ? - -yes diff --git a/Logtalk/examples/lo/planner/loader.lgt b/Logtalk/examples/lo/planner/loader.lgt deleted file mode 100644 index ff97594d2..000000000 --- a/Logtalk/examples/lo/planner/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(planner)). diff --git a/Logtalk/examples/lo/planner/planner.lgt b/Logtalk/examples/lo/planner/planner.lgt deleted file mode 100644 index d273fe7e8..000000000 --- a/Logtalk/examples/lo/planner/planner.lgt +++ /dev/null @@ -1,211 +0,0 @@ - -% Planner - -:- object(plan(_)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Air-line trip planner.', - parnames is ['Mode'], - source is 'Example adopted from the Francis G. McCabe L&O documentation.']). - - :- public(from/3). - :- mode(from(+atom, +atom, -list), zero_or_more). - :- info(from/3, - [comment is 'Plan a trip from Start to Destination.', - argnames is ['Start', 'Destination', 'Plan']]). - - from(Start, Destination, Plan) :- - from(Start, Destination, [], Plan). - - from(Start, Destination, _, [Step]) :- - parameter(1, Mode), - Mode::step(Start, Destination, Step), - !. - from(Start, Destination, Locations, [Step| Steps]) :- - parameter(1, Mode), - Mode::step(Start, City2, Step), - not_member(City2, Locations), - from(City2, Destination, [Start| Locations], Steps). - - not_member(_, []). - not_member(City, [Location| Locations]) :- - City \= Location, - not_member(City, Locations). - -:- end_object. - - - -% Abstractions of City, Airport, and Flight - -:- object(city). - - :- public(step/3). - :- mode(step(+, +, -), zero_or_more). - - :- public(airport/1). - :- mode(airport(?atom), zero_or_more). - - step(X, Y, P1-P-P2) :- - \+ same_city(X, Y), !, - X::airport(XA), - Y::airport(YA), - plan(fly)::from(XA, YA, P), - plan(city)::from(X, XA, P1), - plan(city)::from(YA, Y, P2). - - step(X, Y, taxi(X, Y)) :- - same_city(X, Y), - X \= Y. - - same_city(X, Y) :- - X::airport(A), - Y::airport(A). - -:- end_object. - - -:- object(airport). - - :- public(fly/1). - :- mode(fly(?), zero_or_more). - - :- public(airport/1). - :- mode(airport(?), zero_or_more). - - airport(Airport) :- - self(Airport). - -:- end_object. - - -:- object(fly). - - :- public(step/3). - :- mode(step(+, +, -), zero_or_more). - - step(From, To, fly(From, To)) :- - From::fly(To). - -:- end_object. - - - -% Edinburgh locations - -:- object(edinburgh, - extends(city)). - - airport(edin). - -:- end_object. - - -:- object(edin, - extends(edinburgh)). - -:- end_object. - - -:- object(castle, - extends(edinburgh)). - -:- end_object. - - -:- object(aiai, - extends(edinburgh)). - -:- end_object. - - - -% Glasgow locations - -:- object(glasgow, - extends(city)). - - airport(renfrew). - -:- end_object. - - - -% London locations - -:- object(london, - extends(city)). - - airport(lhr). - -:- end_object. - - -:- object(albert_hall, - extends(london)). - -:- end_object. - - -:- object(imperial, - extends(london)). - -:- end_object. - - - -% Manchester locations - -:- object(manchester, - extends(city)). - - airport(ringway). - -:- end_object. - - -:- object(victoria, - extends(manchester)). - -:- end_object. - - - -% Airports - -:- object(aberdeen_air, - extends(airport)). - - fly(renfrew). - -:- end_object. - - -:- object(lhr, - extends(airport)). - - fly(edin). - fly(ringway). - -:- end_object. - - -:- object(renfrew, - extends(airport)). - - fly(aberdeen_air). - fly(ringway). - -:- end_object. - - -:- object(ringway, - extends(manchester, airport)). - - fly(lhr). - fly(renfrew). - -:- end_object. diff --git a/Logtalk/examples/lo/travellers/NOTES.txt b/Logtalk/examples/lo/travellers/NOTES.txt deleted file mode 100644 index 1ed2ccb62..000000000 --- a/Logtalk/examples/lo/travellers/NOTES.txt +++ /dev/null @@ -1,10 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT -file. diff --git a/Logtalk/examples/lo/travellers/SCRIPT.txt b/Logtalk/examples/lo/travellers/SCRIPT.txt deleted file mode 100644 index 99655065b..000000000 --- a/Logtalk/examples/lo/travellers/SCRIPT.txt +++ /dev/null @@ -1,44 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(lo_travellers(loader)). -... - - -% build a route by adding one town at a time: - -| ?- incremental::route([london, brighton, portsmouth, exeter, oxford, aberystwyth], Route). - -Route = oxford-london-portsmouth-brighton-exeter-aberystwyth ? -yes - - -% presort towns by geographical distance before using the incremental algorithm: - -| ?- presort::route([london, brighton, portsmouth, exeter, oxford, aberystwyth], Route). - -Route = brighton-london-oxford-portsmouth-exeter-aberystwyth ? -yes - - -% come home after the journey: - -| ?- circular::route([london, brighton, portsmouth, exeter, oxford, aberystwyth], Route). - -Route = london-brighton-portsmouth-exeter-aberystwyth-oxford-london ? -yes - - -% blind search by generating permutations of the list of towns: - -| ?- permute::route([london, brighton, portsmouth, exeter, oxford, aberystwyth], Route). - -Route = (aberystwyth-exeter-portsmouth-brighton-london-oxford,273.6237583942784) ? -yes diff --git a/Logtalk/examples/lo/travellers/loader.lgt b/Logtalk/examples/lo/travellers/loader.lgt deleted file mode 100644 index fa228c8d9..000000000 --- a/Logtalk/examples/lo/travellers/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load([sorting, towns, salesman])). diff --git a/Logtalk/examples/lo/travellers/salesman.lgt b/Logtalk/examples/lo/travellers/salesman.lgt deleted file mode 100644 index d1b6dc05b..000000000 --- a/Logtalk/examples/lo/travellers/salesman.lgt +++ /dev/null @@ -1,273 +0,0 @@ - -:- object(salesman). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is '.', - source is 'Example adopted from the Francis G. McCabe L&O documentation.']). - - :- public(route/2). - :- mode(route(+list, -nonvar), zero_or_more). - -:- end_object. - - - -:- object(circular, - extends(salesman)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is '.', - source is 'Example adopted from the Francis G. McCabe L&O documentation.']). - - route([Town| Towns], Route) :- - route(Towns, Town-Town, Route). - - route([], Route, Route). - route([Town| Towns], Route, Route2) :- - best_place(Route, Town, Best), - split(Best, Route, Town, Split), - route(Towns, Split, Route2). - - best_place(Route, Town, Best) :- - best_place(Route, Town, 10000000, 0, 0, Best). - - best_place(R-T1-T2, Town, XD, _, I, Best) :- - atom(T1), - atom(T2), - extra(T1, Town, T2, XT), - XT < XD, - I2 is I + 1, - best_place(R-T1, Town, XT, I2, I2, Best). - best_place(R-T1-T2, Town, XD, XI, I, Best) :- - atom(T1), - atom(T2), - I2 is I + 1, - best_place(R-T1, Town, XD, XI, I2, Best). - best_place(T1-T2, Town, XD, _, I, Best) :- - atom(T1), - atom(T2), - extra(T1, Town, T2, XT), - XT < XD, - Best is I + 1. - best_place(_-_, _, _, XI, _, XI). - - split(0, Route, Town, Route-Town). - split(IX, Route-Town1, Town, Split-Town1) :- - IX2 is IX - 1, - split(IX2, Route, Town, Split). - split(1, Route, Town, Town-Route). - - extra(T1, T, T2, E) :- - T1::crow_flies(T, E1), - T::crow_flies(T2, E2), - T1::crow_flies(T2, E3), - E is E1 + E2 - E3. - -:- end_object. - - - -:- object(incremental, - extends(salesman)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is '.', - source is 'Example adopted from the Francis G. McCabe L&O documentation.']). - - route([Town| Towns], Route) :- - route(Towns, Town, Route). - - route([], Route, Route). - route([Town| Towns], Route, Route2) :- - best_place(Route, Town, Best), - split(Best, Route, Town, NewR), - route(Towns, NewR, Route2). - - best_place(Route-Town1, Town, Best) :- % try the back first ... - atom(Town1), - Town::crow_flies(Town1, Distance), - best_place(Route-Town1, Town, Distance, 0, 0, Best). - best_place(Town, _, 0) :- - atom(Town). - - best_place(R-T1-T2, T, XD, _, I, Best) :- - atom(T1), - atom(T2), - extra(T1, T, T2, XT), - XT < XD, - I2 is I + 1, - best_place(R-T1, T, XT, I2, I2, Best). - best_place(R-T1-T2, T, XD, XI, I, Best) :- - atom(T1), - atom(T2), - I2 is I + 1, - best_place(R-T1, T, XD, XI, I2, Best). - best_place(T1-T2, T, XD, _, I, Best) :- - atom(T1), - atom(T2), - extra(T1, T, T2, XT), - XT < XD, - I2 is I + 1, - best_place(T1, T, XT, I2, I2, Best). - best_place(T1-T2, T, XD, XI, I, Best) :- - atom(T1), - atom(T2), - I2 is I + 1, - best_place(T1, T, XD, XI, I2, Best). - best_place(T1, T, XD, _, I, Best) :- - atom(T1), - T1::crow_flies(T, Distance), - Distance < XD, - Best is I + 1. - best_place(_, _, _, XI, _, XI). - - split(0, Route, Town, Route-Town). - split(IX, Route-Town1, Town, S-Town1) :- - IX2 is IX -1, - split(IX2, Route, Town, S). - split(1, Route, Town, Town-Route). - - extra(T1, T, T2, XT) :- - T1::crow_flies(T, Distance1), - T::crow_flies(T2, Distance2), - T1::crow_flies(T2, Distance3), - XT is Distance1 + Distance2 - Distance3. - -:- end_object. - - - -:- object(presort, - extends(incremental)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is '.', - source is 'Example adopted from the Francis G. McCabe L&O documentation.']). - - :- uses(quick(_)). - - route(Towns, Route) :- - arrange(Towns, Towns2), - ^^route(Towns2, Route). - - arrange(Towns, Sorted) :- - centre(Towns, X, Y), - quick(geographic(X, Y))::sort(Towns, Sorted). - - centre(Towns, X, Y) :- - average(Towns, 0, 0, U, V, 0, L), - X is U/L, - Y is V/L. - - average([], U, V, U, V, L, L). - average([Town| Towns], UX, VX, U, V, I, L):- - Town::at(UT, VT), - UX2 is UX+UT, - VX2 is VX+VT, - I2 is I + 1, - average(Towns, UX2, VX2, U, V, I2, L). - -:- end_object. - - - -:- object(driving, - extends(salesman)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is '.', - source is 'Example adopted from the Francis G. McCabe L&O documentation.']). - - route(Towns, Route) :- - presort::route(Towns, Presort), - drive_around(Presort, Route). - - drive_around(Route-Town1-Town2, Route1-Route2) :- - !, - drive_around(Route-Town1, Route1), - Town1::drive(Town2, Route2). - drive_around(Town1-Town2, Route) :- - !, - Town1::drive(Town2, Route). - drive_around(Town, Town). - - drive_length(Route, Length) :- - drive_length(Route, 0, Length). - - drive_length(Route-Town1-Town2, Acc, Length) :- - !, - Town1::road_distance(Town2, Length2), - Acc2 is Acc + Length2, - drive_length(Route-Town1, Acc2, Length). - drive_length(Town1-Town2, Acc, Length) :- - !, - Town1::road_distance(Town2, Length2), - Length is Acc + Length2. - drive_length(_, Length, Length). - -:- end_object. - - - -:- object(permute, - extends(salesman)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is '.', - source is 'Example adopted from the Francis G. McCabe L&O documentation.']). - - route(Towns, Route) :- - findall( - (Towns2, Length), - (permute(Towns, Towns2), route_length(Towns2, Length)), - List), - shortest(List, Route). - - permute([Town], Town). - permute(Towns, Towns2-Town) :- - delete(Towns, Town, Towns3), - permute(Towns3, Towns2). - - delete([Head| Tail], Head, Tail). - delete([Head| Tail], Element, [Head| Tail2]):- - delete(Tail, Element, Tail2). - - route_length(Town, 0) :- - atom(Town), !. - route_length(Towns-Town1-Town2, Length) :- - !, - route_length(Towns-Town1, Length1), - Town1::crow_flies(Town2, Length2), - Length is Length1 + Length2. - route_length(Town1-Town2, Length) :- - Town1::crow_flies(Town2, Length). - - shortest(List, Shortest) :- - shortest(List, null, 1000000, Shortest). - - shortest([], Route, Length, (Route, Length)). - shortest([(Route, Length)| Routes], _, LX, Shortest) :- - Length < LX, !, - shortest(Routes, Route, Length, Shortest). - shortest([_| Routes], RX, LX, Shortest) :- - shortest(Routes, RX, LX, Shortest). - -:- end_object. diff --git a/Logtalk/examples/lo/travellers/sorting.lgt b/Logtalk/examples/lo/travellers/sorting.lgt deleted file mode 100644 index d0d2caa11..000000000 --- a/Logtalk/examples/lo/travellers/sorting.lgt +++ /dev/null @@ -1,153 +0,0 @@ - -:- object(quick(_Order)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - parnames is ['Order'], - comment is '.', - source is 'Example adopted from the Francis G. McCabe L&O documentation.']). - - :- public(sort/2). - :- mode(sort(+list, -list), one). - - sort([], []). - sort([X| L], S):- - split(L, X, L1, L2), - sort(L1, S1), - sort(L2, S2), - app(S1, [X| S2], S). - - split([], _, [], []). - split([D| L], X, [D| L1], L2):- - parameter(1, Order), - Order::less(D, X), - !, - split(L, X, L1, L2). - split([D| L], X, L1, [D| L2]):- - split(L, X, L1, L2). - - app([], L, L). - app([H| T], L, [H| T2]) :- - app(T, L, T2). - -:- end_object. - - - -:- object(descend). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is '.', - source is 'Example adopted from the Francis G. McCabe L&O documentation.']). - - :- public(less/2). - - less(X, Y):- - X >= Y. - -:- end_object. - - -:- object(natural). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is '.', - source is 'Example adopted from the Francis G. McCabe L&O documentation.']). - - :- public(less/2). - - less(X, Y):- - X < Y. - -:- end_object. - - -:- object(geographic(_OX, _OY)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - parnames is ['OX', 'OY'], - comment is '.', - source is 'Example adopted from the Francis G. McCabe L&O documentation.']). - - :- public(less/2). - - less(Town1, Town2):- - angle(Town1, Angle1), - angle(Town2, Angle2), - Angle1 < Angle2. - - angle(Town, Angle) :- - Town::at(X, Y), - parameter(1, OX), - parameter(2, OY), - angle(X, Y, OX, OY, Angle). - - angle(X, Y, OX, OY, Angle) :- - X > OX, - Y >= OY, - Angle is atan((Y-OY)/(X-OX)). - - angle(X, Y, OX, OY, Angle) :- - X > OX, - Y < OY, - pi(Pi), - Angle is Pi + Pi - atan((OY-Y)/(X-OX)). - - angle(X, Y, OX, OY, Angle) :- - X < OX, - Y >= OY, - pi(Pi), - Angle is Pi - atan((Y-OY)/(OX-X)). - - angle(X, Y, OX, OY, Angle) :- - X < OX, - Y < OY, - pi(Pi), - Angle is Pi + atan((OY-Y)/(OX-X)). - - angle(OX, Y, OX, OY, Angle) :- - Y > OY, - pi(Pi), - Angle is Pi / 2. - - angle(OX, Y, OX, OY, Angle) :- - Y =< OY, - pi(Pi), - Angle is 1.5 * Pi. - - pi(Pi) :- - Pi is 4.0*atan(1.0). - -:- end_object. - - -:- object(metric(_Town)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is '.', - parnames is ['Town'], - source is 'Example adopted from the Francis G. McCabe L&O documentation.']). - - :- public(less/2). - - less((Town1, _), (Town2, _)):- - parameter(1, Town), - Town::crow_flies(Town1, Distance1), - Town::crow_flies(Town2, Distance2), - Distance1 < Distance2. - -:- end_object. diff --git a/Logtalk/examples/lo/travellers/towns.lgt b/Logtalk/examples/lo/travellers/towns.lgt deleted file mode 100644 index 526dfa98f..000000000 --- a/Logtalk/examples/lo/travellers/towns.lgt +++ /dev/null @@ -1,351 +0,0 @@ - -:- object(location(_X, _Y)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - parnames is ['X', 'Y'], - comment is '.', - source is 'Example adopted from the Francis G. McCabe L&O documentation.']). - - :- public(at/2). - :- mode(at(-integer, -integer), one). - - :- public(crow_flies/2). - :- mode(crow_flies(+atom, -integer), one). - - :- public(drive/2). - :- mode(drive(+atom, -nonvar), zero_or_more). - - :- public(links/1). - :- mode(links(-list), one). - - :- public(road_distance/2). - :- mode(road_distance(?atom, ?integer), zero_or_more). - - at(X, Y) :- - parameter(1, X), - parameter(2, Y). - - crow_flies(Town, Distance) :- - ::at(X, Y), - Town::at(U, V), - U0 is U-X, - V0 is V-Y, - Distance is sqrt(U0*U0+V0*V0). - - road_distance(Town, Distance) :- - ::links(Links), - member((Town, Distance), Links). - - drive(To, Route) :- % plan a road journey - self(Self), - plan_drive(Self, To, [], _, Route). - - % go directly - plan_drive(From, To, _, Distance, From-To):- - To::links(Links), - member((From, Distance), Links). - - % go indirectly - plan_drive(From, To, R, D+DI, Route-To):- - To::links(Links), - nearest(Links, From, Int, DI), - \+ member(Int, R), - plan_drive(From, Int, [To| R], D, Route). - - nearest(Links, To, Int, Distance):- - quick(metric(To))::sort(Links, Sorted), - member((Int, Distance), Sorted). - - member(Head, [Head| _]). - member(Head, [_| Tail]) :- - member(Head, Tail). - -:- end_object. - - - -:- object(aberdeen, - extends(location(194, 340))). - - links([ - (edinburgh, 115), - (glasgow, 142)]). - -:- end_object. - - -:- object(aberystwyth, - extends(location(126, 102))). - - links([ - (birmingham, 114), - (liverpool, 100), - (swansea, 75)]). - -:- end_object. - - -:- object(birmingham, - extends(location(192, 106))). - - links([ - (aberystwyth, 114), - (bristol, 86), - (cambridge, 97), - (liverpool, 99), - (nottingham, 48), - (oxford, 63), - (sheffield, 75)]). - -:- end_object. - - -:- object(brighton, - extends(location(248, 10))). - - links([ - (dover, 81), - (portsmouth, 49), - (london, 52)]). - -:- end_object. - - -:- object(bristol, - extends(location(168, 47))). - - links([ - (cardiff, 44), - (exeter, 76), - (oxford, 71), - (birmingham, 86)]). - -:- end_object. - - -:- object(cambridge, - extends(location(254, 92))). - - links([ - (nottingham, 82), - (oxford, 80), - (london, 54), - (birmingham, 97)]). - -:- end_object. - - -:- object(cardiff, - extends(location(148, 56))). - - links([ - (bristol, 44), - (swansea, 45)]). - -:- end_object. - - -:- object(carlisle, - extends(location(166, 226))). - - links([ - (glasgow, 94), - (leeds, 117), - (newcastle, 58)]). - -:- end_object. - - -:- object(dover, - extends(location(292, 38))). - - links([ - (brighton, 81), - (london, 71)]). - -:- end_object. - - -:- object(edinburgh, - extends(location(162, 282))). - - links([ - (aberdeen, 115), - (glasgow, 44), - (newcastle, 104)]). - -:- end_object. - - -:- object(exeter, - extends(location(138, 18))). - - links([ - (bristol, 76), - (penzance, 112), - (portsmouth, 126)]). - -:- end_object. - - -:- object(glasgow, - extends(location(132, 273))). - - links([ - (aberdeen, 142), - (carlisle, 94), - (edinburgh, 44)]). - -:- end_object. - - -:- object(hull, - extends(location(240, 168))). - - links([ - (leeds, 58), - (sheffield, 65), - (york, 37)]). - -:- end_object. - - -:- object(leeds, - extends(location(208, 170))). - - links([ - (carlisle, 117), - (hull, 58), - (sheffield, 34), - (manchester, 41), - (york, 23)]). - -:- end_object. - - -:- object(liverpool, - extends(location(164, 150))). - - links([ - (aberystwyth, 100), - (birmingham, 99), - (manchester, 35), - (sheffield, 70)]). - -:- end_object. - - -:- object(london, - extends(location(244,54))). - - links([ - (brighton, 52), - (dover, 71), - (cambridge, 54), - (oxford, 57), - (portsmouth, 72)]). - -:- end_object. - - -:- object(manchester, - extends(location(180, 156))). - - links([ - (leeds, 41), - (liverpool, 35), - (sheffield, 38)]). - -:- end_object. - - -:- object(newcastle, - extends(location(210, 230))). - - links([ - (edinburgh, 104), - (carlisle, 58), - (york, 80)]). - -:- end_object. - - -:- object(nottingham, - extends(location(216, 128))). - - links([ - (birmingham, 48), - (cambridge, 82), - (sheffield, 38)]). - -:- end_object. - - -:- object(oxford, - extends(location(214, 66))). - - links([ - (bristol, 71), - (birmingham, 63), - (cambridge, 80), - (london, 57)]). - -:- end_object. - - -:- object(penzance, - extends(location(10, 0))). - - links([( - exeter, 112)]). - -:- end_object. - - -:- object(portsmouth, - extends(location(216, 22))). - - links([ - (brighton, 49), - (exeter, 126), - (london, 72)]). - -:- end_object. - - -:- object(sheffield, - extends(location(208, 142))). - - links([ - (birmingham, 75), - (hull, 65), - (leeds, 34), - (liverpool, 70), - (manchester, 38), - (nottingham, 38)]). - -:- end_object. - - -:- object(swansea, - extends(location(126, 66))). - - links([ - (cardiff, 45), - (aberystwyth, 75)]). - -:- end_object. - - -:- object(york, - extends(location(218, 184))). - - links([ - (leeds, 23), - (hull, 37), - (newcastle, 80)]). - -:- end_object. diff --git a/Logtalk/examples/logic/NOTES.txt b/Logtalk/examples/logic/NOTES.txt deleted file mode 100644 index d1442ff06..000000000 --- a/Logtalk/examples/logic/NOTES.txt +++ /dev/null @@ -1,35 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT -file. - -This folder contains an object which implements a translator from -first-order predicate logic propositions to conjunctive normal form -and to clausal form. The translator code is partially based on code -published in the book "Programming in Prolog" by W. F. Clocksin and -C. S. Mellish. - -The following operators are used for representing logic connectives: - - negation: ~ - disjunction: v - conjunction: & - implication: => - equivalence: <=> - -Quantifiers are represented using the following notation: - - universal: all(X, P) - existential: exists(X, P) - -The two main object predicates are translate/2 and step_by_step/2. -The first predicate, translate/2, translate a logic proposition to -a list of clauses. The second predicate, step_by_step/2, performs -the same translations as translate/2 but also prints the results -of each conversion step. diff --git a/Logtalk/examples/logic/SCRIPT.txt b/Logtalk/examples/logic/SCRIPT.txt deleted file mode 100644 index 8484ca8ea..000000000 --- a/Logtalk/examples/logic/SCRIPT.txt +++ /dev/null @@ -1,98 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(logic(loader)). -... - - -% translate a single logic proposition: - -| ?- translator::translate((p v ~q) => (r & k), Cs). -r :- p. -k :- p. -q; r :- . -q; k :- . - - -Cs = [cl([r],[p]),cl([k],[p]),cl([q,r],[]),cl([q,k],[])] -yes - - -% translate a single logic proposition printing each translation step: - -| ?- translator::step_by_step((p v ~q) => (r & k), Cs). - -Processing proposition: p v ~q=>r&k - - 1. Remove implications: ~ (p v ~q) v r&k - 2. Distribute negation: ~p&q v r&k - 3. Remove existential quantifiers: ~p&q v r&k - 4. Convert to prenex normal form: ~p&q v r&k - 5. Remove universal quantifiers: ~p&q v r&k - 6. Convert to conjunctive normal form: (~p v r)&(~p v k)&((q v r)&(q v k)) - 7. Convert to clauses: [cl([r],[p]),cl([k],[p]),cl([q,r],[]),cl([q,k],[])] - -Clauses in Prolog-like notation: -r :- p. -k :- p. -q; r :- . -q; k :- . - - -Cs = [cl([r],[p]),cl([k],[p]),cl([q,r],[]),cl([q,k],[])] -yes - - -% translate a single logic proposition printing each translation step: - -| ?- translator::step_by_step(all(X, exists(Y, p(X) v ~q(X) => r(X, Y))), Cs). - -Processing proposition: all(X, exists(Y, p(X)v~q(X)=>r(X, Y))) - - 1. Remove implications: all(X, exists(Y, ~ (p(X)v~q(X))v r(X, Y))) - 2. Distribute negation: all(X, exists(Y, ~p(X)&q(X)v r(X, Y))) - 3. Remove existential quantifiers: all(X, ~p(X)&q(X)v r(X, f1(X))) - 4. Convert to prenex normal form: all(X, ~p(X)&q(X)v r(X, f1(X))) - 5. Remove universal quantifiers: ~p(X)&q(X)v r(X, f1(X)) - 6. Convert to conjunctive normal form: (~p(X)v r(X, f1(X)))& (q(X)v r(X, f1(X))) - 7. Convert to clauses: [cl([r(X, f1(X))], [p(X)]), cl([q(X), r(X, f1(X))], [])] - -Clauses in Prolog-like notation: -r(X, f1(X)) :- p(X). -q(X); r(X, f1(X)) :- . - - -X = X -Y = f1(X) -Cs = [cl([r(X, f1(X))], [p(X)]), cl([q(X), r(X, f1(X))], [])] -yes - - -% translate a single logic proposition printing each translation step: - -| ?- translator::step_by_step(all(X, men(X) => mortal(X)), Cs). - -Processing proposition: all(X, men(X)=>mortal(X)) - - 1. Remove implications: all(X, ~men(X)v mortal(X)) - 2. Distribute negation: all(X, ~men(X)v mortal(X)) - 3. Remove existential quantifiers: all(X, ~men(X)v mortal(X)) - 4. Convert to prenex normal form: all(X, ~men(X)v mortal(X)) - 5. Remove universal quantifiers: ~men(X)v mortal(X) - 6. Convert to conjunctive normal form: ~men(X)v mortal(X) - 7. Convert to clauses: [cl([mortal(X)], [men(X)])] - -Clauses in Prolog-like notation: -mortal(X) :- men(X). - - -X = X -Cs = [cl([mortal(X)], [men(X)])] -yes diff --git a/Logtalk/examples/logic/loader.lgt b/Logtalk/examples/logic/loader.lgt deleted file mode 100644 index a36039759..000000000 --- a/Logtalk/examples/logic/loader.lgt +++ /dev/null @@ -1,9 +0,0 @@ - -:- op(10, fy, ~). -:- op(20, yfx, &). -:- op(30, yfx, v). -:- op(40, xfx, =>). -:- op(40, xfx, <=>). - -:- initialization( - logtalk_load(translator)). diff --git a/Logtalk/examples/logic/translator.lgt b/Logtalk/examples/logic/translator.lgt deleted file mode 100644 index fada44f2e..000000000 --- a/Logtalk/examples/logic/translator.lgt +++ /dev/null @@ -1,371 +0,0 @@ - -:- object(translator). - - :- info([ - version is 1.1, - date is 2007/10/13, - author is 'Paulo Moura', - comment is 'Translator of logic propositions to clauses in conjunctive normal form.', - source is 'Code partially based on an example found on the Clocksin and Mellish Prolog book.']). - - :- public(translate/2). - :- mode(translate(+nonvar, -list), zero_or_one). - :- info(translate/2, [ - comment is 'Translates a proposition to a list of clauses.', - argnames is ['Propostion', 'Clauses']]). - - :- public(step_by_step/2). - :- mode(step_by_step(+nonvar, -list), zero_or_one). - :- info(step_by_step/2, [ - comment is 'Translates a proposition to a list of clauses, printing the result of each translation step.', - argnames is ['Propostion', 'Clauses']]). - - :- private(gensym_counter_/1). - :- dynamic(gensym_counter_/1). - - - :- op(10, fy, ~ ). % negation - :- op(20, yfx, & ). % conjunction - :- op(30, yfx, v ). % disjunction - :- op(40, xfx, =>). % implication - :- op(40, xfx, <=>). % equivalence - - - translate(P, Cs) :- - remove_implications(P, P2), - distribute_negation(P2, P3), - remove_existential_quantifiers(P3, P4), - convert_to_prenex_normal_form(P4, P5), - remove_universal_quantifiers(P5, P6), - convert_to_conjunctive_normal_form(P6, P7), - convert_to_clauses(P7, Cs), - print_clauses(Cs). - - - step_by_step(P, Cs) :- - nl, write('Processing proposition: '), write(P), nl, nl, - write(' 1. Remove implications: '), - remove_implications(P, P2), - write(P2), nl, - write(' 2. Distribute negation: '), - distribute_negation(P2, P3), - write(P3), nl, - write(' 3. Remove existential quantifiers: '), - remove_existential_quantifiers(P3, P4), - write(P4), nl, - write(' 4. Convert to prenex normal form: '), - convert_to_prenex_normal_form(P4, P5), - write(P5), nl, - write(' 5. Remove universal quantifiers: '), - remove_universal_quantifiers(P5, P6), - write(P6), nl, - write(' 6. Convert to conjunctive normal form: '), - convert_to_conjunctive_normal_form(P6, P7), - write(P7), nl, - write(' 7. Convert to clauses: '), - convert_to_clauses(P7, Cs), - write(Cs), nl, nl, - write('Clauses in Prolog-like notation:'), nl, - print_clauses(Cs). - - - remove_implications(all(X, P), all(X, P2)) :- - !, - remove_implications(P, P2). - - remove_implications(exists(X, P), exists(X, P2)) :- - !, - remove_implications(P, P2). - - remove_implications(P <=> Q, P2 & Q2 v ~P2 & ~Q2) :- - !, - remove_implications(P, P2), - remove_implications(Q, Q2). - - remove_implications(P => Q, ~P2 v Q2) :- - !, - remove_implications(P, P2), - remove_implications(Q, Q2). - - remove_implications(P & Q, P2 & Q2) :- - !, - remove_implications(P, P2), - remove_implications(Q, Q2). - - remove_implications(P v Q, P2 v Q2) :- - !, - remove_implications(P, P2), - remove_implications(Q, Q2). - - remove_implications(~P, ~P2) :- - !, - remove_implications(P, P2). - - remove_implications(P, P). - - - distribute_negation(all(X, P), all(X, P2)) :- - !, - distribute_negation(P, P2). - - distribute_negation(exists(X, P), exists(X, P2)) :- - !, - distribute_negation(P, P2). - - distribute_negation(P & Q, P2 & Q2) :- - !, - distribute_negation(P, P2), - distribute_negation(Q, Q2). - - distribute_negation(P v Q, P2 v Q2) :- - !, - distribute_negation(P, P2), - distribute_negation(Q, Q2). - - distribute_negation(~P, P2) :- - !, - apply_negation(P, P2). - - distribute_negation(P, P). - - - apply_negation(all(X, P), exists(X, P2)) :- - !, - apply_negation(P, P2). - - apply_negation(exists(X, P), all(X, P2)) :- - !, - apply_negation(P, P2). - - apply_negation(P & Q, P2 v Q2) :- - !, - apply_negation(P, P2), - apply_negation(Q, Q2). - - apply_negation(P v Q, P2 & Q2) :- - !, - apply_negation(P, P2), - apply_negation(Q, Q2). - - apply_negation(~P, P2) :- - !, - distribute_negation(P, P2). - - apply_negation(P, ~P). - - - remove_existential_quantifiers(P, P2) :- - remove_existential_quantifiers(P, P2, []). - - remove_existential_quantifiers(all(X, P), all(X, P2), Vars) :- - !, - remove_existential_quantifiers(P, P2, [X| Vars]). - - remove_existential_quantifiers(exists(X, P), P2, Vars) :- - !, - gensym(f, F), - X =.. [F| Vars], - remove_existential_quantifiers(P, P2, Vars). - - remove_existential_quantifiers(P & Q, P2 & Q2, Vars) :- - !, - remove_existential_quantifiers(P, P2, Vars), - remove_existential_quantifiers(Q, Q2, Vars). - - remove_existential_quantifiers(P v Q, P2 v Q2, Vars) :- - !, - remove_existential_quantifiers(P, P2, Vars), - remove_existential_quantifiers(Q, Q2, Vars). - - remove_existential_quantifiers(P, P, _). - - - convert_to_prenex_normal_form(P, P2) :- - collect_vars(P, P1, [], Vars), - add_vars_at_front(Vars, P1, P2). - - collect_vars(all(X, P), P2, Acc, Vars) :- - !, - collect_vars(P, P2, [X| Acc], Vars). - - collect_vars(P & Q, P2 & Q2, Acc, Vars) :- - !, - collect_vars(P, P2, Acc, Acc2), - collect_vars(Q, Q2, Acc2, Vars). - - collect_vars(P v Q, P2 v Q2, Acc, Vars) :- - !, - collect_vars(P, P2, Acc, Acc2), - collect_vars(Q, Q2, Acc2, Vars). - - collect_vars(P, P, Vars, Vars). - - - add_vars_at_front([], P, P). - - add_vars_at_front([X| Vars], P, P2) :- - add_vars_at_front(Vars, all(X, P), P2). - - - remove_universal_quantifiers(all(_, P), P2) :- - !, - remove_universal_quantifiers(P, P2). - - remove_universal_quantifiers(P & Q, P2 & Q2) :- - !, - remove_universal_quantifiers(P, P2), - remove_universal_quantifiers(Q, Q2). - - remove_universal_quantifiers(P v Q, P2 v Q2) :- - !, - remove_universal_quantifiers(P, P2), - remove_universal_quantifiers(Q, Q2). - - remove_universal_quantifiers(P, P). - - - convert_to_conjunctive_normal_form(P v Q, R) :- - !, - convert_to_conjunctive_normal_form(P, P2), - convert_to_conjunctive_normal_form(Q, Q2), - distribute_disjunction(P2 v Q2, R). - - convert_to_conjunctive_normal_form(P & Q, P2 & Q2) :- - !, - convert_to_conjunctive_normal_form(P, P2), - convert_to_conjunctive_normal_form(Q, Q2). - - convert_to_conjunctive_normal_form(P, P). - - - distribute_disjunction(P & Q v R, P2 & Q2) :- - !, - convert_to_conjunctive_normal_form(P v R, P2), - convert_to_conjunctive_normal_form(Q v R, Q2). - - distribute_disjunction(P v Q & R, P2 & Q2) :- - !, - convert_to_conjunctive_normal_form(P v Q, P2), - convert_to_conjunctive_normal_form(P v R, Q2). - - distribute_disjunction(P, P). - - - convert_to_clauses(P, Cs) :- - convert_to_clauses(P, [], Cs). - - - convert_to_clauses(P & Q, Acc, Cs) :- - !, - convert_to_clauses(Q, Acc, Acc2), - convert_to_clauses(P, Acc2, Cs). - - convert_to_clauses(P, Acc, [cl(Pos, Negs)| Acc]) :- - convert_to_clauses(P, [], Pos, [], Negs), - !. - - convert_to_clauses(_, Cs, Cs). - - - convert_to_clauses(P v Q, AccPos, Pos, AccNegs, Negs) :- - !, - convert_to_clauses(Q, AccPos, AccPos2, AccNegs, AccNegs2), - convert_to_clauses(P, AccPos2, Pos, AccNegs2, Negs). - - convert_to_clauses(~P, Pos, Pos, AccNegs, [P| AccNegs]) :- - !, - not_member_of(P, Pos). - - convert_to_clauses(P, AccPos, [P| AccPos], Negs, Negs) :- - !, - not_member_of(P, Negs). - -/* - convert_to_clauses(P & Q, {P2, Q2}) :- - !, - convert_to_clauses(P, P2), - convert_to_clauses(Q, Q2). - - convert_to_clauses(P v Q, R) :- - !, - convert_to_clause(P v Q, R). - - convert_to_clauses(P, {P}). - - - convert_to_clause(P & Q, R) :- - !, - convert_to_clauses(P & Q, {R}). - - convert_to_clause(P v Q, {P2, Q}) :- - !, - convert_to_clause(P, P2). - - convert_to_clause(P, P). -*/ - - not_member_of(P, [P| _]) :- - !, - fail. - - not_member_of(P, [_| Ps]) :- - !, - not_member_of(P, Ps). - - not_member_of(_, []). - - - print_clauses([]) :- - nl. - - print_clauses([cl(Pos, Negs)| Cs]) :- - print_clause(Pos, Negs), nl, - print_clauses(Cs). - - print_clause(Pos, []) :- - !, - print_disjunctions(Pos), write(' :- .'). - - print_clause([], Negs) :- - !, - write(':- '), print_conjunctions(Negs), write('.'). - - print_clause(Pos, Negs) :- - !, - print_disjunctions(Pos), write(' :- '), - print_conjunctions(Negs), write('.'). - - - print_disjunctions([P]) :- - !, - write(P). - - print_disjunctions([P| Ps]) :- - !, - write(P), write('; '), - print_disjunctions(Ps). - - - print_conjunctions([P]) :- - !, - write(P). - - print_conjunctions([P| Ps]) :- - !, - write(P), write(', '), - print_conjunctions(Ps). - - - gensym_counter_(0). - - - gensym(Base, Atom) :- - retract(gensym_counter_(Counter)), - Counter2 is Counter + 1, - number_codes(Counter2, Codes2), - atom_codes(Number, Codes2), - atom_concat(Base, Number, Atom), - assertz(gensym_counter_(Counter2)). - - -:- end_object. diff --git a/Logtalk/examples/lpa/NOTES.txt b/Logtalk/examples/lpa/NOTES.txt deleted file mode 100644 index 87e209485..000000000 --- a/Logtalk/examples/lpa/NOTES.txt +++ /dev/null @@ -1,11 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - -This directory contains examples adapted from the LPA Prolog++ -Reference Manual. This manual can be downloaded from the LPA web -site at . Please consult this reference -manual for further informations about each example. diff --git a/Logtalk/examples/lpa/faults/NOTES.txt b/Logtalk/examples/lpa/faults/NOTES.txt deleted file mode 100644 index 5141de98a..000000000 --- a/Logtalk/examples/lpa/faults/NOTES.txt +++ /dev/null @@ -1,11 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This example is an adaptation of the LPA Prolog++ faults example. - -To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/lpa/faults/SCRIPT.txt b/Logtalk/examples/lpa/faults/SCRIPT.txt deleted file mode 100644 index 39f6ad685..000000000 --- a/Logtalk/examples/lpa/faults/SCRIPT.txt +++ /dev/null @@ -1,27 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(lpa_faults(loader)). -... - - -| ?- fault::findall. - -Please answer all questions with yes or no. - -The starter turns but the engine doesnt fire? no. -The engine has difficulty starting? yes. -The engine cuts out shortly after starting? yes. - -Location : distributor -Possible Fault: Worn distributor brushes - -No (more) explanations found. -yes. diff --git a/Logtalk/examples/lpa/faults/cylinders.lgt b/Logtalk/examples/lpa/faults/cylinders.lgt deleted file mode 100644 index bf9c7bbd4..000000000 --- a/Logtalk/examples/lpa/faults/cylinders.lgt +++ /dev/null @@ -1,6 +0,0 @@ - -:- object(cylinders, - extends(engine)). - - -:- end_object. diff --git a/Logtalk/examples/lpa/faults/distributor.lgt b/Logtalk/examples/lpa/faults/distributor.lgt deleted file mode 100644 index e336f72dc..000000000 --- a/Logtalk/examples/lpa/faults/distributor.lgt +++ /dev/null @@ -1,25 +0,0 @@ - -:- object(distributor, - extends(sparking)). - - - fault(f1001, 'Condensation in the distributor cap'). - fault(f1002, 'Faulty distributor arm'). - fault(f1003, 'Worn distributor brushes'). - - symptom(s1001, 'The starter turns but the engine doesnt fire'). - symptom(s1002, 'The engine has difficulty starting'). - symptom(s1003, 'The engine cuts out shortly after starting'). - symptom(s1004, 'The engine cuts out at speed'). - - effect(f1001, s1001). - effect(f1002, s1001). - effect(f1002, s1004). - effect(f1003, s1002). - effect(f1003, s1003). - - contrary(s1002, s1001). - contrary(s1003, s1001). - - -:- end_object. diff --git a/Logtalk/examples/lpa/faults/electrical.lgt b/Logtalk/examples/lpa/faults/electrical.lgt deleted file mode 100644 index 1ccc35e04..000000000 --- a/Logtalk/examples/lpa/faults/electrical.lgt +++ /dev/null @@ -1,6 +0,0 @@ - -:- object(electrical, - extends(fault)). - - -:- end_object. diff --git a/Logtalk/examples/lpa/faults/engine.lgt b/Logtalk/examples/lpa/faults/engine.lgt deleted file mode 100644 index b315433be..000000000 --- a/Logtalk/examples/lpa/faults/engine.lgt +++ /dev/null @@ -1,6 +0,0 @@ - -:- object(engine, - extends(mechanical)). - - -:- end_object. diff --git a/Logtalk/examples/lpa/faults/fault.lgt b/Logtalk/examples/lpa/faults/fault.lgt deleted file mode 100644 index f3f61ea09..000000000 --- a/Logtalk/examples/lpa/faults/fault.lgt +++ /dev/null @@ -1,72 +0,0 @@ - -:- object(fault, - imports(proto_hierarchy)). - - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Expert system for automobile fault diagnosis.', - source is 'Example adopted from the LPA Prolog++ documentation.']). - - - :- public(findall/0). - :- mode(findall, one). - - :- private(told_by_user_/2). - :- dynamic(told_by_user_/2). - :- mode(told_by_user_(?nonvar, ?nonvar), zero_or_more). - - :- public(find/1). - :- mode(find(?nonvar), zero_or_more). - - :- private(exhibited/1). - :- mode(exhibited(+nonvar), zero_or_one). - - :- public(contrary/2). - :- mode(contrary(?nonvar, ?nonvar), zero_or_more). - - :- public(fault/2). - :- mode(fault(?nonvar, ?nonvar), zero_or_more). - - :- public(effect/2). - :- mode(effect(?nonvar, ?nonvar), zero_or_more). - - :- public(symptom/2). - :- mode(symptom(?nonvar, ?nonvar), zero_or_more). - - - findall :- - retractall(told_by_user_(_, _)), - write('Please answer all questions with yes or no.'), nl, nl, - forall( - (::descendant(Where), Where::find(Description)), - (nl, write('Location : '), write(Where), nl, - write('Possible Fault: '), write(Description), nl)), - nl, write('No (more) explanations found.'). - - - find(Description) :- - ::fault(Fault, Description), - forall(::effect(Fault, Symptom), exhibited(Symptom)). - - - exhibited(Symptom) :- - told_by_user_(Symptom, Reply), - !, - Reply = yes. - - exhibited(Symptom) :- - ::symptom(Symptom, Description), - write(Description), write('? '), - read(Reply), - asserta(told_by_user_(Symptom, Reply)), - Reply = yes, - forall( - (::contrary(Symptom, Contrary); - ::contrary(Contrary, Symptom)), - asserta(told_by_user_(Contrary, no))). - - -:- end_object. diff --git a/Logtalk/examples/lpa/faults/faults.lgt b/Logtalk/examples/lpa/faults/faults.lgt deleted file mode 100644 index cddc9b58a..000000000 --- a/Logtalk/examples/lpa/faults/faults.lgt +++ /dev/null @@ -1,178 +0,0 @@ - -:- object(fault, - imports(proto_hierarchy)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Expert system for automobile fault diagnosis.', - source is 'Example adopted from the LPA Prolog++ documentation.']). - - :- public(findall/0). - :- mode(findall, one). - - :- private(told_by_user_/2). - :- dynamic(told_by_user_/2). - :- mode(told_by_user_(?nonvar, ?nonvar), zero_or_more). - - :- public(find/1). - :- mode(find(?nonvar), zero_or_more). - - :- private(exhibited/1). - :- mode(exhibited(+nonvar), zero_or_one). - - :- public(contrary/2). - :- mode(contrary(?nonvar, ?nonvar), zero_or_more). - - :- public(fault/2). - :- mode(fault(?nonvar, ?nonvar), zero_or_more). - - :- public(effect/2). - :- mode(effect(?nonvar, ?nonvar), zero_or_more). - - :- public(symptom/2). - :- mode(symptom(?nonvar, ?nonvar), zero_or_more). - - findall :- - retractall(told_by_user_(_, _)), - write('Please answer all questions with yes or no.'), nl, nl, - forall( - (::descendant(Where), Where::find(Description)), - (nl, write('Location : '), write(Where), nl, - write('Possible Fault: '), write(Description), nl)), - nl, write('No (more) explanations found.'). - - find(Description) :- - ::fault(Fault, Description), - forall(::effect(Fault, Symptom), exhibited(Symptom)). - - exhibited(Symptom) :- - told_by_user_(Symptom, Reply) -> - Reply = yes - ; - ::symptom(Symptom, Description), - write(Description), write('? '), - read(Reply), - asserta(told_by_user_(Symptom, Reply)), - Reply = yes, - forall( - (::contrary(Symptom, Contrary); ::contrary(Contrary, Symptom)), - asserta(told_by_user_(Contrary, no))). - -:- end_object. - - - -/* electrical sub-system: - - electrical - lights - starting - sparking - distributor - plugs - starter_motor - -*/ - - -:- object(electrical, - extends(fault)). - -:- end_object. - - -:- object(lights, - extends(electrical)). - -:- end_object. - - -:- object(starting, - extends(electrical)). - -:- end_object. - - -:- object(sparking, - extends(starting)). - -:- end_object. - - -:- object(distributor, - extends(sparking)). - - fault(f1001, 'Condensation in the distributor cap'). - fault(f1002, 'Faulty distributor arm'). - fault(f1003, 'Worn distributor brushes'). - - symptom(s1001, 'The starter turns but the engine doesnt fire'). - symptom(s1002, 'The engine has difficulty starting'). - symptom(s1003, 'The engine cuts out shortly after starting'). - symptom(s1004, 'The engine cuts out at speed'). - - effect(f1001, s1001). - effect(f1002, s1001). - effect(f1002, s1004). - effect(f1003, s1002). - effect(f1003, s1003). - - contrary(s1002, s1001). - contrary(s1003, s1001). - -:- end_object. - - -:- object(plugs, - extends(sparking)). - -:- end_object. - - -:- object(starter_motor, - extends(starting)). - -:- end_object. - - - -/* mechanical sub-system: - - mechanical - engine - cylinders -*/ - - -:- object(mechanical, - extends(fault)). - -:- end_object. - - -:- object(engine, - extends(mechanical)). - -:- end_object. - - -:- object(cylinders, - extends(engine)). - -:- end_object. - - - -/* fuel_system sub-system: - - fuel_system - ... -*/ - - -:- object(fuel_system, - extends(fault)). - -:- end_object. diff --git a/Logtalk/examples/lpa/faults/fuel_system.lgt b/Logtalk/examples/lpa/faults/fuel_system.lgt deleted file mode 100644 index d7c978e0c..000000000 --- a/Logtalk/examples/lpa/faults/fuel_system.lgt +++ /dev/null @@ -1,6 +0,0 @@ - -:- object(fuel_system, - extends(fault)). - - -:- end_object. diff --git a/Logtalk/examples/lpa/faults/lights.lgt b/Logtalk/examples/lpa/faults/lights.lgt deleted file mode 100644 index 9f6913ed9..000000000 --- a/Logtalk/examples/lpa/faults/lights.lgt +++ /dev/null @@ -1,6 +0,0 @@ - -:- object(lights, - extends(electrical)). - - -:- end_object. diff --git a/Logtalk/examples/lpa/faults/loader.lgt b/Logtalk/examples/lpa/faults/loader.lgt deleted file mode 100644 index a5c866db8..000000000 --- a/Logtalk/examples/lpa/faults/loader.lgt +++ /dev/null @@ -1,4 +0,0 @@ - -:- initialization(( - logtalk_load(library(hierarchies_loader), [reload(skip)]), % allow for static binding - logtalk_load(faults))). diff --git a/Logtalk/examples/lpa/faults/mechanical.lgt b/Logtalk/examples/lpa/faults/mechanical.lgt deleted file mode 100644 index 5623ed9d5..000000000 --- a/Logtalk/examples/lpa/faults/mechanical.lgt +++ /dev/null @@ -1,6 +0,0 @@ - -:- object(mechanical, - extends(fault)). - - -:- end_object. diff --git a/Logtalk/examples/lpa/faults/plugs.lgt b/Logtalk/examples/lpa/faults/plugs.lgt deleted file mode 100644 index f436480e4..000000000 --- a/Logtalk/examples/lpa/faults/plugs.lgt +++ /dev/null @@ -1,6 +0,0 @@ - -:- object(plugs, - extends(sparking)). - - -:- end_object. diff --git a/Logtalk/examples/lpa/faults/sparking.lgt b/Logtalk/examples/lpa/faults/sparking.lgt deleted file mode 100644 index d82463408..000000000 --- a/Logtalk/examples/lpa/faults/sparking.lgt +++ /dev/null @@ -1,6 +0,0 @@ - -:- object(sparking, - extends(starting)). - - -:- end_object. diff --git a/Logtalk/examples/lpa/faults/starter_motor.lgt b/Logtalk/examples/lpa/faults/starter_motor.lgt deleted file mode 100644 index fec5e46fd..000000000 --- a/Logtalk/examples/lpa/faults/starter_motor.lgt +++ /dev/null @@ -1,6 +0,0 @@ - -:- object(starter_motor, - extends(starting)). - - -:- end_object. diff --git a/Logtalk/examples/lpa/faults/starting.lgt b/Logtalk/examples/lpa/faults/starting.lgt deleted file mode 100644 index 380602a1a..000000000 --- a/Logtalk/examples/lpa/faults/starting.lgt +++ /dev/null @@ -1,6 +0,0 @@ - -:- object(starting, - extends(electrical)). - - -:- end_object. diff --git a/Logtalk/examples/lpa/timetables/NOTES.txt b/Logtalk/examples/lpa/timetables/NOTES.txt deleted file mode 100755 index eb2a0e584..000000000 --- a/Logtalk/examples/lpa/timetables/NOTES.txt +++ /dev/null @@ -1,11 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This example is an adaptation of the LPA Prolog++ timetables example. - -To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/lpa/timetables/SCRIPT.txt b/Logtalk/examples/lpa/timetables/SCRIPT.txt deleted file mode 100755 index fe15dfc84..000000000 --- a/Logtalk/examples/lpa/timetables/SCRIPT.txt +++ /dev/null @@ -1,525 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(lpa_timetables(loader)). -... - - -% the setup phase initializes the timetable: - -| ?- timetable::setup. - -yes - - -| ?- timetable::make(2). - -+ first_year - p1 - nicky - french -+ first_year - p2 - nicky - biology -+ first_year - p3 - brian - maths -+ first_year - p4 - brian - music -+ first_year - p5 - clive - prolog -+ second_year - p1 - brian - maths -+ second_year - p2 - brian - music -+ second_year - p3 - nicky - french -+ second_year - p4 - nicky - biology -+ second_year - p5 - diane - accountancy -+ third_year - p1 - dave - maths -+ third_year - p2 - clive - french -+ third_year - p3 - clive - prolog -+ third_year - p4 - diane - accountancy -+ third_year - p5 - nicky - biology -+ fourth_year - p1 - clive - french -+ fourth_year - p2 - dave - maths -+ fourth_year - p3 - diane - accountancy -+ fourth_year - p4 - clive - prolog -+ fourth_year - p5 - brian - music -yes - - -% the partially completed timetable is ... - -| ?- timetable::print. - -FORM TIMETABLE... - -FORM: first_year -p1: nicky teaches french -p2: nicky teaches biology -p3: brian teaches maths -p4: brian teaches music -p5: clive teaches prolog - -FORM: second_year -p1: brian teaches maths -p2: brian teaches music -p3: nicky teaches french -p4: nicky teaches biology -p5: diane teaches accountancy - -FORM: third_year -p1: dave teaches maths -p2: clive teaches french -p3: clive teaches prolog -p4: diane teaches accountancy -p5: nicky teaches biology - -FORM: fourth_year -p1: clive teaches french -p2: dave teaches maths -p3: diane teaches accountancy -p4: clive teaches prolog -p5: brian teaches music - - - -PERIOD TIMETABLE ... - -PERIOD: p1 -first_year: nicky teaches french -second_year: brian teaches maths -third_year: dave teaches maths -fourth_year: clive teaches french - -PERIOD: p2 -first_year: nicky teaches biology -second_year: brian teaches music -third_year: clive teaches french -fourth_year: dave teaches maths - -PERIOD: p3 -first_year: brian teaches maths -second_year: nicky teaches french -third_year: clive teaches prolog -fourth_year: diane teaches accountancy - -PERIOD: p4 -first_year: brian teaches music -second_year: nicky teaches biology -third_year: diane teaches accountancy -fourth_year: clive teaches prolog - -PERIOD: p5 -first_year: clive teaches prolog -second_year: diane teaches accountancy -third_year: nicky teaches biology -fourth_year: brian teaches music - - - -TEACHER TIMETABLE ... - -TEACHER: nicky -p1: teach french to first_year -p2: teach biology to first_year -p3: teach french to second_year -p4: teach biology to second_year -p5: teach biology to third_year - -TEACHER: brian -p1: teach maths to second_year -p2: teach music to second_year -p3: teach maths to first_year -p4: teach music to first_year -p5: teach music to fourth_year - -TEACHER: dave -p1: teach maths to third_year -p2: teach maths to fourth_year -p3: -p4: -p5: - -TEACHER: clive -p1: teach french to fourth_year -p2: teach french to third_year -p3: teach prolog to third_year -p4: teach prolog to fourth_year -p5: teach prolog to first_year - -TEACHER: diane -p1: -p2: -p3: teach accountancy to fourth_year -p4: teach accountancy to third_year -p5: teach accountancy to second_year - -TEACHER: phil -p1: -p2: -p3: -p4: -p5: - - - -SUBJECT TIMETABLE ... - -SUBJECT: maths -p1: second_year taught by brian -p1: third_year taught by dave -p2: fourth_year taught by dave -p3: first_year taught by brian - -SUBJECT: music -p2: second_year taught by brian -p4: first_year taught by brian -p5: fourth_year taught by brian - -SUBJECT: french -p1: first_year taught by nicky -p1: fourth_year taught by clive -p2: third_year taught by clive -p3: second_year taught by nicky - -SUBJECT: prolog -p3: third_year taught by clive -p4: fourth_year taught by clive -p5: first_year taught by clive - -SUBJECT: biology -p2: first_year taught by nicky -p4: second_year taught by nicky -p5: third_year taught by nicky - -SUBJECT: prolog++ - -SUBJECT: accountancy -p3: fourth_year taught by diane -p4: third_year taught by diane -p5: second_year taught by diane - -yes - - -| ?- timetable::make(5). - -+ first_year - p1 - diane - accountancy -+ first_year - p2 - phil - prolog++ -+ second_year - p1 - phil - prolog++ -Swap subject... -- third_year - p4 - diane - accountancy -+ third_year - p4 - phil - prolog++ -Swap teacher... -- third_year - p2 - clive - french -+ third_year - p2 - diane - accountancy -Swap teacher... -- second_year - p2 - brian - music -+ second_year - p2 - clive - prolog -Swap teacher... -Swap subject... -- third_year - p2 - diane - accountancy -+ third_year - p2 - brian - music -Swap teacher... -- third_year - p2 - brian - music -+ third_year - p2 - diane - accountancy -Swap teacher... -- second_year - p2 - clive - prolog -+ second_year - p2 - brian - music -Swap teacher... -Swap teacher... -- second_year - p2 - brian - music -+ second_year - p2 - clive - prolog -Swap teacher... -- second_year - p2 - clive - prolog -+ second_year - p2 - brian - music -Swap teacher... -Swap teacher... -- second_year - p2 - brian - music -+ second_year - p2 - clive - prolog -Swap teacher... -- second_year - p2 - clive - prolog -+ second_year - p2 - brian - music -Swap teacher... -Swap teacher... -- second_year - p2 - brian - music -+ second_year - p2 - clive - prolog -Swap teacher... -Swap teacher... -- second_year - p2 - clive - prolog -+ second_year - p2 - brian - music -Swap teacher... -- second_year - p2 - brian - music -+ second_year - p2 - clive - prolog -Swap teacher... -Swap teacher... -- second_year - p2 - clive - prolog -+ second_year - p2 - brian - music -Swap teacher... -- second_year - p2 - brian - music -+ second_year - p2 - clive - prolog -Swap teacher... -Swap teacher... -- second_year - p2 - clive - prolog -+ second_year - p2 - brian - music -Swap teacher... -- second_year - p2 - brian - music -+ second_year - p2 - clive - prolog -Swap teacher... -Swap teacher... -- second_year - p2 - clive - prolog -+ second_year - p2 - brian - music -Swap teacher... -- second_year - p2 - brian - music -+ second_year - p2 - clive - prolog -Swap teacher... -Swap teacher... -- second_year - p2 - clive - prolog -+ second_year - p2 - brian - music -Swap teacher... -- second_year - p2 - brian - music -+ second_year - p2 - clive - prolog -Swap teacher... -Swap teacher... -- second_year - p2 - clive - prolog -+ second_year - p2 - brian - music -Swap subject... -- third_year - p2 - diane - accountancy -+ third_year - p2 - clive - french -Swap subject... -- third_year - p4 - phil - prolog++ -+ third_year - p4 - diane - accountancy -Swap teacher... -- third_year - p3 - clive - prolog -+ third_year - p3 - phil - prolog++ -Swap subject... -Swap subject... -Swap subject... -- third_year - p3 - phil - prolog++ -+ third_year - p3 - clive - prolog -Swap subject... -- third_year - p4 - diane - accountancy -+ third_year - p4 - phil - prolog++ -Swap teacher... -- third_year - p2 - clive - french -+ third_year - p2 - diane - accountancy -+ second_year - p2 - clive - prolog -Swap subject... -- fourth_year - p3 - diane - accountancy -+ fourth_year - p3 - phil - prolog++ -Swap teacher... -- fourth_year - p4 - clive - prolog -+ fourth_year - p4 - diane - accountancy -Swap subject... -- third_year - p4 - phil - prolog++ -+ third_year - p4 - clive - french -Swap teacher... -- third_year - p3 - clive - prolog -+ third_year - p3 - phil - prolog++ -Swap subject... -- fourth_year - p3 - phil - prolog++ -+ fourth_year - p3 - clive - prolog -Swap teacher... -Swap teacher... -Swap subject... -- fourth_year - p4 - diane - accountancy -+ fourth_year - p4 - phil - prolog++ -Swap teacher... -- fourth_year - p3 - clive - prolog -+ fourth_year - p3 - diane - accountancy -Swap subject... -- fourth_year - p3 - diane - accountancy -+ fourth_year - p3 - clive - prolog -Swap teacher... -- fourth_year - p3 - clive - prolog -+ fourth_year - p3 - diane - accountancy -Swap subject... -- third_year - p3 - phil - prolog++ -+ third_year - p3 - clive - prolog -Swap teacher... -- third_year - p5 - nicky - biology -+ third_year - p5 - phil - prolog++ -Swap teacher... -- fourth_year - p5 - brian - music -+ fourth_year - p5 - nicky - biology -Swap teacher... -Swap teacher... -- fourth_year - p5 - nicky - biology -+ fourth_year - p5 - brian - music -Swap teacher... -- fourth_year - p5 - brian - music -+ fourth_year - p5 - nicky - biology -Swap teacher... -Swap teacher... -- fourth_year - p5 - nicky - biology -+ fourth_year - p5 - brian - music -Swap teacher... -- fourth_year - p5 - brian - music -+ fourth_year - p5 - nicky - biology -Swap teacher... -Swap teacher... -- fourth_year - p5 - nicky - biology -+ fourth_year - p5 - brian - music -Swap teacher... -- fourth_year - p5 - brian - music -+ fourth_year - p5 - nicky - biology -+ third_year - p5 - brian - music - -yes - - -% the completed timetable is ... - -| ?- timetable::print. - -FORM TIMETABLE... - -FORM: first_year -p1: nicky teaches french -p2: nicky teaches biology -p3: brian teaches maths -p4: brian teaches music -p5: clive teaches prolog - -FORM: second_year -p1: brian teaches maths -p2: brian teaches music -p3: nicky teaches french -p4: nicky teaches biology -p5: diane teaches accountancy - -FORM: third_year -p1: dave teaches maths -p2: diane teaches accountancy -p3: clive teaches prolog -p4: clive teaches french -p5: phil teaches prolog++ - -FORM: fourth_year -p1: clive teaches french -p2: dave teaches maths -p3: diane teaches accountancy -p4: phil teaches prolog++ -p5: nicky teaches biology - - - -PERIOD TIMETABLE ... - -PERIOD: p1 -first_year: nicky teaches french -second_year: brian teaches maths -third_year: dave teaches maths -fourth_year: clive teaches french - -PERIOD: p2 -first_year: nicky teaches biology -second_year: brian teaches music -third_year: diane teaches accountancy -fourth_year: dave teaches maths - -PERIOD: p3 -first_year: brian teaches maths -second_year: nicky teaches french -third_year: clive teaches prolog -fourth_year: diane teaches accountancy - -PERIOD: p4 -first_year: brian teaches music -second_year: nicky teaches biology -third_year: clive teaches french -fourth_year: phil teaches prolog++ - -PERIOD: p5 -first_year: clive teaches prolog -second_year: diane teaches accountancy -third_year: phil teaches prolog++ -fourth_year: nicky teaches biology - - - -TEACHER TIMETABLE ... - -TEACHER: nicky -p1: teach french to first_year -p2: teach biology to first_year -p3: teach french to second_year -p4: teach biology to second_year -p5: teach biology to fourth_year - -TEACHER: brian -p1: teach maths to second_year -p2: teach music to second_year -p3: teach maths to first_year -p4: teach music to first_year -p5: teach music to third_year - -TEACHER: dave -p1: teach maths to third_year -p2: teach maths to fourth_year -p3: -p4: -p5: - -TEACHER: clive -p1: teach french to fourth_year -p2: teach prolog to second_year -p3: teach prolog to third_year -p4: teach french to third_year -p5: teach prolog to first_year - -TEACHER: diane -p1: teach accountancy to first_year -p2: teach accountancy to third_year -p3: teach accountancy to fourth_year -p4: -p5: teach accountancy to second_year - -TEACHER: phil -p1: teach prolog++ to second_year -p2: teach prolog++ to first_year -p3: -p4: teach prolog++ to fourth_year -p5: teach prolog++ to third_year - - - -SUBJECT TIMETABLE ... - -SUBJECT: maths -p1: second_year taught by brian -p1: third_year taught by dave -p2: fourth_year taught by dave -p3: first_year taught by brian - -SUBJECT: music -p2: second_year taught by brian -p4: first_year taught by brian -p5: third_year taught by brian - -SUBJECT: french -p1: first_year taught by nicky -p1: fourth_year taught by clive -p3: second_year taught by nicky -p4: third_year taught by clive - -SUBJECT: prolog -p2: second_year taught by clive -p3: third_year taught by clive -p5: first_year taught by clive - -SUBJECT: biology -p2: first_year taught by nicky -p4: second_year taught by nicky -p5: fourth_year taught by nicky - -SUBJECT: prolog++ -p1: second_year taught by phil -p2: first_year taught by phil -p4: fourth_year taught by phil -p5: third_year taught by phil - -SUBJECT: accountancy -p1: first_year taught by diane -p2: third_year taught by diane -p3: fourth_year taught by diane -p5: second_year taught by diane - -yes diff --git a/Logtalk/examples/lpa/timetables/forms.lgt b/Logtalk/examples/lpa/timetables/forms.lgt deleted file mode 100644 index f686aac40..000000000 --- a/Logtalk/examples/lpa/timetables/forms.lgt +++ /dev/null @@ -1,80 +0,0 @@ - -:- object(forms). - - :- info([ - version is 1.0, - date is 2005/5/8, - author is 'Example by LPA; adapted to Logtalk by Paulo Moura.', - comment is 'General attributes & methods for all forms.']). - - :- public(print/0). - :- info(print/0, [ - comment is 'Print the complete timetable from the pupil viewpoint.']). - - print :- - nl, write('FORM TIMETABLE...'), nl, nl, - forall(extends_object(Form, form), Form::print), nl. - -:- end_object. - - -:- object(form). - - :- info([ - version is 1.0, - date is 2005/5/8, - author is 'Example by LPA; adapted to Logtalk by Paulo Moura.', - comment is 'General attributes & methods for all forms.']). - - :- public(print/0). - :- info(print/0, [ - comment is 'Print the complete timetable from the pupil viewpoint.']). - - :- public(print_period/1). - :- info(print_period/1, [ - comment is 'Print the pupil timetable for a specific period.', - argnames is ['Period']]). - - print :- - self(Self), - write('FORM: '), write(Self), nl, - forall(extends_object(Period, period), Period::print_form(Self)), nl. - - print_period(Period) :- - self(Self), - timetable::filled_entry(Self, Period, Teacher, Subject), - !, - write(Self), write(': '), - write(Teacher), write(' teaches '), - write(Subject), nl. - - print_period(_) :- - self(Self), - write(Self), write(': '), nl. - -:- end_object. - - -:- object(first_year, - extends(form)). - -:- end_object. - - -:- object(second_year, - extends(form)). - -:- end_object. - - -:- object(third_year, - extends(form)). - -:- end_object. - - -:- object(fourth_year, - extends(form)). - -:- end_object. - diff --git a/Logtalk/examples/lpa/timetables/loader.lgt b/Logtalk/examples/lpa/timetables/loader.lgt deleted file mode 100644 index 4a1af1e97..000000000 --- a/Logtalk/examples/lpa/timetables/loader.lgt +++ /dev/null @@ -1,4 +0,0 @@ - -:- initialization(( - logtalk_load(library(types_loader), [reload(skip)]), % allow for static binding - logtalk_load([timetable, forms, periods, subjects, teachers]))). diff --git a/Logtalk/examples/lpa/timetables/periods.lgt b/Logtalk/examples/lpa/timetables/periods.lgt deleted file mode 100644 index 06456aee2..000000000 --- a/Logtalk/examples/lpa/timetables/periods.lgt +++ /dev/null @@ -1,129 +0,0 @@ - -:- object(periods). - - - :- info([ - version is 1.0, - date is 2005/5/8, - author is 'Example by LPA; adapted to Logtalk by Paulo Moura.', - comment is 'General attributes & methods for all periods.']). - - - :- public(print/0). - :- info(print/0, [ - comment is 'Print period timetable.']). - - - print :- - nl, write('PERIOD TIMETABLE ...'), nl, nl, - forall(extends_object(Period, period), Period::print), nl. - - -:- end_object. - - -:- object(period). - - - :- info([ - version is 1.0, - date is 2005/5/8, - author is 'Example by LPA; adapted to Logtalk by Paulo Moura.', - comment is 'General attributes & methods for all periods.']). - - - :- public(print/0). - :- info(print/0, [ - comment is 'Print complete timetable from the period viewpoint.']). - - :- public(print_teacher/1). - :- info(print_teacher/1, [ - comment is 'Print entry for a specific teacher in this period.', - argnames is ['Teacher']]). - - :- public(print_form/1). - :- info(print_form/1, [ - comment is 'Print entry for a specific form in this period.', - argnames is ['Form']]). - - :- public(print_subject/1). - :- info(print_subject/1, [ - comment is 'Print entry for a specific subject in this period.', - argnames is ['Subject']]). - - - - print :- - self(Self), - write('PERIOD: '), write(Self), nl, - forall(extends_object(Form, form), Form::print_period(Self)), nl. - - - print_teacher(Teacher) :- - self(Self), - timetable::filled_entry(Form, Self, Teacher, Subject), - !, - write(Self), write(': teach '), - write(Subject), write(' to '), - write(Form), nl. - - print_teacher(_) :- - self(Self), - write(Self), write(':'), nl. - - - print_form(Form) :- - self(Self), - timetable::filled_entry(Form, Self, Teacher, Subject), - !, - write(Self), write(': '), - write(Teacher), write(' teaches '), - write(Subject), nl. - - print_form(_) :- - self(Self), - write(Self), write(':'), nl. - - - print_subject(Subject) :- - self(Self), - timetable::filled_entry(Form, Self, Teacher, Subject), - write(Self), write(': '), - write(Form), write(' taught by '), - write(Teacher), nl, - fail. - - print_subject(_). - - -:- end_object. - - -:- object(p1, - extends(period)). - -:- end_object. - - -:- object(p2, - extends(period)). - -:- end_object. - - -:- object(p3, - extends(period)). - -:- end_object. - - -:- object(p4, - extends(period)). - -:- end_object. - - -:- object(p5, - extends(period)). - -:- end_object. diff --git a/Logtalk/examples/lpa/timetables/subjects.lgt b/Logtalk/examples/lpa/timetables/subjects.lgt deleted file mode 100644 index 8f269e63a..000000000 --- a/Logtalk/examples/lpa/timetables/subjects.lgt +++ /dev/null @@ -1,82 +0,0 @@ - -:- object(subjects). - - :- info([ - version is 1.0, - date is 2005/5/8, - author is 'Example by LPA; adapted to Logtalk by Paulo Moura.', - comment is 'General attributes & methods for all subjects.']). - - :- public(print/0). - :- info(print/0, [ - comment is 'Print complete timetable from the subject viewpoint.']). - - print :- - nl, write('SUBJECT TIMETABLE ...'), nl, nl, - forall(extends_object(Subject, subject), Subject::print), - nl. - -:- end_object. - - -:- object(subject). - - :- info([ - version is 1.0, - date is 2005/5/8, - author is 'Example by LPA; adapted to Logtalk by Paulo Moura.', - comment is 'General attributes & methods for all subjects.']). - - :- public(print/0). - :- info(print/0, [ - comment is 'Print complete timetable from the subject viewpoint.']). - - print :- - self(Self), - write('SUBJECT: '), write(Self), nl, - forall(extends_object(Period, period), Period::print_subject(Self)), - nl. - -:- end_object. - - -:- object(maths, - extends(subject)). - -:- end_object. - - -:- object(music, - extends(subject)). - -:- end_object. - - -:- object(french, - extends(subject)). - -:- end_object. - - -:- object(prolog, - extends(subject)). - -:- end_object. - - -:- object(biology, - extends(subject)). - -:- end_object. - - -:- object('prolog++', - extends(subject)). - -:- end_object. - - -:- object(accountancy, - extends(subject)). - -:- end_object. diff --git a/Logtalk/examples/lpa/timetables/teachers.lgt b/Logtalk/examples/lpa/timetables/teachers.lgt deleted file mode 100644 index c6f6fd7fc..000000000 --- a/Logtalk/examples/lpa/timetables/teachers.lgt +++ /dev/null @@ -1,128 +0,0 @@ - -:- object(teachers). - - :- info([ - version is 1.0, - date is 2005/5/8, - author is 'Example by LPA; adapted to Logtalk by Paulo Moura.', - comment is 'General attributes & methods for all teachers.']). - - :- public(print/0). - :- info(print/0, [ - comment is 'Print teachers timetable.']). - - print :- - nl, write('TEACHER TIMETABLE ...'), nl, nl, - forall(extends_object(Teacher, teacher), Teacher::print), - nl. - -:- end_object. - - -:- object(teacher). - - :- info([ - version is 1.0, - date is 2005/5/8, - author is 'Example by LPA; adapted to Logtalk by Paulo Moura.', - comment is 'General attributes & methods for all teachers.']). - - :- public(teach_period/1). - :- info(teach_period/1, [ - comment is 'A period for which the teacher can be assigned.']). - - :- public(teach_subject/1). - :- info(teach_subject/1, [ - comment is 'A subject which the teacher can teach.']). - - :- public(print/0). - :- info(print/0, [ - comment is 'Print complete timetable from the teacher viewpoint.']). - - :- public(freetime/1). - :- info(freetime/1, [ - comment is '.', - argnames is ['Freetime']]). - - :- public(subject/1). - :- info(subject/1, [ - comment is '.', - argnames is ['Subject']]). - - teach_period(Period) :- - \+ ::freetime(Period). - - teach_subject(Subject) :- - ::subject(Subject). - - print :- - self(Self), - write('TEACHER: '), write(Self), nl, - forall(extends_object(Period, period), Period::print_teacher(Self)), - nl. - -:- end_object. - - -:- object(nicky, - extends(teacher)). - - subject(french). - subject(biology). - - freetime(1). - freetime(4). - -:- end_object. - - -:- object(brian, - extends(teacher)). - - subject(maths). - subject(music). - -:- end_object. - - -:- object(dave, - extends(teacher)). - - subject(maths). - -:- end_object. - - -:- object(clive, - extends(teacher)). - - subject(french). - subject(prolog). - - freetime(2). - freetime(3). - freetime(5). - -:- end_object. - - -:- object(diane, - extends(teacher)). - - subject(accountancy). - - freetime(2). - freetime(4). - -:- end_object. - - -:- object(phil, - extends(teacher)). - - subject(maths). - subject('prolog++'). - - freetime(3). - -:- end_object. diff --git a/Logtalk/examples/lpa/timetables/timetable.lgt b/Logtalk/examples/lpa/timetables/timetable.lgt deleted file mode 100644 index 6352a9e49..000000000 --- a/Logtalk/examples/lpa/timetables/timetable.lgt +++ /dev/null @@ -1,134 +0,0 @@ - -:- object(timetable). - - - :- info([ - version is 1.0, - date is 2005/5/8, - author is 'Example by LPA; adapted to Logtalk by Paulo Moura.', - comment is 'Set up & create a timetable satisfying all of the constraints.']). - - - :- public(setup/0). - :- info(setup/0, [ - comment is 'Set up the teachers, subjects, forms & periods for this school.']). - - :- public(make/0). - :- info(make/0, [ - comment is 'Make the timetable according to the school setup.']). - - :- public(make/1). - :- info(make/1, [ - comment is 'Make with max. depth of swaps.', - argnames is ['Effort']]). - - :- public(print/0). - :- info(print/0, [ - comment is 'Print from different perspectives.']). - - :- public(filled_entry/4). - :- info(filled_entry/4, [ - comment is 'Timetable entry.', - argnames is ['Form', 'Period', 'Teacher', 'Subject']]). - - :- private(entry/4). - :- dynamic(entry/4). - :- info(entry/4, [ - comment is 'Timetable entry.', - argnames is ['Form', 'Period', 'Teacher', 'Subject']]). - - - :- uses(list). - - - print :- - (forms, periods, teachers, subjects)::print. - - - setup :- - retractall(entry(_, _, _, _)). - - - make :- - make(3). - - - make(Effort) :- - list::length(E, Effort), - forall( - (extends_object(Form, form), extends_object(Period, period)), - fill_entry(E, Form, Period, _Teacher, _Subject)). - - - unfilled_entry(Form, Period) :- - extends_object(Form, form), - extends_object(Period, period), - \+ filled_entry(Form, Period, _, _). - - - filled_entry(Form, Period, Teacher, Subject) :- - entry(Form, Period, Teacher, Subject). - - - fill_entry(E, Form, Period, Teacher, Subject) :- - find_entry(E, Form, Period, Teacher, Subject), - !, - assert(Form, Period, Teacher, Subject). - - fill_entry(_, _, _, _, _). - - - find_entry(_, Form, Period, Teacher, Subject) :- - extends_object(Teacher, teacher), - Teacher::teach_period(Period), - \+ filled_entry(_, Period, Teacher, _), - extends_object(Subject, subject), - Teacher::teach_subject(Subject), - \+ filled_entry(Form, _, _, Subject). - - find_entry([_| E], FormA, Period, TeacherA, SubjectA) :- - extends_object(Teacher, teacher), - Teacher::teach_period(Period), - filled_entry(FormB, Period, TeacherA, _), - extends_object(SubjectA, subject), - TeacherA::teach_subject(SubjectA), - \+ filled_entry(FormA, _, _, SubjectA), - find_entry(E, FormB, Period, TeacherB, SubjectB), - TeacherB \= TeacherA, - write('Swap teacher... '), nl, - retract(FormB, Period, TeacherA, _), - assert(FormB, Period, TeacherB, SubjectB). - - find_entry([_| E], Form, PeriodA, TeacherA, SubjectA) :- - extends_object(TeacherA, teacher), - TeacherA::teach_period(PeriodA), - \+ filled_entry(_, PeriodA, TeacherA, _), - extends_object(SubjectA, subject), - TeacherA::teach_subject(SubjectA), - filled_entry(Form, PeriodB, _, SubjectA), - find_entry(E, Form, PeriodB, TeacherB, SubjectB), - SubjectA \= SubjectB, - write('Swap subject... '), nl, - retract(Form, PeriodB, _, SubjectA), - assert(Form, PeriodB, TeacherB, SubjectB). - - - assert(Form, Period, Teacher, Subject) :- - assertz(entry(Form, Period, Teacher, Subject)), - write('+ '), - write(Form), write(' - '), - write(Period), write(' - '), - write(Teacher), write(' - '), - write(Subject), nl. - - - retract(Form, Period, Teacher, Subject) :- - retract(entry(Form, Period, Teacher, Subject)), - write('- '), - write(Form), write(' - '), - write(Period), write(' - '), - write(Teacher), write(' - '), - write(Subject), nl. - - -:- end_object. diff --git a/Logtalk/examples/metainterpreters/NOTES.txt b/Logtalk/examples/metainterpreters/NOTES.txt deleted file mode 100644 index 3b3df75f7..000000000 --- a/Logtalk/examples/metainterpreters/NOTES.txt +++ /dev/null @@ -1,26 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This example contains simple meta-interpreters for pure Prolog encapsulated -in Logtalk categories: - - solver - simple meta-interpreter for pure Prolog - - proof_tree - simple meta-interpreter for pure Prolog returning the proof - tree for successful queries - - tracer - simple meta-interpreter for pure Prolog that traces proof - construction - -To use a meta-interpreter with an object, simply import the corresponding -category. diff --git a/Logtalk/examples/metainterpreters/SCRIPT.txt b/Logtalk/examples/metainterpreters/SCRIPT.txt deleted file mode 100644 index 1d1720eae..000000000 --- a/Logtalk/examples/metainterpreters/SCRIPT.txt +++ /dev/null @@ -1,100 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(metainterpreters(loader)). -... - - -% direct call of p/1: - -| ?- database::p(X). - -X = 1 ; -X = 2 -yes - - -% solver - a simple meta-interpreter for pure Prolog: - -| ?- database::solve(p(X)). - -X = 1 ; -X = 2 -yes - -| ?- database::proof_tree(p(X), Tree). - -X = 1 -Tree = p(1):- (q(1, a):- (s(1):-true), (t(1, a):-true)), (r(a):-true) ; -X = 2 -Tree = p(2):- (q(2, b):- (s(2):-true), (t(2, b):-true)), (r(b):-true) -yes - - -% tracer - a simple meta-interpreter for tracing goal proofs using pure Prolog: - -| ?- database::trace(p(X)). -1 call: p(_G180) -2 call: q(_G180, _G316) -3 call: s(_G180) -3 exit: s(1) -3 call: t(1, _G316) -3 exit: t(1, a) -2 exit: q(1, a) -2 call: r(a) -2 exit: r(a) -1 exit: p(1) - -X = 1 ; -1 redo: p(1) -2 redo: r(a) -2 fail: r(a) -2 redo: q(1, a) -3 redo: t(1, a) -3 fail: t(1, _G316) -3 redo: s(1) -3 exit: s(2) -3 call: t(2, _G316) -3 exit: t(2, b) -2 exit: q(2, b) -2 call: r(b) -2 exit: r(b) -1 exit: p(2) - -X = 2 ; -1 redo: p(2) -2 redo: r(b) -2 fail: r(b) -2 redo: q(2, b) -3 redo: t(2, b) -3 fail: t(2, _G316) -3 redo: s(2) -3 exit: s(3) -3 call: t(3, _G316) -3 fail: t(3, _G316) -3 redo: s(3) -3 fail: s(_G180) -2 fail: q(_G180, _G316) -1 fail: p(_G180) - -no - - -% another example: expert system rules: - -| ?- rules::prove(weather(Wheather)). - -Wheather = raining -yes - -| ?- rules::prove(goto(Where)). - -Where = cinema -yes diff --git a/Logtalk/examples/metainterpreters/database.lgt b/Logtalk/examples/metainterpreters/database.lgt deleted file mode 100644 index 689f97746..000000000 --- a/Logtalk/examples/metainterpreters/database.lgt +++ /dev/null @@ -1,23 +0,0 @@ - -:- object(database, - imports(solver, proof_tree, tracer)). - - :- public(p/1). - :- private(q/2, r/1, s/1, t/2). - :- dynamic(p/1, q/2, r/1, s/1, t/2). - - p(X) :- q(X, Y), r(Y). - - q(X, Y) :- s(X), t(X, Y). - - r(a). - r(b). - - s(1). - s(2). - s(3). - - t(1, a). - t(2, b). - -:- end_object. diff --git a/Logtalk/examples/metainterpreters/loader.lgt b/Logtalk/examples/metainterpreters/loader.lgt deleted file mode 100644 index ce24f47c9..000000000 --- a/Logtalk/examples/metainterpreters/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load([metainterpreters, database, rules])). diff --git a/Logtalk/examples/metainterpreters/metainterpreters.lgt b/Logtalk/examples/metainterpreters/metainterpreters.lgt deleted file mode 100644 index 70191ca27..000000000 --- a/Logtalk/examples/metainterpreters/metainterpreters.lgt +++ /dev/null @@ -1,95 +0,0 @@ - -:- category(solver). - - :- info([ - version is 1.0, - date is 2004/5/2, - author is 'Paulo Moura', - comment is 'Simple meta-interpreter for pure Prolog with only conjunctions as clause bodies.']). - - :- public(solve/1). - :- mode(solve(+goal), zero_or_more). - :- info(solve/1, [ - comment is 'Proves goal.', - argnames is ['Goal']]). - - solve(true) :- - !. - solve((A, B)) :- - !, - solve(A), - solve(B). - solve(A) :- - ::clause(A, B), - solve(B). - -:- end_category. - - -:- category(proof_tree). - - :- info([ - version is 1.0, - date is 2004/5/2, - author is 'Paulo Moura', - comment is 'Meta-interpreter for pure Prolog with only conjunctions as clause bodies.']). - - :- public(proof_tree/2). - :- mode(proof_tree(+goal, -tree), zero_or_more). - :- info(proof_tree/2, [ - comment is 'Constructs a proof tree for a goal.', - argnames is ['Goal', 'Tree']]). - - proof_tree(true, true) :- - !. - proof_tree((A, B), (PA, PB)) :- - !, - proof_tree(A, PA), - proof_tree(B, PB). - proof_tree(A, (A :- PB)) :- - ::clause(A, B), - proof_tree(B, PB). - -:- end_category. - - -:- category(tracer). - - :- info([ - version is 1.0, - date is 2004/5/5, - author is 'Paulo Moura', - comment is 'A simple tracer meta-interpreter for pure Prolog with only conjunctions as clause bodies.']). - - :- public(trace/1). - :- mode(trace(+goal), zero_or_more). - :- info(trace/1, [ - comment is 'Traces goal proof.', - argnames is ['Goal']]). - - trace(Goal) :- - trace(Goal, 1). - - trace(true, _) :- - !. - trace((A, B), Depth) :- - !, - trace(A, Depth), - trace(B, Depth). - trace(A, Depth) :- - write_trace(call, A, Depth), - clause(A, B), - Depth2 is Depth + 1, - trace(B, Depth2), - ( write_trace(exit, A, Depth) - ; - write_trace(redo, A, Depth), - fail). - trace(A, Depth) :- - write_trace(fail, A, Depth), - fail. - - write_trace(Port, Goal, Depth) :- - write(Depth), write(' '), write(Port), write(': '), writeq(Goal), nl. - -:- end_category. diff --git a/Logtalk/examples/metainterpreters/rules.lgt b/Logtalk/examples/metainterpreters/rules.lgt deleted file mode 100644 index 05b445092..000000000 --- a/Logtalk/examples/metainterpreters/rules.lgt +++ /dev/null @@ -1,50 +0,0 @@ - -:- category(engine). - - :- public(prove/1). - - :- public(if/1). - :- dynamic(if/1). - - :- op(200, fx, if). - :- op(100, xfx, then). - - prove(true) :- - !. - - prove([]) :- - !. - prove([Cond| Conds]) :- - !, - prove(Cond), - prove(Conds). - - prove(Fact) :- - ::clause(Fact, true). - prove(Conclusion) :- - ::clause(if Conds then Conclusion, true), - prove(Conds). - -:- end_category. - - -:- object(rules, - imports(engine)). - - :- public([weather/1, weekday/1, time/1, goto/1]). - :- dynamic([weather/1, weekday/1, time/1, goto/1]). - - :- dynamic(if/1). - - :- op(200, fx, if). - :- op(100, xfx, then). - - if [weather(sunny), weekday(weekend), time(day)] then goto(beach). - if [weather(raining), weekday(weekend), time(night)] then goto(cinema). - if [weekday(workday), time(day)] then goto(work). - - weather(raining). - weekday(weekend). - time(night). - -:- end_object. diff --git a/Logtalk/examples/metapredicates/NOTES.txt b/Logtalk/examples/metapredicates/NOTES.txt deleted file mode 100644 index d583e5abe..000000000 --- a/Logtalk/examples/metapredicates/NOTES.txt +++ /dev/null @@ -1,24 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This example shows the use of meta-predicates in Logtalk. Meta-predicates are -predicates whose head contains arguments that will be called as goals in the -body of the predicate definition. - -This example defines two objects: - - sort(_) - this is a parametric object containing a method that implements the - quicksort sorting algorithm; the parameter is interpreted as the type - of the elements being sorted - - tracer - this object implements a meta-predicate that is used by sort(_) to - trace the sorting algorithm steps \ No newline at end of file diff --git a/Logtalk/examples/metapredicates/SCRIPT.txt b/Logtalk/examples/metapredicates/SCRIPT.txt deleted file mode 100644 index ca46c394a..000000000 --- a/Logtalk/examples/metapredicates/SCRIPT.txt +++ /dev/null @@ -1,81 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(metapredicates(loader)). -... - - -% note that "user" is a pseudo-object representing the Prolog database -% this implies that the integer comparisons are done using the standard -% Prolog built-in predicates - -| ?- sort(user)::sort([3, 1, 4, 2, 9], Sorted). - -call: partition([1,4,2,9],3,_358,_359) -exit: partition([1,4,2,9],3,[1,2],[4,9]) -call: sort([1,2],_740) -call: partition([2],1,_967,_968) -exit: partition([2],1,[],[2]) -call: sort([],_1300) -exit: sort([],[]) -call: sort([2],_1539) -call: partition([],2,_1765,_1766) -exit: partition([],2,[],[]) -call: sort([],_2093) -exit: sort([],[]) -call: sort([],_2332) -exit: sort([],[]) -exit: sort([2],[2]) -exit: sort([1,2],[1,2]) -call: sort([4,9],_2831) -call: partition([9],4,_3058,_3059) -exit: partition([9],4,[],[9]) -call: sort([],_3391) -exit: sort([],[]) -call: sort([9],_3630) -call: partition([],9,_3856,_3857) -exit: partition([],9,[],[]) -call: sort([],_4184) -exit: sort([],[]) -call: sort([],_4423) -exit: sort([],[]) -exit: sort([9],[9]) -exit: sort([4,9],[4,9]) - -Sorted = [1,2,3,4,9] ? - -yes - - -% call the meta-predicate apply/2 directly: - -| ?- meta::test_this. - -1, meta - -yes - - -% send an apply/2 message to self: - -| ?- desc::test_self. - -2, desc - -yes - - -% send an apply/2 message from another object: - -| ?- test::test_obj. - -3, test - -yes diff --git a/Logtalk/examples/metapredicates/closures.lgt b/Logtalk/examples/metapredicates/closures.lgt deleted file mode 100644 index f3e9a447e..000000000 --- a/Logtalk/examples/metapredicates/closures.lgt +++ /dev/null @@ -1,56 +0,0 @@ - -/* Logtalk meta-predicates accept both goals and closures - as meta-arguments as illustrated in this example -*/ - - -:- object(meta). - - % the meta_predicate/1 directive below changes the interpretation of meta-calls on apply/2 - % clauses; the integer argument ("1") implies that the first argument is a closure that will - % be used to construct a goal by appending exactly one additional argument - - :- public(apply/2). - :- mode(apply(+callable, ?term), zero_or_more). - :- meta_predicate(apply(1, *)). - - apply(Closure, Arg) :- % the Logtalk compiler verifies that any closure which is a - call(Closure, Arg). % meta-argument is used within a call/N method that honors the - % meta-predicate directive (in this case, apply(1, *) => call/2) - - :- public(test_this/0). % simple predicate for testing calls to a local meta-predicate - - test_this :- - apply(foo(X), Y), - write((X, Y)), nl. - - foo(1, meta). - -:- end_object. - - -:- object(desc, - extends(meta)). - - :- public(test_self/0). % simple predicate for testing calls to a meta-predicate - % defined in an ancestor object - test_self :- - ::apply(foo(X), Y), - write((X, Y)), nl. - - foo(2, desc). - -:- end_object. - - -:- object(test). - - :- public(test_obj/0). % simple predicate for testing calls to a meta-predicate - % defined in another object - test_obj :- - meta::apply(foo(X), Y), - write((X, Y)), nl. - - foo(3, test). - -:- end_object. diff --git a/Logtalk/examples/metapredicates/loader.lgt b/Logtalk/examples/metapredicates/loader.lgt deleted file mode 100644 index ce70eae59..000000000 --- a/Logtalk/examples/metapredicates/loader.lgt +++ /dev/null @@ -1,4 +0,0 @@ - -:- initialization(( - logtalk_load(library(types_loader), [reload(skip)]), % allow for static binding - logtalk_load([closures, metapredicates]))). diff --git a/Logtalk/examples/metapredicates/metapredicates.lgt b/Logtalk/examples/metapredicates/metapredicates.lgt deleted file mode 100644 index 5eea4f633..000000000 --- a/Logtalk/examples/metapredicates/metapredicates.lgt +++ /dev/null @@ -1,79 +0,0 @@ - -% example adopted from: -% Programming Language Prolog Part 2, Modules -% Committee Draft - January 14, 1998 X3J17/97/5 - -:- object(tracer). - - :- info([ - version is 2.1, - author is 'Paulo Moura', - date is 2006/9/17, - comment is 'Tracer for a goal call, exit, and fail ports.']). - - :- public(trace/1). - :- meta_predicate(trace(::)). % changes interpretation of meta-calls on trace/1 clauses - :- mode(trace(+callable), zero_or_more). - :- info(trace/1, [ - comment is 'Traces goal execution.', - argnames is ['Goal']]). - - trace(Goal) :- - write('call: '), writeq(Goal), nl, - call(Goal), % Goal is called in the context of the object sending the message trace/1 - write('exit: '), writeq(Goal), nl. - - trace(Goal) :- - write('fail: '), writeq(Goal), nl, - fail. - -:- end_object. - - -% sort code adopted from an example on the SICStus Prolog User Manual -% meta-predicate example taken from Prolog Part 2, Modules - Committee Draft - -:- object(sort(_Type)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'List sorting parameterized by the type of the list elements.']). - - :- uses(list, [append/3]). % calls to append(...) will be translated to list::append(...) - :- uses(tracer, [trace/1]). % calls to trace(...) will be translated to tracer::trace(...) - - :- calls(comparingp). - - :- public(sort/2). - :- mode(sort(+list, -list), one). - :- info(sort/2, [ - comment is 'Sorts a list in ascending order (quicksort algorithm).', - argnames is ['List', 'Sorted']]). - - :- private(partition/4). - :- mode(partition(+list, +nonvar, -list, -list), one). - :- info(partition/4, [ - comment is 'Partition a list in two lists containing the elements smaller and larger than a pivot.', - argnames is ['List', 'Pivot', 'Small', 'Large']]). - - sort([], []). - - sort([Head| Tail], Sorted) :- - trace(partition(Tail, Head, Small, Large)), - trace(sort(Small, Sorted1)), - trace(sort(Large, Sorted2)), - append(Sorted1, [Head| Sorted2], Sorted). - - partition([], _, [], []). - - partition([Head| Tail], Pivot, Small, Large) :- - parameter(1, Type), - ( Type::(Head < Pivot) -> - Small = [Head| Small1], Large = Large1 - ; Small = Small1, Large = [Head| Large1] - ), - partition(Tail, Pivot, Small1, Large1). - -:- end_object. diff --git a/Logtalk/examples/mi/NOTES.txt b/Logtalk/examples/mi/NOTES.txt deleted file mode 100644 index f2cc25dff..000000000 --- a/Logtalk/examples/mi/NOTES.txt +++ /dev/null @@ -1,39 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -There are two examples in this folder. The first one is an adoption of a -multi-inheritance C++ example found on the D. M. Capper book "Introducing -C++ for Scientists, Engineers and Mathematicians" published by -Springer-Verlag. It uses dynamic predicates for storing state. The second -example is a variant of the first one using parametric objects. - -This example defines the following objects: - - space - this object space stores spatial coordinates using a dynamic - predicate - - time - this object stores a time stamp using a dynamic predicate - - space_time - this object inherits from both the objects space and time - - - space(_,_,_) - similar to object space but using parameters instead of dynamic - predicates - - time(_) - similar to object space but using a parameter instead of a dynamic - predicate - - space_time(_,_,_,_) - this object inherits from both the objects space(_,_,_) and time(_) diff --git a/Logtalk/examples/mi/SCRIPT.txt b/Logtalk/examples/mi/SCRIPT.txt deleted file mode 100644 index 050138d11..000000000 --- a/Logtalk/examples/mi/SCRIPT.txt +++ /dev/null @@ -1,95 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(mi(loader)). -... - - -% set a point in the space-time: - -| ?- space_time::rotate(1, 2, 3). -yes - -| ?- space_time::translate(4). -yes - - -% verify it: - -| ?- space_time::xyzt(X, Y, Z, T). - -T = 4, -X = 1, -Y = 2, -Z = 3 ? -yes - - -% enumerate space_time public predicates: - -| ?- space_time::(current_predicate(Functor/Arity), functor(Pred, Functor, Arity), predicate_property(Pred, declared_in(Object))). - -Pred = xyzt(_A,_B,_C,_D), -Arity = 4, -Object = space_time, -Functor = xyzt ? ; - -Pred = xyz(_A,_B,_C), -Arity = 3, -Object = space, -Functor = xyz ? ; - -Pred = rotate(_A,_B,_C), -Arity = 3, -Object = space, -Functor = rotate ? ; - -Pred = t(_A), -Arity = 1, -Object = time, -Functor = t ? ; - -Pred = translate(_A), -Arity = 1, -Object = time, -Functor = translate ? ; - -no - - - -% get the origin distance from a point in the space-time(_, _, _, _): - -| ?- space_time(2,3,4,7)::distance(D). - -D = 5.385164807134504 -yes - -| ?- space_time(2,3,4,7)::time(T). - -T = 7 -yes - - -% enumerate space_time(_, _, _, _) public predicates: - -| ?- space_time(2,3,4,7)::(current_predicate(Functor/Arity), functor(Pred, Functor, Arity), predicate_property(Pred, declared_in(Object))). - -Pred = distance(_A), -Arity = 1, -Object = space(_B,_C,_D), -Functor = distance ? ; - -Pred = time(_A), -Arity = 1, -Object = time(_B), -Functor = time ? ; - -no diff --git a/Logtalk/examples/mi/loader.lgt b/Logtalk/examples/mi/loader.lgt deleted file mode 100644 index c84557ac5..000000000 --- a/Logtalk/examples/mi/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(mi)). diff --git a/Logtalk/examples/mi/mi.lgt b/Logtalk/examples/mi/mi.lgt deleted file mode 100644 index b15e6c727..000000000 --- a/Logtalk/examples/mi/mi.lgt +++ /dev/null @@ -1,93 +0,0 @@ - -:- object(space). - - :- public(xyz/3). - :- mode(xyz(?integer, ?integer, ?integer), zero_or_one). - - :- private(xyz_/3). - :- mode(xyz_(?integer, ?integer, ?integer), zero_or_one). - :- dynamic(xyz_/3). - - :- public(rotate/3). - :- mode(rotate(+integer, +integer, +integer), zero_or_one). - - xyz(X, Y, Z) :- - ::xyz_(X, Y, Z). - - rotate(X, Y, Z) :- - integer(X), - integer(Y), - integer(Z), - ::retractall(xyz_(_, _, _)), - ::assertz(xyz_(X, Y, Z)). - -:- end_object. - - -:- object(time). - - :- public(t/1). - :- mode(t(?integer), zero_or_one). - - :- private(t_/1). - :- mode(t_(?integer), zero_or_one). - :- dynamic(t_/1). - - :- public(translate/1). - :- mode(translate(+integer), zero_or_one). - - t(T) :- - ::t_(T). - - translate(T) :- - integer(T), - ::retractall(t_(_)), - ::assertz(t_(T)). - -:- end_object. - - -:- object(space_time, - extends(space, time)). - - :- public(xyzt/4). - :- mode(xyzt(?integer, ?integer, ?integer, ?integer), zero_or_one). - - xyzt(X, Y, Z, T) :- - ::xyz(X, Y, Z), - ::t(T). - -:- end_object. - - - - -:- object(space(_X,_Y,_Z)). - - :- public(distance/1). - :- mode(xyz(?nunber), one). - - distance(Distance) :- - parameter(1, X), - parameter(2, Y), - parameter(3, Z), - Distance is sqrt(X*X+Y*Y+Z*Z). - -:- end_object. - - -:- object(time(_T)). - - :- public(time/1). - :- mode(time(?integer), zero_or_one). - - time(Time) :- - parameter(1, Time). - -:- end_object. - - -:- object(space_time(X, Y, Z, T), - extends(space(X, Y, Z), time(T))). - -:- end_object. diff --git a/Logtalk/examples/miscellaneous/NOTES.txt b/Logtalk/examples/miscellaneous/NOTES.txt deleted file mode 100644 index bad553d81..000000000 --- a/Logtalk/examples/miscellaneous/NOTES.txt +++ /dev/null @@ -1,15 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -hanoi.lgt - Towers of Hanoi example - -queens.lgt - N-Queens example diff --git a/Logtalk/examples/miscellaneous/SCRIPT.txt b/Logtalk/examples/miscellaneous/SCRIPT.txt deleted file mode 100644 index f5268d9da..000000000 --- a/Logtalk/examples/miscellaneous/SCRIPT.txt +++ /dev/null @@ -1,36 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(miscellaneous(loader)). -... - - -% towers of hanoi using three disks: - -| ?- hanoi::run(3). - -Move a disk from left to right. -Move a disk from left to middle. -Move a disk from right to middle. -Move a disk from left to right. -Move a disk from middle to left. -Move a disk from middle to right. -Move a disk from left to right. - -yes - - -% placing eight queens in a chess table: - -| ?- queens::queens(8). - -[1-5,2-7,3-2,4-6,5-3,6-1,7-4,8-8] - -yes diff --git a/Logtalk/examples/miscellaneous/hanoi.lgt b/Logtalk/examples/miscellaneous/hanoi.lgt deleted file mode 100644 index 1d0d4867e..000000000 --- a/Logtalk/examples/miscellaneous/hanoi.lgt +++ /dev/null @@ -1,44 +0,0 @@ - -:- object(hanoi). - - - :- info([ - version is 1.0, - date is 1998/3/23, - author is 'Paulo Moura', - comment is 'Towers of Hanoi.']). - - - :- public(run/1). - :- mode(run(+integer), one). - - :- info(run/1, [ - comment is 'Solves the towers of Hanoi problem for the specified number of disks.', - argnames is ['Disks']]). - - - run(Disks) :- - move(Disks, left, middle, right). - - - move(1, Left, _, Right):- - !, - report(Left, Right). - - move(Disks, Left, Aux, Right):- - Disks2 is Disks - 1, - move(Disks2, Left, Right, Aux), - report(Left, Right), - move(Disks2, Aux, Left, Right). - - - report(Pole1, Pole2):- - write('Move a disk from '), - writeq(Pole1), - write(' to '), - writeq(Pole2), - write('.'), - nl. - - -:- end_object. diff --git a/Logtalk/examples/miscellaneous/loader.lgt b/Logtalk/examples/miscellaneous/loader.lgt deleted file mode 100644 index bd3842d9d..000000000 --- a/Logtalk/examples/miscellaneous/loader.lgt +++ /dev/null @@ -1,4 +0,0 @@ - -:- initialization(( - logtalk_load(library(types_loader), [reload(skip)]), % allow for static binding - logtalk_load([hanoi, queens]))). diff --git a/Logtalk/examples/miscellaneous/queens.lgt b/Logtalk/examples/miscellaneous/queens.lgt deleted file mode 100644 index 2b13a5363..000000000 --- a/Logtalk/examples/miscellaneous/queens.lgt +++ /dev/null @@ -1,216 +0,0 @@ -% example adapted form: - -% File : Queens.Pl -% Author : Richard A O'Keefe -% Updated: 8 Feb 84 -% Purpose: Solve the N queens problem in Prolog. - - -:- object(queens). - - - :- uses(list, [keysort/2, member/2]). - - - :- public(queens/1). - :- mode(queens(+integer), one). - - - :- private(forbidden/4). - :- mode(forbidden(+integer, +integer, +integer, +integer), zero_or_one). - - :- private(least_room_to_move/4). - :- mode(least_room_to_move(+list, -integer, -integer, -list), zero_or_more). - - :- private(lr2m/6). - :- mode(lr2m(+list, +integer, +integer, -integer, -integer, -list), zero_or_more). - - :- private(make_initial_table/2). - :- mode(make_initial_table(+integer, -list), zero_or_one). - - :- private(make_initial_table/3). - :- mode(make_initial_table(+integer, +list, -list), zero_or_one). - - :- private(number_list/2). - :- mode(number_list(+integer, -list), one). - - :- private(place/2). - :- mode(place(+list, -list), zero_or_more). - - :- private(prune/4). - :- mode(prune(+list, +integer, +integer, -list), zero_or_more). - - :- private(prune/5). - :- mode(prune(+list, +integer, +integer, +integer, -list), zero_or_more). - - :- private(shorter/2). - :- mode(shorter(+list, +list), zero_or_one). - - -/* The N-queens problem is to place N queens on an NxN chessboard so - that no two queens attack each other. Suppose we have a queen in - (Row1,Col1) and a queen in (Row2,Col2). They attack each other if - 1. Same rank: Row1 = Row2. - 2. Same file: Col1 = Col2. - 3. Same NW-SE diagonal Row2 - Row1 = Col2 - Col1. - 4. Same SW-NE diagonal Row2 - Row1 = Col1 - Col2. - We can express 3 and 4 another way: - 3. Row2 - Col2 = Row1 - Col1. - 4. Row2 + Col2 = Row1 + Col1. - So each of the N queens has four numbers associated with it, - (Row,Col,Dif,Sum), and any two queens must have different numbers - in all these positions. The possible values are - Row : 1 .. N - Col : 1 .. N - Sum : 1 .. 2N - Dif : 1-N .. N-1 - - The first question is, how shall we represent the board? - It is sufficient to have a table indexed by rows, whose elements - are the columns in which the corresponding queen is placed. For - example, with rows horizontal and columns vertical - 1 2 3 4 -column / row - +---+---+---+---+ - | | Q | | | 1 - +---+---+---+---+ - | | | | Q | 2 - +---+---+---+---+ - | Q | | | | 3 - +---+---+---+---+ - | | | Q | | 4 - +---+---+---+---+ - - could be represented by board(2,4,1,3). - - How are we going to place the queens? The first idea that springs - to mind is to place them one after another, but we can do better than - that. Let us maintain a table of (QueenRow/PossibleColumns), and at - each step pick the queen with the fewest possible columns, place it, - and prune the remaining sets. - - Let's start by writing a predicate to generate this table. For N=4 - it will look like [1/[1,2,3,4], 2/[1,2,3,4], 3/[1,2,3,4], 4/[1,2,3,4]]. -*/ - - make_initial_table(N, Table) :- - number_list(N, PossibleColumns), % set of all possible columns - make_initial_table(N, PossibleColumns, Table). - - - make_initial_table(0, _, []) :- !. - make_initial_table(N, PossibleColumns, [N/PossibleColumns|Table]) :- - M is N-1, - % in C-Prolog we could write succ(M, N) which would eliminate - % the need for the cut in the previous clause - make_initial_table(M, PossibleColumns, Table). - - - number_list(0, []) :- !. - number_list(N, [N| List]) :- - M is N-1, % see previous comment - number_list(M, List). - - -/* This actually generates the reverse of what I said, so we'd get - [4/[4,3,2,1], 3/[4,3,2,1], 2/[4,3,2,1], 1/[4,3,2,1]], - but since it was to be a set of number/set pairs, that's ok. - We shall only be operating on these sets an element at a time, - so it the order doesn't matter. - - Now the problem is solved if there are no queens left to place. - Otherwise, we pick the queen with the fewest possible columns, - backtrack over those possible columns, prune the possible columns - sets of the remaining queens, and recur. - - We are given a set of Row/PossCols pairs for the unplaced queens, - and we are to return a set of Row-Col pairs saying where we put - the queens. -*/ - - place([], []). - place(UnplacedQueens, [Queen-Col|Placement]) :- - least_room_to_move(UnplacedQueens, Queen, Columns, OtherQueens), - member(Col, Columns), % backtrack over possible places - prune(OtherQueens, Queen, Col, RemainingQueens), - place(RemainingQueens, Placement). - - -/* If you haven't done this sort of thing before, least_room_to_move - can be quite tricky. The idea is the we wander down the list of - pairs, keeping the current best pair apart, and when we find that - there is a better pair we have to put the current pair back in the list. - But because these are sets, it doesn't matter *where* the pairs go in - the list. Note that we don't need a cut in the first clause of place/2 - because least_room_to_move will fail on an empty list. -*/ - - least_room_to_move([Q/C|Table], Qbest, Cbest, Rest) :- - lr2m(Table, Q, C, Qbest, Cbest, Rest). - -/* This uses accumulator passing. I really have to explain this program - to you in person. -*/ - - lr2m([], Q, C, Q, C, []). - lr2m([NewQ/NewC|Table], OldQ, OldC, MinQ, MinC, [OldQ/OldC|Rest]) :- - shorter(NewC, OldC), - !, - lr2m(Table, NewQ, NewC, MinQ, MinC, Rest). - lr2m([Pair|Table], OldQ, OldC, MinQ, MinC, [Pair|Rest]) :- - lr2m(Table, OldQ, OldC, MinQ, MinC, Rest). - - -/* shorter(L1, L2) is true when the list L1 is strictly shorter than - the list L2 -*/ - shorter([], [_|_]). - shorter([_|L1], [_|L2]) :- - shorter(L1, L2). - - -/* Now we have to code prune. To prune all the queens, we prune each - queen in turn. -*/ - prune([], _, _, []). - prune([Queen/Columns|Queens], Row, Col, [Queen/Pruned|RestPruned]) :- - prune(Columns, Queen, Row, Col, Pruned), - prune(Queens, Row, Col, RestPruned). - -/* To prune a single queen, we have to eliminate all the positions - forbidden by the queen wee have just placed. -*/ - - prune([], _, _, _, []). - prune([Col2|Cols], Row2, Row1, Col1, Permitted) :- - forbidden(Row1, Col1, Row2, Col2), - !, - prune(Cols, Row2, Row1, Col1, Permitted). - prune([Col2|Cols], Row2, Row1, Col1, [Col2|Permitted]) :- - prune(Cols, Row2, Row1, Col1, Permitted). - - -/* Finally, since we have ensured that two queens are automatically in - different rows, we have only to check rules 2, 3, and 4. -*/ - forbidden(_, Col, _, Col). - forbidden(Row1, Col1, Row2, Col2) :- - Row2 - Col2 =:= Row1 - Col1. - forbidden(Row1, Col1, Row2, Col2) :- - Row2 + Col2 =:= Row1 + Col1. - - -/* The last thing left for us to do is to write the top level predicate - that ties all the pieces together. Because the 'place' predicate - may place the queens in any order, we keysort the list to make it more - readable. I'm afraid I had that in mind when I decided that it would - be a list of Row-Col pairs. I seem to recommend sorting for everything. - Well, it IS a panacea. -*/ - queens(N) :- - make_initial_table(N, Table), - place(Table, Placement), - keysort(Placement, DisplayForm), - write(DisplayForm), nl. - - -:- end_object. diff --git a/Logtalk/examples/modules/NOTES.txt b/Logtalk/examples/modules/NOTES.txt deleted file mode 100644 index cb0d490b4..000000000 --- a/Logtalk/examples/modules/NOTES.txt +++ /dev/null @@ -1,16 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This example illustrates compilation of Prolog module files as objects. - -Due to the lack of standardization of Prolog module systems, the module -files must use only a common subset of Prolog module directives. Consult -the "Prolog Integration and Migration Guide" in the Logtalk documentation -for details. diff --git a/Logtalk/examples/modules/SCRIPT.txt b/Logtalk/examples/modules/SCRIPT.txt deleted file mode 100644 index 36a620767..000000000 --- a/Logtalk/examples/modules/SCRIPT.txt +++ /dev/null @@ -1,60 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by compiling and loading the Prolog module files as objects: - -| ?- logtalk_load(modules(loader)). -... - - -% call one of the module exported predicates using message sending: - -| ?- test::names. - -paulo -carlos -helena -yes - - -% same goal as above but the call is made using a meta-predicate -% imported from other module: - -| ?- test::test. - -paulo -carlos -helena -yes - - -% test the compilation of the module export/1 directive; module -% exported predicates become public predicates: - -| ?- exports::current_predicate(Pred). - -Pred = p/1 -yes - -| ?- exports::predicate_property(p(_), Prop). - -Prop = public ; -Prop = static ; -Prop = declared_in(exports) ; -Prop = defined_in(exports) -yes - - -% call the module exported/public predicate using message sending: - -| ?- exports::p(N). - -N = 1 ; -N = 2 ; -N = 3 -yes diff --git a/Logtalk/examples/modules/exports.lgt b/Logtalk/examples/modules/exports.lgt deleted file mode 100644 index 6970adaac..000000000 --- a/Logtalk/examples/modules/exports.lgt +++ /dev/null @@ -1,8 +0,0 @@ - -:- module(exports). - -:- export([p/1]). - -p(1). -p(2). -p(3). diff --git a/Logtalk/examples/modules/list.lgt b/Logtalk/examples/modules/list.lgt deleted file mode 100644 index d1671f81c..000000000 --- a/Logtalk/examples/modules/list.lgt +++ /dev/null @@ -1,9 +0,0 @@ -:- module(list, [contained/2, notcontained/2]). - -contained(H, [H| _]). -contained(H, [_| T]) :- - contained(H, T). - -notcontained(H, L) :- - \+ contained(H, L). - diff --git a/Logtalk/examples/modules/loader.lgt b/Logtalk/examples/modules/loader.lgt deleted file mode 100644 index 9b745e71a..000000000 --- a/Logtalk/examples/modules/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load([exports, list, meta, test])). diff --git a/Logtalk/examples/modules/meta.lgt b/Logtalk/examples/modules/meta.lgt deleted file mode 100644 index 24562df01..000000000 --- a/Logtalk/examples/modules/meta.lgt +++ /dev/null @@ -1,7 +0,0 @@ - -:- module(meta, [meta/1]). - -:- meta_predicate(meta(:)). - -meta(Goal) :- - call(Goal). diff --git a/Logtalk/examples/modules/test.lgt b/Logtalk/examples/modules/test.lgt deleted file mode 100644 index 503fba12c..000000000 --- a/Logtalk/examples/modules/test.lgt +++ /dev/null @@ -1,14 +0,0 @@ - -:- module(test, [test/0, names/0]). - -:- use_module(list, [contained/2]). -:- use_module(meta, [meta/1]). - -names :- - contained(P, [paulo, carlos, helena]), - write(P), nl, - fail. -names. - -test :- - meta(names). diff --git a/Logtalk/examples/msglog/NOTES.txt b/Logtalk/examples/msglog/NOTES.txt deleted file mode 100644 index 9210a2dc4..000000000 --- a/Logtalk/examples/msglog/NOTES.txt +++ /dev/null @@ -1,13 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -If you need more than one message recorder, just create a new prototype -as an extension of the object msglog. - diff --git a/Logtalk/examples/msglog/SCRIPT.txt b/Logtalk/examples/msglog/SCRIPT.txt deleted file mode 100644 index 342741274..000000000 --- a/Logtalk/examples/msglog/SCRIPT.txt +++ /dev/null @@ -1,53 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(msglog(loader)). -... - - -% assume that all library entities have been loaded... - -% start recording user messages: - -| ?- msglog::record. - -yes - -% send some messages: - -| ?- list::member(X, [1, 2, 3]). - -X = 1 ; -X = 2 ; -X = 3 ; -no - -| ?- character::is_alpha(p). - -yes - -| ?- integer::between(1, 4, N). - -N = 1 ; -N = 2 ; -N = 3 ; -N = 4 ; -no - -% stop recording and print message log: - -| ?- msglog::(stop, print). - -list::member(X, [1, 2, 3]). -character::is_alpha(p). -integer::between(1, 4, N). - -yes - diff --git a/Logtalk/examples/msglog/loader.lgt b/Logtalk/examples/msglog/loader.lgt deleted file mode 100644 index edaf88e0c..000000000 --- a/Logtalk/examples/msglog/loader.lgt +++ /dev/null @@ -1,4 +0,0 @@ - -:- initialization(( - logtalk_load(library(types_loader), [reload(skip)]), % allow for static binding - logtalk_load(msglog, [events(on)]))). diff --git a/Logtalk/examples/msglog/msglog.lgt b/Logtalk/examples/msglog/msglog.lgt deleted file mode 100644 index 6da2cb4ab..000000000 --- a/Logtalk/examples/msglog/msglog.lgt +++ /dev/null @@ -1,83 +0,0 @@ - -:- object(msglog, - implements(monitoring)). - - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2007/01/13, - comment is 'Monitor for recording, replaying, and saving user messages.']). - - - :- public(record/0). - :- mode(record, one). - :- info(record/0, - [comment is 'Starts recording messages.']). - - :- public(stop/0). - :- mode(stop, one). - :- info(stop/0, - [comment is 'Stops recording messages.']). - - :- public(replay/0). - :- mode(replay, one). - :- info(replay/0, - [comment is 'Replays all recorded messages.']). - - :- public(print/0). - :- mode(print, one). - :- info(print/0, - [comment is 'Prints recorded messages, one per line.']). - - :- public(erase/0). - :- mode(erase, one). - :- info(erase/0, - [comment is 'Erases recorded messages.']). - - - :- private(log_/2). - :- dynamic(log_/2). - :- mode(log_(+object, +nonvar), zero_or_more). - :- info(log_/2, - [comment is 'Table of recorded messages.', - argnames is ['Object', 'Message']]). - - - record :- - self(Self), - abolish_events(_, _, _, _, Self), - define_events(before, _, _, user, Self). - - - stop :- - self(Self), - abolish_events(_, _, _, _, Self). - - - replay :- - self(Self), - abolish_events(_, _, _, _, Self), - forall(::log_(Object, Message), {Object::Message}). - - - print :- - forall( - ::log_(Object, Message), - (writeq(Object), write('::'), writeq(Message), write('.'), nl)). - - - erase :- - ::retractall(log_(_, _)). - - - before(Object, Message, _) :- - self(Self), - (Self = Object -> - true - ; - ::assertz(log_(Object, Message))). - - -:- end_object. - diff --git a/Logtalk/examples/operators/NOTES.txt b/Logtalk/examples/operators/NOTES.txt deleted file mode 100644 index ac0198b95..000000000 --- a/Logtalk/examples/operators/NOTES.txt +++ /dev/null @@ -1,26 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains examples of the used of operators inside objects -and categories: - -double.lgt - Simple object containing clauses using an infix operator. - -triple.lgt - Simple object reading from a file (triple.txt), and asserting into - self, clauses that use an infix operator. - -reverse.lgt - Simple object reading from a file (next.txt), and writing to - another file (previous.txt), clauses that use infix operators. - -local.lgt - Simple example of defining an operator local to a source file. diff --git a/Logtalk/examples/operators/SCRIPT.txt b/Logtalk/examples/operators/SCRIPT.txt deleted file mode 100644 index 08512322d..000000000 --- a/Logtalk/examples/operators/SCRIPT.txt +++ /dev/null @@ -1,97 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(operators(loader)). -... - - -% operators declared inside an object are not visible outside: - -| ?- double::(I double J). - -Syntax error: Operator expected - - -% you must use instead functor notation: - -| ?- double::double(I, J). - -I = 1 -J = 2 ; - -I = 2 -J = 4 ; - -I = 3 -J = 6 - -yes - - -% operators also affect inputing of terms, enabling this example to work: - -| ?- triple::triple(I, J). - -I = 1 -J = 3 ; - -I = 2 -J = 6 ; - -I = 3 -J = 9 - -yes - - -% check the file "previous.txt" generated from the file "next.txt" by the object "reverse" -% by opening the files on a text editor - - -% the "edge" operator on the "local.lgt" source file is not globally visible: - -| ?- graph1::(N1 edge N2). -uncaught exception: error(syntax_error('user_input:10 (char:13) ) or operator expected'),read_term/3) - - -% you must use instead functor notation: - -| ?- graph1::edge(N1, N2). - -N1 = a -N2 = b ; - -N1 = a -N2 = c ; - -N1 = b -N2 = d ; - -N1 = c -N2 = d - -yes - - -| ?- graph1::path(a, d, Path). - -Path = [a, b, d] ; - -Path = [a, c, d] - -yes - - -% confirm that the "edge" operator have not became global: - -| ?- current_op(P, T, edge). - -no - diff --git a/Logtalk/examples/operators/double.lgt b/Logtalk/examples/operators/double.lgt deleted file mode 100644 index b576471c7..000000000 --- a/Logtalk/examples/operators/double.lgt +++ /dev/null @@ -1,21 +0,0 @@ - -:- object(double). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/2/16, - comment is 'Contains a simple table of facts for testing operator handling code.']). - - :- public(double/2). - - :- op(500, xfx, double). % local object operators, not visible outside this object - - - 1 double 2. - 2 double 4. - 3 double 6. - - -:- end_object. diff --git a/Logtalk/examples/operators/loader.lgt b/Logtalk/examples/operators/loader.lgt deleted file mode 100644 index 98102b279..000000000 --- a/Logtalk/examples/operators/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load([double, triple, reverse, local])). diff --git a/Logtalk/examples/operators/local.lgt b/Logtalk/examples/operators/local.lgt deleted file mode 100644 index f90d86802..000000000 --- a/Logtalk/examples/operators/local.lgt +++ /dev/null @@ -1,45 +0,0 @@ - -% simple example of defining an operator local to a source file - - -:- op(200, xfx, edge). % global operator, visible within all - % entities defined in this source file - -:- object(graph). - - :- public(path/3). - :- public((edge)/2). - - path(Start, End, [Start, End]) :- - ::(Start edge End). - path(Start, End, [Start| Path]) :- - ::(Start edge Node), - path(Node, End, Path). - -:- end_object. - - -:- object(graph1, - extends(graph)). - - a edge b. - a edge c. - b edge d. - c edge d. - -:- end_object. - - -:- object(graph2, - extends(graph)). - - v1 edge v2. - v1 edge v3. - v2 edge v4. - v3 edge v4. - -:- end_object. - - -:- op(0, xfx, edge). % "undefine" the operator, effectively - % making it local to this source file diff --git a/Logtalk/examples/operators/next.txt b/Logtalk/examples/operators/next.txt deleted file mode 100644 index b4bae5459..000000000 --- a/Logtalk/examples/operators/next.txt +++ /dev/null @@ -1,5 +0,0 @@ -0 next 1. -1 next 2. -2 next 3. -3 next 4. -4 next 5. diff --git a/Logtalk/examples/operators/reverse.lgt b/Logtalk/examples/operators/reverse.lgt deleted file mode 100644 index cde883d29..000000000 --- a/Logtalk/examples/operators/reverse.lgt +++ /dev/null @@ -1,34 +0,0 @@ - -:- object(reverse). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/2/16, - comment is 'Reads and writes a simple table of facts from and to files for testing operator handling code.']). - - :- op(500, xfx, next). % local object operators, not visible outside this object - :- op(500, xfx, previous). - - :- initialization(reverse_file). - - - reverse_file :- - open('next.txt', read, RStream), - open('previous.txt', write, WStream), - read(RStream, Term), % local operators are used when reading terms ... - process(Term, RStream, WStream). - - process(end_of_file, RStream, WStream) :- - close(RStream), - close(WStream). - - process(X next Y, RStream, WStream) :- - write(WStream, Y previous X), % ... and when writing terms - write(WStream, '.'), nl(WStream), - read(RStream, Next), - process(Next, RStream, WStream). - - -:- end_object. diff --git a/Logtalk/examples/operators/triple.lgt b/Logtalk/examples/operators/triple.lgt deleted file mode 100644 index 438864e56..000000000 --- a/Logtalk/examples/operators/triple.lgt +++ /dev/null @@ -1,34 +0,0 @@ - -:- object(triple). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/2/16, - comment is 'Read and asserts a simple table of facts from a file for testing operator handling code.']). - - :- public(triple/2). - :- dynamic(triple/2). - - :- op(500, xfx, triple). - - :- initialization(read_from_file). - - - read_from_file :- - open('triple.txt', read, Stream), - read(Stream, Term), - process(Stream, Term). - - process(Stream, end_of_file) :- - close(Stream), - !. - - process(Stream, Term) :- - assertz(Term), - read(Stream, Next), - process(Stream, Next). - - -:- end_object. diff --git a/Logtalk/examples/operators/triple.txt b/Logtalk/examples/operators/triple.txt deleted file mode 100644 index 52fcb72b0..000000000 --- a/Logtalk/examples/operators/triple.txt +++ /dev/null @@ -1,3 +0,0 @@ -1 triple 3. -2 triple 6. -3 triple 9. diff --git a/Logtalk/examples/parametric/NOTES.txt b/Logtalk/examples/parametric/NOTES.txt deleted file mode 100644 index 426865f8a..000000000 --- a/Logtalk/examples/parametric/NOTES.txt +++ /dev/null @@ -1,12 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains some examples of parametric objects, dealing with -lists, time and date values, and rectangles. diff --git a/Logtalk/examples/parametric/SCRIPT.txt b/Logtalk/examples/parametric/SCRIPT.txt deleted file mode 100644 index e5de250b9..000000000 --- a/Logtalk/examples/parametric/SCRIPT.txt +++ /dev/null @@ -1,88 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(parametric(loader)). -... - - -% some queries using the list parametric object: - -| ?- [1, 2, 3]::member(X). - -X = 1 ; -X = 2 ; -X = 3 ; -no - -| ?- [1, 2, 3]::last(X). - -X = 3 -yes - -| ?- [1, 2, 3]::nextto(2, Y). - -Y = 3 -yes - -| ?- []::member(X). - -no - - -% some queries using the time and date parametric objects: - -| ?- date(Year, Month, Day)::today. - -Year = 2000 -Month = 8 -Day = 15 -yes - - -| ?- date(Year, _, _)::(today, \+ leap_year). - -Year = 2002 -yes - - -| ?- time(Hours, Mins, Secs)::now. - -Hours = 13 -Mins = 52 -Secs = 42 -yes - - -| ?- R = rectangle(W, H, X, Y), R::init, R::move(3, 4, NR), NR::position(X2, Y2). - -R = rectangle(2, 1, 0, 0) -W = 2 -H = 1 -X = 0 -Y = 0 -NR = rectangle(2, 1, 3, 4) -X2 = 3 -Y2 = 4 -yes - - -% some queries with parametric objects that define "setter" -% methods that return updated object identifiers: - -| ?- person(sally, 20)::grow_older(NewId). - -NewId = person(sally, 21) -yes - - -| ?- employee(sally, 21, 1200)::give_raise(250, NewId). - -NewId = employee(sally, 21, 1450) -yes diff --git a/Logtalk/examples/parametric/loader.lgt b/Logtalk/examples/parametric/loader.lgt deleted file mode 100644 index 8fe18af7f..000000000 --- a/Logtalk/examples/parametric/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(parametric)). diff --git a/Logtalk/examples/parametric/parametric.lgt b/Logtalk/examples/parametric/parametric.lgt deleted file mode 100644 index 4d13918f5..000000000 --- a/Logtalk/examples/parametric/parametric.lgt +++ /dev/null @@ -1,349 +0,0 @@ - -/* This example illustrates how to associate a set of predicates with a - compound term. Parameters can be accessed from within an object by - using the execution-context built-in methods this/1 and parameter/2; - both alternatives are illustrated below. -*/ - - - -/* The first parametric object defines some useful predicates for working - with lists. -*/ - - -% dealing with non-empty lists is easy: - -:- object(.(_, _)). % note that the [X, Y, ...] notation - % is just syntactic sugar for ./2 - :- public(last/1). - :- mode(last(?term), zero_or_one). - - :- public(member/1). - :- mode(member(?term), zero_or_more). - - :- public(nextto/2). - :- mode(nextto(?term, ?term), zero_or_more). - - last(Last) :- - this([Head| Tail]), - last(Tail, Head, Last). - - last([], Last, Last). - last([Head| Tail], _, Last) :- - last(Tail, Head, Last). - - member(Element) :- - this(List), - member(Element, List). - - member(Element, [Element| _]). - member(Element, [_| Tail]) :- - member(Element, Tail). - - nextto(X, Y) :- - this([Head| Tail]), - nextto(X, Y, [Head| Tail]). - - nextto(X, Y, [X, Y| _]). - nextto(X, Y, [_| Tail]) :- - nextto(X, Y, Tail). - -:- end_object. - - -% dealing with empty lists must also be done but it's a bit tricky: - -:- object([], % the empty list is an atom, not a compound term, - extends([.(_, _)])). % so the "extends" relation would be always wrong - - last(_) :- % the trick is to redefine all inherited predicates - fail. % to do the right thing for empty lists - - member(_) :- - fail. - - nextto(_, _) :- - fail. - -:- end_object. - - - -/* The next two parametric objects represent time and date values as - compound terms using the object's identifiers. -*/ - - -:- object(date(_Year, _Month, _Day)). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2005/9/5, - comment is 'Dates as parametric objects.', - parnames is ['Year', 'Month', 'Day']]). - - :- public(year/1). - :- mode(year(?integer), one). - - :- public(month/1). - :- mode(month(?integer), one). - - :- public(day/1). - :- mode(day(?integer), one). - - :- public(today/0). - :- mode(today, one). - - :- public(leap_year/0). - :- mode(leap_year, zero_or_one). - - year(Year) :- - parameter(1, Year). - - month(Month) :- - parameter(2, Month). - - day(Day) :- - parameter(3, Day). - - today :- - {'$lgt_current_date'(Year, Month, Day)}, % defined in the config files - parameter(1, Year), - parameter(2, Month), - parameter(3, Day). - -/* Alternative predicate definitions using this/1 instead of parameter/2 - (see the User Manual for the pros and cons of both alternatives): - - year(Year) :- - this(date(Year, _, _)). - - month(Month) :- - this(date(_, Month, _)). - - day(Day) :- - this(date(_, _, Day)). - - today :- - {'$lgt_current_date'(Year, Month, Day)}, % defined in the config files - this(date(Year, Month, Day)). - -*/ - - leap_year :- - parameter(1, Year), - (0 =:= mod(Year, 4), 0 =\= mod(Year, 100) - ; - 0 =:= mod(Year, 400)), - !. - -:- end_object. - - -:- object(time(_Hours, _Mins, _Secs)). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2005/9/5, - comment is 'Time as parametric objects.', - parnames is ['Hours', 'Mins', 'Secs']]). - - :- public(hours/1). - :- mode(hours(?integer), one). - - :- public(mins/1). - :- mode(mins(?integer), one). - - :- public(secs/1). - :- mode(secs(?integer), one). - - :- public(now/0). - :- mode(now, one). - - hours(Hours) :- - parameter(1, Hours). - - mins(Mins) :- - parameter(2, Mins). - - secs(Secs) :- - parameter(3, Secs). - - now :- - {'$lgt_current_time'(Hours, Mins, Secs)}, % defined in the config files - parameter(1, Hours), - parameter(2, Mins), - parameter(3, Secs). - -/* Alternative predicate definitions using this/1 instead of parameter/2 - (see the User Manual for the pros and cons of both alternatives): - - hours(Hours) :- - this(time(Hours, _, _)). - - mins(Mins) :- - this(time(_, Mins, _)). - - secs(Secs) :- - this(time(_, _, Secs)). - - now :- - {'$lgt_current_time'(Hours, Mins, Secs)}, % defined in the config files - this(time(Hours, Mins, Secs)). - -*/ - -:- end_object. - - - -/* The following parametric object illustrates a solution for implementing - backtracable object state. The idea is to represent object state by using - object parameters, defining "setter" predicates/methods that return the - updated object identifier. -*/ - -:- object(rectangle(_Width, _Height, _X, _Y)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2005/9/5, - comment is 'A simple implementation of a geometric rectangle using parametric objects.', - parnames is ['Width', 'Height', 'X', 'Y']]). - - :- public(init/0). - :- mode(init, one). - :- info(init/0, - [comment is 'Initialize rectangle position.']). - - :- public(area/1). - :- mode(area(-integer), one). - :- info(area/1, - [comment is 'Rectangle area.', - argnames is ['Area']]). - - :- public(move/3). - :- mode(move(+integer, +integer, -compound), one). - :- info(move/3, [ - comment is 'Moves a rectangle to a new position, returning the updated rectangle.', - argnames is ['X', 'Y', 'NewRectangle']]). - - :- public(position/2). - :- mode(position(?integer, ?integer), zero_or_one). - :- info(position/2, [ - comment is 'Rectangle current position.', - argnames is ['X', 'Y']]). - - init :- - parameter(1, 2), % Width - parameter(2, 1), % Height - parameter(3, 0), % X - parameter(4, 0). % Y - - area(Area) :- - parameter(1, Width), - parameter(2, Height), - Area is Width*Height. - - move(X, Y, rectangle(Width, Height, X, Y)) :- - parameter(1, Width), - parameter(2, Height). - - position(X, Y) :- - parameter(3, X), - parameter(4, Y). - -/* Alternative predicate definitions using this/1 instead of parameter/2 - (see the User Manual for the pros and cons of both alternatives): - - init :- - this(rectangle(2, 1, 0, 0)). - - area(Area) :- - this(rectangle(Width, Height, _, _)), - Area is Width*Height. - - move(X, Y, rectangle(Width, Height, X, Y)) :- - this(rectangle(Width, Height, _, _)). - - position(X, Y) :- - this(rectangle(_, _, X, Y)). - -*/ - -:- end_object. - - - -/* The following parametric objects show a solution for dealing with inheritance when - defining "setter" predicates/methods that return updated object identifiers. -*/ - -:- object(person(_Name, _Age)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2007/6/19, - comment is 'A simple representation for people using parametric objects.', - parnames is ['Name', 'Age']]). - - :- public(grow_older/1). - :- mode(grow_older(-object_identifier), one). - :- info(grow_older/1, - [comment is 'Increments the person''s age, returning the updated object identifier.', - argnames is ['NewId']]). - - grow_older(NewId) :- - ::age(OldAge, NewAge, NewId), - NewAge is OldAge + 1. - - :- protected(age/3). - :- mode(age(?integer, ?integer, -object_identifier), zero_or_one). - :- info(age/3, - [comment is 'Rectangle area.', - argnames is ['OldAge', 'NewAge', 'NewId']]). - - age(OldAge, NewAge, person(Name, NewAge)) :- % this rule is compiled into a fact due to - this(person(Name, OldAge)). % compilation of the this/1 call inline - -:- end_object. - - -:- object(employee(Name, Age, _Salary), - extends(person(Name, Age))). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2007/6/19, - comment is 'A simple representation for employees using parametric objects.', - parnames is ['Name', 'Age', 'Salary']]). - - :- public(give_raise/2). - :- mode(give_raise(+integer, -object_identifier), one). - :- info(give_raise/2, - [comment is 'Gives a raise to the employee, returning the updated object identifier.', - argnames is ['Amount', 'NewId']]). - - give_raise(Amount, NewId) :- - ::salary(OldSalary, NewSalary, NewId), - NewSalary is OldSalary + Amount. - - :- protected(salary/3). - :- mode(salary(?integer, ?integer, -object_identifier), zero_or_one). - :- info(salary/3, - [comment is 'Rectangle area.', - argnames is ['OldSalary', 'NewSalary', 'NewId']]). - - salary(OldSalary, NewSalary, employee(Name, Age, NewSalary)) :- - this(employee(Name, Age, OldSalary)). - - age(OldAge, NewAge, employee(Salary, Name, NewAge)) :- - this(employee(Salary, Name, OldAge)). - -:- end_object. diff --git a/Logtalk/examples/poem/NOTES.txt b/Logtalk/examples/poem/NOTES.txt deleted file mode 100644 index 030316a3d..000000000 --- a/Logtalk/examples/poem/NOTES.txt +++ /dev/null @@ -1,23 +0,0 @@ -The example in this folder is an adaptation of an example of POEM, an -object-oriented extension to Prolog developed by Ben Staveley-Taylor. - -To load all entities in this example compile and load the loader file: - -| ?- logtalk_load(poem(loader)). - -Contrary to the other cases, to test this example consult the Prolog -file SCRIPT and then call the predicate run/0 to run the example. On -most Prolog compilers, you can type: - -| ?- ['SCRIPT'], run. - - -Original author contact: - - Ben Staveley-Taylor, - Plessey Electronic Systems Research Ltd., - Roke Manor, - ROMSEY, - Hants. SO5 0ZN. - - Tel. Romsey (0794) 515222 ext 311 diff --git a/Logtalk/examples/poem/SCRIPT.txt b/Logtalk/examples/poem/SCRIPT.txt deleted file mode 100644 index 26b2bcf77..000000000 --- a/Logtalk/examples/poem/SCRIPT.txt +++ /dev/null @@ -1,93 +0,0 @@ - -/************************************************************************/ -/* */ -/* Now some examples of using the above definitions ... */ -/* */ -/************************************************************************/ - - -run :- - banner, - points, - ellipse, - lines, - circle. - - -setup_points(P45, P66, AnotherP45, Pm4m3, P00) :- - P45 = point(4, 5), - P66 = point(6, 6), - AnotherP45 = P45, - Pm4m3 = point(-4, -3), - P00 = point(0, 0). - - -setup_lines(L1, L2, L3, L4) :- - setup_points(P45, P66, _, Pm4m3, P00), - L1 = line(P00, P45), - L2 = line(Pm4m3, P66), - L3 = line(Pm4m3, P45), - L4 = line(P00, P66). - - -banner :- - write('Logtalk adaptation of a Ben Staveley-Taylor POEM example.'), nl, - write('Original banner:'), nl, nl, - nl, - write('POEM demonstration file.'), nl, nl, - write('The example output that follows is produced by Prolog code'), nl, - write('using the object language enhancement POEM. Please look'), nl, - write('through the code file "shapes.pl" provided to understand how'), nl, - write('the class facilities are being used.'), nl. - - -points :- - nl, - write('(1) point manipulation:'), nl, - setup_points(P45, P66, AnotherP45, _, P00), - write('distance from (4,5) to (6,6) is '), - P45::distance(P66, D), - write(D), nl, - P45::identical(AnotherP45), - write('P45 and AnotherP45 are identical points'), nl, - \+ P00::identical(P66), - write('P00 and P66 are different points'), nl. - - -ellipse :- - nl, - write('(2) ellipse manipulation:'), nl, - P56 = point(5, 6), - E = ellipse(P56, 3, 5), - write('Area of ellipse of semi-axes 3 and 5 is '), - E::area(A), - write(A), nl. - - -lines :- - nl, - write('(3) line manipulation:'), nl, - setup_lines( L1, L2, L3, L4 ), - P33 = point(3, 3), - write('distance from '),write(L2),write(' to '),write(P33),write(' is '), - L2::distance(P33, D), - write(D), nl, - L1::intersects(L2), - write(L1), write(' intesects '), write(L2), nl, - \+ L3::intersects(L4), - write(L3), write(' does not intersect '), write(L4), nl. - - -circle :- - nl, - write('(4) circle manipulation:'), nl, - write(' Circles are subsets of ellipses, so the "area" function'), nl, - write(' is available, and a new "circumference" function.'), nl, - P22 = point(2, 2), - C = circle(P22, 3), - write('Area of circle radius 3 is '), - C::area(A), - write(A), nl, - write('Circumference of circle radius 3 is '), - C::circumference(Circ), - write(Circ), nl, nl. diff --git a/Logtalk/examples/poem/loader.lgt b/Logtalk/examples/poem/loader.lgt deleted file mode 100644 index a84adb4ae..000000000 --- a/Logtalk/examples/poem/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(poem)). diff --git a/Logtalk/examples/poem/poem.lgt b/Logtalk/examples/poem/poem.lgt deleted file mode 100644 index e3bb1da27..000000000 --- a/Logtalk/examples/poem/poem.lgt +++ /dev/null @@ -1,176 +0,0 @@ - -/* Points are going to be the fundamental quantity. */ -/* These will be defined in Cartesian co-ordinates. */ - -:- object(point(_X, _Y)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Parametric object for representing geometric points.', - parnames is ['X', 'Y'], - source is 'Example adopted from the POEM system by Ben Staveley-Taylor.']). - - :- public(identical/1). - :- mode(identical(+nonvar), one). - - :- public(distance/2). - :- mode(distance(+nonvar, -number), one). - - identical(point(X1, Y1)) :- - /* succeeds if the argument and owner points are the same. */ - parameter(1, X), - parameter(2, Y), - X1 = X, - Y1 = Y. - - distance(point(X1, Y1), Distance) :- - /* finds the distance between argument and owner points. */ - parameter(1, X), - parameter(2, Y), - Distance is sqrt((X1-X)*(X1-X)+(Y1-Y)*(Y1-Y)). - -:- end_object. - - - -/* A line is defined by its end points. */ -/* This class shows examples of calling its own and other class */ -/* predicates. */ - -:- object(line(_Point1, _Point2)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Parametric object for representing geometric lines.', - parnames is ['Point1', 'Point2'], - source is 'Example adopted from the POEM system by Ben Staveley-Taylor.']). - - :- public(length/1). - :- mode(length(-number), one). - - :- public(intersects/1). - :- mode(intersects(+nonvar), one). - - :- public(signed_distance/2). - :- mode(signed_distance(+nonvar, -number), one). - - :- public(distance/2). - :- mode(distance(+nonvar, -number), one). - - length(Length) :- - /* sets Len to the length of the owner line */ - parameter(1, P1), - parameter(2, P2), - P1::distance(P2, Length). - - intersects(Line2) :- - /* succeeds if Line2 intersects the owner line. */ - /* this isn't necessarily a good method, but shows how to */ - /* call class procedures from within the class definition. */ - parameter(1, P1), - parameter(2, P2), - Line1 = line(P1, P2), - Line2 = line(P3, P4), - Line2::signed_distance(P1, D1), - Line2::signed_distance(P2, D2), - opposite_signs(D1, D2), - Line1::signed_distance(P3, D3), - Line1::signed_distance(P4, D4), - opposite_signs(D3, D4). - - signed_distance(Point, Dist) :- - /* finds the perpendicular distance from point to line. */ - /* the sign of the answer depends on which side of the */ - /* line the point is on. */ - parameter(1, P1), - parameter(2, P2), - P1 = point(X1, Y1), - P2 = point(X2, Y2), - Point = point(X3, Y3), - A is X2-X1, - B is Y1-Y2, - C is X1*Y2-X2*Y1, - Dist is (A*Y3+B*X3+C)/sqrt(A*A+B*B). - - distance(Point, Dist) :- - /* as 'signed_distance', but Dist always >= 0 */ - parameter(1, P1), - parameter(2, P2), - line(P1, P2)::signed_distance(Point, Temp), - Dist is abs(Temp). - - /* 'opposite_signs' succeeds if its arguments are of opposite signs. */ - /* It has a feature in that 'opposite_signs(0,0)' succeeds: this is */ - /* because 0 is treated as having optional sign. */ - - opposite_signs(A, B) :- - o_s_aux(A, B). - opposite_signs(A, B) :- - o_s_aux(B, A). - - o_s_aux(A, B) :- - A >= 0, - B =< 0. - -:- end_object. - - - -/* Ellipses are defined by centre and semi-axes */ - -:- object(ellipse(_Center, _A, _B)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Parametric object for representing geometric ellipses.', - parnames is ['Center', 'Rx', 'Ry'], - source is 'Example adopted from the POEM system by Ben Staveley-Taylor.']). - - :- public(area/1). - :- mode(area(-number), one). - - area(Area) :- - pi(Pi), - parameter(2, A), - parameter(3, B), - Area is Pi*A*B. - - pi(3.14196). - -:- end_object. - - - -/* Circle is a special form of ellipse */ -/* Subclasses ('circle' here) must have the same number of arguments */ -/* as their superclass ('ellipse') for the superclass predicates to */ -/* be applicable. The arguments may be renamed for clarity. */ - -:- object(circle(Center, Radius), - extends(ellipse(Center, Radius, Radius))). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Parametric object for representing geometric circles.', - parnames is ['Center', 'Radius'], - source is 'Example adopted from the POEM system by Ben Staveley-Taylor.']). - - :- public(circumference/1). - :- mode(circumference(-number), one). - - circumference(Circumference) :- - pi(Pi), - parameter(2, Radius), - Circumference is 2*Pi*Radius. - - pi(3.14196). - -:- end_object. diff --git a/Logtalk/examples/points/NOTES.txt b/Logtalk/examples/points/NOTES.txt deleted file mode 100644 index 769cf5434..000000000 --- a/Logtalk/examples/points/NOTES.txt +++ /dev/null @@ -1,60 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -You can find the original description of this example (and a solution using -SICStus Objects) at the URL: - - http://www.sics.se/ps/sicstus/sicstus_32.html#SEC254 - -Suppose you wish to represent points in a two-dimensional space. The -protocol you will have to define consists on the operation move/2, which -allows you to move one point to a new position, and on the operation -print/0, which prints the point position. From the base class point, -which contains the indicated operations, we wish to build three -variants. One class bounded_point in which one point can only move in a -restricted area in space. One class history_point, characterized from -the particularity that each point recalls its previous positions. -Finally, a class bounded_history_point combining the functionality of -classes bounded_point and history_point. - -At first sight, this looks like the kind of ideal problem to illustrate -the advantages of the multiple inheritance mechanisms. However, this type -of solution holds several problems. If the methods move/2 and -print/0 are inherited by bounded_history_point of classes -history_point and bounded_point simultaneously, then one point will be -moved and shown twice. If the inheritance is carried out, for each -method, only from one of the superclasses (assuming that it is possible -to do so, only by breaking the apparent problem symmetry), then the -interfaces of classes history_point and bounded_point will have to -contain separately the necessary operations to verify the limits (in the -case of bounded_point), or to recall the previous positions (in the -case of history_point). This way, the class bounded_history_point could -build its own versions of methods move/2 and print/0, adding to the -inherited definitions of one of the superclasses the calling of the -operation missing in the other superclass. This is the solution adopted -in the SICStus Objects. However, this solution also implies a few -problems. Let's suppose that method move/2 is inherited from class -history_point. Then, any changing operated in the definition of the same -method in class bounded_point is ignored by bounded_history_point. The -problem can be unnoticed, once the symmetry suggested by the use of -multiple inheritance does not reflect on the present implementation. - -The solution just suggested is, in short, a generalization of the -problem previously described. Instead of using multiple inheritance, -let's use composition mechanisms. In order to do so, let's separate the -operations on one point, while an object state, of the classes -representing each one of the point types. This can be achieved through -the definition of two new categories, bounded_coordinate and -point_history, that will define the operations associated both to the -memorization of previous values, and to the verification of feasible -limits for a coordinate value. Each one of the point, bounded_point, -history_point and bounded_history_point classes will import this -category, using his operations so as to define the methods affecting the -solutions that use multiple inheritance. diff --git a/Logtalk/examples/points/SCRIPT.txt b/Logtalk/examples/points/SCRIPT.txt deleted file mode 100644 index be82e5dbf..000000000 --- a/Logtalk/examples/points/SCRIPT.txt +++ /dev/null @@ -1,78 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(points(loader)). -... - - -% let's start with a simple point: - -| ?- point::new(Point,[position-(1, 3)]), Point::(print, move(7, 4), print). - -p1 @ (1, 3) -p1 @ (7, 4) - -Point = p1 ? - -yes - - -% same problem but with bounds on coordinate values: - -| ?- bounded_point::new(Point,[position-(1, 3), bounds(x)-(0, 13), bounds(y)-(-7, 7)]), Point::(print, move(7, 4), print). - -bounds(x) : 0,13 -bounds(y) : -7,7 -bp2 @ (1, 3) -bounds(x) : 0,13 -bounds(y) : -7,7 -bp2 @ (7, 4) - -Point = bp2 ? - -yes - - -% same problem but storing the history of coordinate values: - -| ?- history_point::new(Point,[position-(1, 3)]), Point::(print, move(7, 4), print). - -location history: [] -hp3 @ (1, 3) -location history: [(1,3)] -hp3 @ (7, 4) - -Point = hp3 ? - -yes - - -% same problem but with bounds on coordinate values and storing past values: - -| ?- bounded_history_point::new(Point,[position-(1, 3), bounds(x)-(0, 13), bounds(y)-(-7, 7)]), Point::(print, move(7, 4), print). - -bounds(x) : 0,13 -bounds(y) : -7,7 -location history: [] -bhp4 @ (1, 3) -bounds(x) : 0,13 -bounds(y) : -7,7 -location history: [(1,3)] -bhp4 @ (7, 4) - -Point = bhp4 ? - -yes - - -% clean up instances: - -| ?- (point, bounded_point, history_point, bounded_history_point)::delete_all. -yes diff --git a/Logtalk/examples/points/loader.lgt b/Logtalk/examples/points/loader.lgt deleted file mode 100644 index 28009dc12..000000000 --- a/Logtalk/examples/points/loader.lgt +++ /dev/null @@ -1,8 +0,0 @@ - -:- initialization(( - logtalk_load( - [library(events_loader), library(types_loader), library(metapredicates_loader), library(hierarchies_loader)], - [reload(skip)]), % allow for static binding - logtalk_load(roots(loader), [reload(skip)]), % allow for static binding - logtalk_load(relations(loader), [reload(skip)]), % allow for static binding - logtalk_load(points))). diff --git a/Logtalk/examples/points/points.lgt b/Logtalk/examples/points/points.lgt deleted file mode 100644 index 973a50d73..000000000 --- a/Logtalk/examples/points/points.lgt +++ /dev/null @@ -1,336 +0,0 @@ - -:- object(point, - instantiates(class), - specializes(object)). - - - :- info([ - version is 1.1, - date is 2000/10/31, - author is 'Paulo Moura', - comment is 'Two dimensional point class.', - source is 'Example adopted from the SICStus Objects documentation.']). - - - :- public(move/2). - :- mode(move(+integer, +integer), zero_or_one). - - :- public(position/2). - :- mode(position(?integer, ?integer), one). - - :- private(position_/2). - :- dynamic(position_/2). - :- mode(position_(?integer, ?integer), one). - - - move(X, Y) :- - ::retractall(position_(_, _)), - ::assertz(position_(X, Y)). - - - position(X, Y) :- - ::position_(X, Y). - - - print :- - self(Self), - ::position_(X, Y), - writeq(Self), write(' @ '), write((X, Y)), nl. - - - default_init_option(position-(0, 0)). - - default_init_option(Default) :- - ^^default_init_option(Default). - - - process_init_option(position-(X, Y)) :- - ::assertz(position_(X, Y)). - - process_init_option(Option) :- - ^^process_init_option(Option). - - - instance_base_name(p). - - -:- end_object. - - - - -:- category(bounded_coordinate). - - - :- info([ - version is 1.0, - date is 1998/3/23, - author is 'Paulo Moura', - comment is 'Point coordinate bounds management predicates.', - source is 'Example adopted from the SICStus Objects documentation.']). - - - :- public(set_bounds/3). - :- mode(set_bounds(+atom, +integer, +integer), one). - - :- public(clear_bounds/1). - :- mode(clear_bounds(+atom), one). - - :- public(bounds/3). - :- mode(bounds(?atom, ?integer, ?integer), zero_or_more). - - :- public(check_bounds/2). - :- mode(check_bounds(+atom, +integer), zero_or_one). - - :- public(print_bounds/1). - :- mode(print_bounds(?atom), zero_or_more). - - :- public(valid_value/2). - :- mode(valid_value(+atom, +integer), zero_or_one). - - :- private(bounds_/3). - :- dynamic(bounds_/3). - :- mode(bounds_(?atom, ?integer, ?integer), zero_or_more). - - - set_bounds(Coordinate, Min, Max) :- - ::retractall(bounds_(Coordinate, _, _)), - ::assertz(bounds_(Coordinate, Min, Max)). - - - clear_bounds(Coordinate) :- - ::retractall(bounds_(Coordinate, _, _)). - - - bounds(Coordinate, Min, Max) :- - ::bounds_(Coordinate, Min, Max). - - - check_bounds(Coordinate, Value) :- - ::bounds_(Coordinate, Min, Max), - Value >= Min, - Value =< Max. - - - print_bounds(Coordinate) :- - ::bounds_(Coordinate, Min, Max), - writeq(bounds(Coordinate)), - write(' : '), - write((Min, Max)), - nl. - - - valid_value(Coordinate, Value) :- - ::bounds_(Coordinate, Min, Max) -> - Value >= Min, Value =< Max - ; - true. - - -:- end_category. - - - - -:- object(bounded_point, - imports(bounded_coordinate), - instantiates(class), - specializes(point)). - - - :- info([ - version is 1.1, - date is 2000/10/31, - author is 'Paulo Moura', - comment is 'Two dimensional point moving in a constrained area.', - source is 'Example adopted from the SICStus Objects documentation.']). - - - move(X, Y) :- - ::check_bounds(x, X), - ::check_bounds(y, Y), - ^^move(X, Y). - - - print :- - ::print_bounds(x), - ::print_bounds(y), - ^^print. - - - instance_base_name(bp). - - - default_init_option(bounds(x)-(-10, 10)). - - default_init_option(bounds(y)-(-10, 10)). - - default_init_option(Default) :- - ^^default_init_option(Default). - - - process_init_option(bounds(Coordinate)-(Min, Max)) :- - ::set_bounds(Coordinate, Min, Max). - - process_init_option(Option) :- - ^^process_init_option(Option). - - -:- end_object. - - - - -:- category(point_history). - - - :- info([ - version is 1.0, - date is 1998/3/23, - author is 'Paulo Moura', - comment is 'Point position history management predicates.', - source is 'Example adopted from the SICStus Objects documentation.']). - - - :- public(add_to_history/1). - :- mode(add_to_history(+nonvar), one). - - :- public(init_history/1). - :- mode(init_history(+list), one). - - :- public(history/1). - :- mode(history(-list), zero_or_one). - - :- public(print_history/0). - :- mode(print_history, zero_or_one). - - :- private(history_/1). - :- dynamic(history_/1). - :- mode(history_(-list), zero_or_one). - - - add_to_history(Location) :- - ::retract(history_(History)), - ::assertz(history_([Location| History])). - - - init_history(History) :- - ::retractall(history_(_)), - ::assertz(history_(History)). - - - history(History) :- - ::history_(History). - - - print_history :- - ::history_(History), - write('location history: '), - write(History), - nl. - - -:- end_category. - - - - -:- object(history_point, - imports(point_history), - instantiates(class), - specializes(point)). - - - :- info([ - version is 1.1, - date is 2000/10/31, - author is 'Paulo Moura', - comment is 'Two dimensional point remembering past positions.', - source is 'Example adopted from the SICStus Objects documentation.']). - - - move(X, Y) :- - ::position(OldX, OldY), - ^^move(X, Y), - ::add_to_history((OldX, OldY)). - - - print :- - ::print_history, - ^^print. - - - instance_base_name(hp). - - - default_init_option(history-[]). - - default_init_option(Default) :- - ^^default_init_option(Default). - - - process_init_option(history-History) :- - ::init_history(History). - - process_init_option(Option) :- - ^^process_init_option(Option). - - -:- end_object. - - - - -:- object(bounded_history_point, - imports(bounded_coordinate, point_history), - instantiates(class), - specializes(point)). - - - :- info([ - version is 1.1, - date is 2000/10/31, - author is 'Paulo Moura', - comment is 'Two dimensional point moving in a constrained area and remembering past point positions.', - source is 'Example adopted from the SICStus Objects documentation.']). - - - move(X, Y) :- - ::check_bounds(x, X), - ::check_bounds(y, Y), - ::position(OldX, OldY), - ^^move(X, Y), - ::add_to_history((OldX, OldY)). - - - print :- - ::print_bounds(x), - ::print_bounds(y), - ::print_history, - ^^print. - - - instance_base_name(bhp). - - - default_init_option(history-[]). - - default_init_option(bounds(x)-(-10, 10)). - - default_init_option(bounds(y)-(-10, 10)). - - default_init_option(Default) :- - ^^default_init_option(Default). - - - process_init_option(history-History) :- - ::init_history(History). - - process_init_option(bounds(Coordinate)-(Min, Max)) :- - ::set_bounds(Coordinate, Min, Max). - - process_init_option(Option) :- - ^^process_init_option(Option). - - -:- end_object. diff --git a/Logtalk/examples/polygons/NOTES.txt b/Logtalk/examples/polygons/NOTES.txt deleted file mode 100644 index b4c52a2f3..000000000 --- a/Logtalk/examples/polygons/NOTES.txt +++ /dev/null @@ -1,14 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -In this example we have several types of polygons that can be concentric. -This is represented by a concentric binary relation ensuring that whenever -a polygon is moved towards a new position, all polygons likewise concentric -are moved along with them. diff --git a/Logtalk/examples/polygons/SCRIPT.txt b/Logtalk/examples/polygons/SCRIPT.txt deleted file mode 100644 index 7a70e6696..000000000 --- a/Logtalk/examples/polygons/SCRIPT.txt +++ /dev/null @@ -1,148 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(polygons(loader)). -... - - -% first create four polygons and move each one to a different position - -| ?- triangle::new(t, [position-(4, 5)]). -yes - -| ?- square::new(s, [position-(3, 2)]). -yes - -| ?- pentagon::new(p, [position-(7, 1)]). -yes - -| ?- hexagon::new(h, [position-(2, 4)]). -yes - - -% create two tuples of relation concentric - -| ?- concentric::add_tuple([t, s]). -yes - -| ?- concentric::add_tuple([p, h]). -yes - - -% check results - -| ?- concentric::tuple(Tuple), write(Tuple), nl, fail. -[t,s] -[p,h] -no - -| ?- t::position(Xt, Yt), s::position(Xs, Ys), p::position(Xp, Yp), h::position(Xh, Yh). -Xh = 7, -Yh = 1, -Xp = 7, -Xs = 4, -Xt = 4, -Yp = 1, -Ys = 5, -Yt = 5 -yes - -| ?- after_event_registry::monitors(Ma). -Ma = [concentric] -yes - - -% move triangle to a new position - -| ?- t::move(3, 3). -yes - - -% move the hexagon to a new position - -| ?- h::move(8, 4). -yes - - -% check results - -| ?- concentric::tuple(Tuple), write(Tuple), nl, fail. -[t,s] -[p,h] -no - -| ?- t::position(Xt, Yt), s::position(Xs, Ys), p::position(Xp, Yp), h::position(Xh, Yh). -Xh = 8, -Yh = 4, -Xp = 8, -Xs = 3, -Xt = 3, -Yp = 4, -Ys = 3, -Yt = 3 -yes - -| ?- after_event_registry::monitors(Ma). -Ma = [concentric] -yes - - -% create another tuple of relation concentric - -| ?- concentric::add_tuple([t, p]). -yes - - -% move the pentagon to a new position - -| ?- p::move(2, 7). -yes - - -% check results - -| ?- concentric::tuple(Tuple), write(Tuple), nl, fail. -[t,s] -[p,h] -[t,p] -no - -| ?- t::position(Xt, Yt), s::position(Xs, Ys), p::position(Xp, Yp), h::position(Xh, Yh). -Xh = 2, -Yh = 7, -Xp = 2, -Xs = 2, -Xt = 2, -Yp = 7, -Ys = 7, -Yt = 7 -yes - -| ?- after_event_registry::monitors(Monitors). -Monitors = [concentric] -yes - - -% clean up instances, tuples and monitors - -| ?- concentric::remove_all_tuples. -yes - -| ?- triangle::delete(t). -yes - -| ?- square::delete(s). -yes - -| ?- pentagon::delete(p). -yes - -| ?- hexagon::delete(h). -yes diff --git a/Logtalk/examples/polygons/loader.lgt b/Logtalk/examples/polygons/loader.lgt deleted file mode 100644 index af76442fc..000000000 --- a/Logtalk/examples/polygons/loader.lgt +++ /dev/null @@ -1,8 +0,0 @@ - -:- initialization(( - logtalk_load( - [library(events_loader), library(types_loader), library(metapredicates_loader), library(hierarchies_loader)], - [reload(skip)]), % allow for static binding - logtalk_load(roots(loader), [reload(skip)]), % allow for static binding - logtalk_load(relations(loader), [reload(skip)]), % allow for static binding - logtalk_load(polygons, [events(on)]))). diff --git a/Logtalk/examples/polygons/polygons.lgt b/Logtalk/examples/polygons/polygons.lgt deleted file mode 100644 index b675d0f38..000000000 --- a/Logtalk/examples/polygons/polygons.lgt +++ /dev/null @@ -1,194 +0,0 @@ - -:- object(polygon, - instantiates(abstract_class), - specializes(object)). - - :- info([ - version is 1.2, - date is 2005/8/15, - author is 'Paulo Moura', - comment is 'Polygon predicates.']). - - :- public(move/2). - :- mode(move(+integer, +integer), one). - - :- public(trans_x/2). - :- mode(trans_x(+integer), one). - - :- public(trans_y/2). - :- mode(trans_y(+integer), one). - - :- public(number_of_sides/1). - :- mode(number_of_sides(?integer), zero_or_one). - - :- public(position/2). - :- mode(position(?integer, ?integer), zero_or_one). - - :- private(position_/2). - :- dynamic(position_/2). - :- mode(position_(?integer, ?integer), zero_or_one). - - position(X, Y) :- - ::position_(X, Y). - - move(X, Y) :- - ::retractall(position_(_, _)), - ::assertz(position_(X, Y)). - - trans_x(X) :- - ::retractall(position_(_, Y)), - ::assertz(position_(X, Y)). - - trans_y(Y) :- - ::retractall(position_(X, _)), - ::assertz(position_(X, Y)). - - default_init_option(position-(0, 0)). - default_init_option(Default) :- - ^^default_init_option(Default). - - process_init_option(position-(X, Y)) :- - ::move(X, Y). - process_init_option(Option) :- - ^^process_init_option(Option). - -:- end_object. - - - - -:- object(triangle, - instantiates(class), - specializes(polygon)). - - :- info([ - version is 1.0, - date is 1998/3/23, - author is 'Paulo Moura', - comment is 'Triangle class.']). - - number_of_sides(3). - - instance_base_name(tri). - -:- end_object. - - - - -:- object(square, - instantiates(class), - specializes(polygon)). - - :- info([ - version is 1.0, - date is 1998/3/23, - author is 'Paulo Moura', - comment is 'Square class.']). - - number_of_sides(4). - - instance_base_name(sq). - -:- end_object. - - - - - -:- object(pentagon, - instantiates(class), - specializes(polygon)). - - :- info([ - version is 1.0, - date is 1998/3/23, - author is 'Paulo Moura', - comment is 'Pentagon class.']). - - number_of_sides(5). - - instance_base_name(pen). - -:- end_object. - - - - -:- object(hexagon, - instantiates(class), - specializes(polygon)). - - :- info([ - version is 1.0, - date is 1998/3/23, - author is 'Paulo Moura', - comment is 'Hexagon class.']). - - number_of_sides(6). - - instance_base_name(hex). - -:- end_object. - - - - -:- object(concentric, - instantiates(constrained_relation)). - - :- info([ - version is 1.1, - date is 2004/8/15, - author is 'Paulo Moura', - comment is 'Concentric polygons as a constrained binary relation.']). - - :- uses(list, - [member/2, select/3]). - - descriptor_([x1, x2]). - - domain_(x1, polygon). - domain_(x2, polygon). - - key_([x1, x2]). - - cardinality_(x1, 0, n). - cardinality_(x2, 0, n). - - delete_option_(x1, cascade). - delete_option_(x2, cascade). - - add_tuple([Polygon| Polygons]) :- - Polygon::position(X, Y), - forall(member(Polygon2, Polygons), {Polygon2::move(X, Y)}), - ^^add_tuple([Polygon| Polygons]). - - activ_points_(x1, before, []). - activ_points_(x1, after, [move(_, _), trans_x(_), trans_y(_)]). - - activ_points_(x2, before, []). - activ_points_(x2, after, [move(_, _), trans_x(_), trans_y(_)]). - - propagate(after, move(X, Y), Polygon, _, Tuple) :- - select(Polygon, Tuple, Polygons), - !, - forall( - (member(Polygon2, Polygons),\+ Polygon2::position(X, Y)), - {Polygon2::move(X, Y)}). - - propagate(after, trans_x(X), Polygon, _, Tuple) :- - select(Polygon, Tuple, Polygons), - !, - forall( - (member(Polygon2, Polygons), \+ Polygon2::position(X, _)), - {Polygon2::trans_x(X)}). - - propagate(after, trans_y(Y), Polygon, _, Tuple) :- - select(Polygon, Tuple, Polygons), - !, - forall( - (member(Polygon2, Polygons), \+ Polygon2::position(_, Y)), - {Polygon2::trans_y(Y)}). - -:- end_object. diff --git a/Logtalk/examples/profiling/NOTES.txt b/Logtalk/examples/profiling/NOTES.txt deleted file mode 100644 index 126b98d77..000000000 --- a/Logtalk/examples/profiling/NOTES.txt +++ /dev/null @@ -1,33 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -You will also need to load the following files in the library directory: -types_loader, events_loader, metapredicates_loader, and dates_loader. -Alternatively, you may simply load the library all_loader file to load all -library entities. - -This is a very simple example of the use of events and monitors to make -profilers for an application. It's easy to modify to make it do much more. -For instance, most Prolog compilers give you access to data concerning space -usage (stacks, heap, etc). - -The example defines three objects: - - message_counter - using events, this object allows us to count the messages sent to - spied objects - - stop_watch - using events, this object simply prints the CPU time before and after - a message sent to a spied object - - timer - this object implements a method that sends a message to an object a - specified number of times, returning the average execution time diff --git a/Logtalk/examples/profiling/SCRIPT.txt b/Logtalk/examples/profiling/SCRIPT.txt deleted file mode 100644 index 889a6006f..000000000 --- a/Logtalk/examples/profiling/SCRIPT.txt +++ /dev/null @@ -1,110 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(profiling(loader)). -... - - -%% message_counter example - - -% choose an object to spy: - -| ?- message_counter::set_spy_point(_, list, _, _). -yes - - -% activate the monitor: - -| ?- message_counter::activate_monitor. -yes - - -% send some messages to the spied object; get all the answers for ancestor/1: - -| ?- list::empty([]). -yes - -| ?- list::member(X, [1, 2, 3]). -X = 1 ? ; -X = 2 ? ; -X = 3 ? ; -no - - -% print a report of the data collected by the monitor: - -| ?- message_counter::report. -list - total of calls: 2 - total of exits: 4 - - empty/1 - calls: 1 - exits: 1 - - member/2 - calls: 1 - exits: 3 - -yes - - -% stop and reset the message counter monitor: - -| ?- message_counter::stop. -yes - - - -%% stop_watch example - - -% choose a pair object/message to spy: - -| ?- stop_watch::set_spy_point(_, list, length(_, _), _). -yes - - -% activate the monitor: - -| ?- stop_watch::activate_monitor. -yes - - -% send a message to the spied object: - -| ?- list::length([1, 2, 3], Length). -list <-- length([1,2,3],_277) from user -STARTING at 755.75999999999999 seconds -list <-- length([1,2,3],3) from user -ENDING at 755.69000000000005 seconds - -Length = 3 - -yes - - -% clean up: - -| ?- stop_watch::reset_monitor. -yes - - - -%% timer example - - -% try a message 1000 times and return the average time: - -| ?- timer::timer(list::length([1, 2, 3], _), 1000, Time). -Time = 0.00003 - -yes diff --git a/Logtalk/examples/profiling/loader.lgt b/Logtalk/examples/profiling/loader.lgt deleted file mode 100644 index 51944ee75..000000000 --- a/Logtalk/examples/profiling/loader.lgt +++ /dev/null @@ -1,6 +0,0 @@ - -:- initialization(( - logtalk_load( - [library(dates_loader), library(events_loader), library(metapredicates_loader), library(types_loader)], - [reload(skip)]), % allow for static binding - logtalk_load([timer, message_counter, stop_watch], [events(on)]))). diff --git a/Logtalk/examples/profiling/message_counter.lgt b/Logtalk/examples/profiling/message_counter.lgt deleted file mode 100644 index 6130a6365..000000000 --- a/Logtalk/examples/profiling/message_counter.lgt +++ /dev/null @@ -1,99 +0,0 @@ - -:- object(message_counter, - implements(monitoring), - imports(monitor)). - - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2006/12/14, - comment is 'Message counter monitor.']). - - - :- public(report/0). - :- mode(report, one). - :- info(report/0, - [comment is 'Reports current calls and exits message counts.']). - - :- public(stop/0). - :- mode(stop, one). - :- info(stop/0, - [comment is 'Stops message counting.']). - - - :- private(calls/2). - :- dynamic(calls/2). - :- mode(calls(?object, ?integer), zero_or_more). - - :- private(calls/3). - :- dynamic(calls/3). - :- mode(calls(?object, ?predicate_indicator,?integer), zero_or_more). - - :- private(exits/2). - :- dynamic(exits/2). - :- mode(exits(?object, ?integer), zero_or_more). - - :- private(exits/3). - :- dynamic(exits/3). - :- mode(exits(?object, ?predicate_indicator,?integer), zero_or_more). - - - report :- - forall( - ::calls(Object, Calls), - (writeq(Object), nl, - write(' total of calls: '), write(Calls), nl, - write(' total of exits: '), - (::exits(Object, Exits) -> - write(Exits), nl, nl - ; - write(0), nl, nl), - forall( - ::calls(Object, Functor/Arity, Calls2), - (write(' '), writeq(Functor/Arity), nl, - write(' calls: '), write(Calls2), nl, - write(' exits: '), - (::exits(Object, Functor/Arity, Exits2) -> - write(Exits2), nl, nl - ; - write(0), nl, nl))))). - - - stop :- - ::retractall(calls(_, _)), - ::retractall(exits(_, _)), - ::retractall(calls(_, _, _)), - ::retractall(exits(_, _, _)), - ::reset_monitor. - - - before(Object, Message, _) :- - (::retract(calls(Object, Old)) -> - New is Old + 1 - ; - New = 1), - ::assertz(calls(Object, New)), - functor(Message, Functor, Arity), - (::retract(calls(Object, Functor/Arity, Old2)) -> - New2 is Old2 + 1 - ; - New2 = 1 ), - ::assertz(calls(Object, Functor/Arity, New2)). - - - after(Object, Message, _) :- - (::retract(exits(Object, Old)) -> - New is Old + 1 - ; - New = 1), - ::assertz(exits(Object, New)), - functor(Message, Functor, Arity), - (::retract(exits(Object, Functor/Arity, Old2)) -> - New2 is Old2 + 1 - ; - New2 = 1), - ::assertz(exits(Object, Functor/Arity, New2)). - - -:- end_object. diff --git a/Logtalk/examples/profiling/stop_watch.lgt b/Logtalk/examples/profiling/stop_watch.lgt deleted file mode 100644 index 2cbbb734b..000000000 --- a/Logtalk/examples/profiling/stop_watch.lgt +++ /dev/null @@ -1,28 +0,0 @@ - -:- object(stop_watch, - implements(monitoring), - imports(monitor)). - - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2006/12/14, - comment is 'Message executing time monitor.']). - - - :- uses(time). - - - before(Object, Message, Sender) :- - write(Object), write(' <-- '), writeq(Message), - write(' from '), write(Sender), nl, write('STARTING at '), - time::cpu_time(Seconds), write(Seconds), write(' seconds'), nl. - - after(Object, Message, Sender) :- - write(Object), write(' <-- '), writeq(Message), - write(' from '), write(Sender), nl, write('ENDING at '), - time::cpu_time(Seconds), write(Seconds), write(' seconds'), nl. - - -:- end_object. diff --git a/Logtalk/examples/profiling/timer.lgt b/Logtalk/examples/profiling/timer.lgt deleted file mode 100644 index d7a276a82..000000000 --- a/Logtalk/examples/profiling/timer.lgt +++ /dev/null @@ -1,54 +0,0 @@ - -:- object(timer). - - - :- info([ - version is 1.3, - author is 'Paulo Moura', - date is 2006/9/17, - comment is 'Call executing time profiler.']). - - - :- uses(time, [cpu_time/1]). - :- uses(loop, [forto/3]). - - - :- public(timer/2). - :- meta_predicate(timer(::, *)). - - :- mode(timer(+callable, -number), one). - - :- info(timer/2, - [comment is 'Returns time to execute a call.', - argnames is ['Call', 'Time']]). - - - :- public(timer/3). - :- meta_predicate(timer(::, *, *)). - - :- mode(timer(+callable, +integer, -float), one). - - :- info(timer/3, - [comment is 'Returns the average time needed to to execute a call.', - argnames is ['Call', 'Times', 'Time']]). - - - timer(Call, Time) :- - cpu_time(Start), - (call(Call) -> true; true), - cpu_time(End), - Time is End - Start. - - - timer(Call, Times, Time) :- - cpu_time(Start), - forto(1, Times, Call), - cpu_time(End), - cpu_time(Start2), - forto(1, 0, true), - cpu_time(End2), - Overhead is End2 - Start2, - Time is (End - Start - Overhead) / Times. - - -:- end_object. diff --git a/Logtalk/examples/proxies/NOTES.txt b/Logtalk/examples/proxies/NOTES.txt deleted file mode 100644 index 6e793d8d6..000000000 --- a/Logtalk/examples/proxies/NOTES.txt +++ /dev/null @@ -1,33 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -A parametric object may be used to represent objects whose "state" is static -and set when the object is defined. However, there can be only one parametric -object with a given functor and arity. For example, if we define the following -parametric object: - - :- object(circle(_Radius, _Color)). - ... - :- end_object. - -then the following terms may be interpreted as references to the object above: - - circle(1, blue) - circle(2, yellow) - -In the context of parametric objects, the above terms are know as "parametric -object proxies". Proxies represent different instantiations of a parametric -object parameters. They may be stored on the database as Prolog facts. This -results in a very compact representation, which can be an advantage when -dealing with a large number of objects with immutable state. However, this is -also a fragile solution as changes on the parametric object ancestors may -imply changes to the number and meaning of the parametric object parameters -which, in turn, may imply changes to all the Prolog facts used to represent -the individual objects. diff --git a/Logtalk/examples/proxies/SCRIPT.txt b/Logtalk/examples/proxies/SCRIPT.txt deleted file mode 100644 index 8564a7213..000000000 --- a/Logtalk/examples/proxies/SCRIPT.txt +++ /dev/null @@ -1,24 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(proxies(loader)). -... - - -% print the area and the perimeter for all circle proxies: - -| ?- forall(circle(Id, R, C), (write(Id), write(' '), circle(R, C)::print)). - -#1 area: 4.75291, perimeter: 7.72831, color: blue -#2 area: 43.2412, perimeter: 23.3106, color: yellow -#3 area: 0.477836, perimeter: 2.45044, color: green -#4 area: 103.508, perimeter: 36.0655, color: black -#5 area: 217.468, perimeter: 52.2761, color: cyan -yes diff --git a/Logtalk/examples/proxies/loader.lgt b/Logtalk/examples/proxies/loader.lgt deleted file mode 100644 index fd90d006f..000000000 --- a/Logtalk/examples/proxies/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(proxies)). diff --git a/Logtalk/examples/proxies/proxies.lgt b/Logtalk/examples/proxies/proxies.lgt deleted file mode 100644 index 19a964aa9..000000000 --- a/Logtalk/examples/proxies/proxies.lgt +++ /dev/null @@ -1,42 +0,0 @@ - -% we use a parametric object in order to give an interpretation to an -% object proxy arguments and to encapsulate relevant predicates: - -:- object(circle(_Radius, _Color)). - - :- public([ - radius/1, - color/1, - area/1, - perimeter/1, - print/0]). - - radius(Radius) :- - parameter(1, Radius). - - color(Color) :- - parameter(2, Color). - - area(Area) :- - ::radius(Radius), - Area is 3.1415927*Radius*Radius. - - perimeter(Perimeter) :- - ::radius(Radius), - Perimeter is 2*3.1415927*Radius. - - print :- - area(Area), write('area: '), write(Area), - perimeter(Perimeter), write(', perimeter: '), write(Perimeter), - color(Color), write(', color: '), write(Color), nl. - -:- end_object. - - -% parametric object proxies (with an extra argument to represent identity): - -circle('#1', 1.23, blue). -circle('#2', 3.71, yellow). -circle('#3', 0.39, green). -circle('#4', 5.74, black). -circle('#5', 8.32, cyan). diff --git a/Logtalk/examples/puzzles/NOTES.txt b/Logtalk/examples/puzzles/NOTES.txt deleted file mode 100644 index 8592cd2f2..000000000 --- a/Logtalk/examples/puzzles/NOTES.txt +++ /dev/null @@ -1,14 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT -file. - -This folder contains examples of Logtalk implementations for popular -logical puzzles. The description of each puzzle can be found on the -source files themselves. diff --git a/Logtalk/examples/puzzles/SCRIPT.txt b/Logtalk/examples/puzzles/SCRIPT.txt deleted file mode 100644 index f87015a2f..000000000 --- a/Logtalk/examples/puzzles/SCRIPT.txt +++ /dev/null @@ -1,99 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(puzzles(loader)). -... - - -% Harry Potter's room of potions logical puzzle: - -| ?- potions::potions(P1, P2, P3, P4, P5, P6, P7). - -P1 = poison -P2 = wine -P3 = forward -P4 = poison -P5 = poison -P6 = wine -P7 = backwards - -yes - - -% Horse show logical puzzle: - -| ?- horses::(horses(S), print(S)). -1 place: april riding doc, the chestnut gelding -2 place: sue riding danny, the bay gelding -3 place: doc riding gopher, the gray gelding -4 place: danny riding april, the white mare -5 place: gopher riding sue, the black mare - -S = [h(doc,gelding,chestnut,april,1),h(danny,gelding,bay,sue,2),h(gopher,gelding,gray,doc,3),h(april,mare,white,danny,4),h(sue,mare,black,gopher,5)] ? - -yes - - -% Who Stole the Jam? - -| ?- jam_thief::thief(Thief). - -Thief = hare - -yes - -| ?- jam_thief::thief(Thief, Why). - -Thief = hare -Why = [trusty(dormouse),liar(hare),trusty(hatter)] ? - -yes - - -% Houses logical puzzle: - -| ?- houses::(houses(S), print(S)). -h(norwegian,fox,kool,water,yellow) -h(ukrainian,horse,chesterfield,tea,blue) -h(english,snake,winston,milk,red) -h(japonese,zebra,kent,coffee,green) -h(spanish,dog,lucky,juice,white) - -S = [h(norwegian,fox,kool,water,yellow),h(ukrainian,horse,chesterfield,tea,blue),h(english,snake,winston,milk,red),h(japonese,zebra,kent,coffee,green),h(spanish,dog,lucky,juice,white)] ? ; - -yes - - -% Passing a note logical puzzle - -| ?- note::(students(S), print(S)). -s(mary,english,red,1) -s(paul,math,yellow,2) -s(josephine,science,green,3) -s(derrick,french,blue,4) -s(alexis,reading,black,5) - -S = [s(mary,english,red,1),s(paul,math,yellow,2),s(josephine,science,green,3),s(derrick,french,blue,4),s(alexis,reading,black,5)] ? - -yes - - -% Mort's Letter from Camp Swampy logical puzzle - -| ?- camp_swampy::(beds(S), print(S)). -tim thomas, from maine, sleeps on bed number 1 -sam franklin, from north_carolina, sleeps on bed number 2 -mac miller, from virginia, sleeps on bed number 3 -fred james, from florida, sleeps on bed number 4 -john smith, from arkansas, sleeps on bed number 5 - -S = [b(tim,thomas,maine,1),b(sam,franklin,north_carolina,2),b(mac,miller,virginia,3),b(fred,james,florida,4),b(john,smith,arkansas,5)] ? - -yes diff --git a/Logtalk/examples/puzzles/camp_swampy.lgt b/Logtalk/examples/puzzles/camp_swampy.lgt deleted file mode 100644 index 5320b9aae..000000000 --- a/Logtalk/examples/puzzles/camp_swampy.lgt +++ /dev/null @@ -1,93 +0,0 @@ - -/* Mort's Letter from Camp Swampy logical puzzle by Sally Quinn - -Dear Mom and Dad, - -I am having a great time at camp. There are five guys other in my cabin with me and our beds are all lined up in a row. My bed is up against a wall with a window, and when I sleep on my left side I can look out at the moonlight. The boy whose bed is next to mine is from Maine and Sam is next to him. They have become my best friends. We like to go swimming when we have some free time, which isn't often. They keep us pretty busy around here. - -The kids in my cabin come from all over the USA. Mac and the Franklin boy are from neighboring states. John Smith is the only boy from west of the Mississippi River. Fred is from the most southern state and the Thomas kid is from the most northern state. Tim and Sam took a plane to camp, but Mac got to ride in a train. - -When Mr. Miller came to visit his son, he took Sam, Fred, Tim, and me out to dinner with them. When Sam's mom writes to him from North Carolina, she always sends him cookies. He shares them with Mac and Tim whose beds are next to his. Are you going to send me some cookies? I really miss the M & M cookies that you bake every weekend. - -After lights out, I can whisper to the guys whose beds are close. I don't get to talk to the Smith boy much because his bed is the farthest away from mine. We both take horseback riding, and I get to see him then. The girls cabin is next to ours, and sometimes we can hear the girls talking and laughing. Their cabin counselor must not be as strict as ours. - -I am learning how to swim, ride horses, paddle a canoe, and shoot a bow and arrow. Maybe when I get home, I can show you all that I have learned here at camp. - -Well, it's bed time now, so I have to go. I love you and send cookies. - -Love, Mort - -Can you determine who sleeps where in the cabin and where each boy is from? - -Who sleeps where? Include first name, last name, and home state. - -Published on the web: - http://www.norfacad.pvt.k12.va.us/puzzles/camp.htm -*/ - - -:- object(camp_swampy). - - :- info([ - version is 1.0, - date is 2004/5/1, - author is 'Paulo Moura', - comment is 'Camp Swampy logical puzzle']). - - :- public(beds/1). - :- mode(beds(-list), one). - :- info(beds/1, [ - comment is 'Solution to the puzzle.', - argnames is ['Solution']]). - - :- public(print/1). - :- mode(print(+list), one). - :- info(print/1, [ - comment is 'Pretty print solution to the puzzle.', - argnames is ['Solution']]). - - beds(Solution) :- - template(Solution), - member(b(_, _, maine, 1), Solution), - member(b(sam, _, _, 2), Solution), - member(b(_, smith, _, 5), Solution), - next(b(tim, _, _, _), b(sam, _, _, _), Solution), - next(b(sam, _, _, _), b(mac, _, _, _), Solution), - member(b(sam, _, north_carolina, _), Solution), - member(b(john, smith, arkansas, _), Solution), - member(b(fred, _, florida, _), Solution), - member(b(_, thomas, maine, _), Solution), - member(b(mac, _, State1, _), Solution), - member(b(_, franklin, State2, _), Solution), - neighbors(State1, State2), - member(b(_, james, _, _), Solution), - member(b(Name, miller, _, _), Solution), - Name \= sam, Name \= fred, Name \= tim. - - neighbors(north_carolina, virginia). - neighbors(virginia, north_carolina). - - print([]). - print([Place| Places]) :- - print_boy(Place), - print(Places). - - print_boy(b(First, Last, State, Bed)) :- - write(First), write(' '), write(Last), write(', from '), write(State), - write(', sleeps on bed number '), write(Bed), nl. - - % b(First, Last, State, Bed) - template([b(_, _, _, 1), b(_, _, _, 2), b(_, _, _, 3), b(_, _, _, 4), b(_, _, _, 5)]). - - member(A, [A, _, _, _, _]). - member(B, [_, B, _, _, _]). - member(C, [_, _, C, _, _]). - member(D, [_, _, _, D, _]). - member(E, [_, _, _, _, E]). - - next(A, B, [A, B, _, _, _]). - next(B, C, [_, B, C, _, _]). - next(C, D, [_, _, C, D, _]). - next(D, E, [_, _, _, D, E]). - -:- end_object. diff --git a/Logtalk/examples/puzzles/horses.lgt b/Logtalk/examples/puzzles/horses.lgt deleted file mode 100644 index 147b2de03..000000000 --- a/Logtalk/examples/puzzles/horses.lgt +++ /dev/null @@ -1,89 +0,0 @@ - -/* Horse show logical puzzle by Sally Quinn - -"Youll be late for your own funeral." Her mothers words kept repeating in Alexs head as she approached the fair grounds-late again! It was a curse, no matter how hard she tried, she was always late. This time she had missed the first class of the local horse show. Not really a major crisis, but she had to report the results to the local paper. She couldnt let her boss know that she had arrived late. His last words were, "If you are late one more time, youre fired!". She needed to figure out another way to write her article accurately for the paper. As Alex entered the show grounds, she overheard bits of conversation which she jotted down. - -"No horse and rider had the same name" ... -.."Danny rode his white mare..."... -..." the horse named April finished behind the rider named Sue and ahead of the black mare".. -..." April rode the Chestnut gelding and finished one place ahead of the bay horse".... -.." The Gray horse named Gopher was not first or last place".... -..."The horse named Doc was first, and the rider named Doc was third" - -By looking at a program, Alex discovered that the horses and riders names were Doc, April, Sue, Danny, and Gopher. She knew that April and Sue were the only mares. Does Alex have enough information to fool her boss and write the article accurately? - -Published on the web: - http://www.norfacad.pvt.k12.va.us/puzzles/horse.htm -*/ - - -:- object(horses). - - - :- info([ - version is 1.0, - date is 2004/5/1, - author is 'Paulo Moura', - comment is 'Horse show logical puzzle']). - - :- public(horses/1). - :- mode(horses(-list), one). - :- info(horses/1, [ - comment is 'Solution to the puzzle.', - argnames is ['Solution']]). - - :- public(print/1). - :- mode(print(+list), one). - :- info(print/1, [ - comment is 'Pretty print solution to the puzzle.', - argnames is ['Solution']]). - - - horses(Solution) :- - template(Solution), - member(h(doc, _, _, _, 1), Solution), - member(h(_, _, _, doc, 3), Solution), - member(h(april, mare, _, _, _), Solution), - member(h(sue, mare, _, _, _), Solution), - member(h(gopher, gelding, _, _, _), Solution), - member(h(doc, gelding, _, _, _), Solution), - member(h(danny, gelding, _, _, _), Solution), - member(h(gopher, _, gray, _, P), Solution), P \= 1, P \= 5, - member(h(_, mare, white, danny, _), Solution), - member(h(_, _, _, sue, Pi), Solution), member(h(april, _, _, _, Pj), Solution), Pi < Pj, - member(h(april, _, _, _, Pj), Solution), member(h(_, mare, black, _, Pk), Solution), Pj < Pk, - next(h(_, gelding, chestnut, april, _), h(_, _, bay, _, _), Solution), - member(h(_, _, _, gopher, _), Solution), - \+ member(h(N, _, _, N, _), Solution). - - - print([]). - - print([Place| Places]) :- - print_place(Place), - print(Places). - - - print_place(h(H, S, C, R, P)) :- - write(P), write(' place: '), - write(R), write(' riding '), write(H), - write(', the '), write(C), write(' '), write(S), nl. - - % h(Name, Sex, Color, Rider, Place) - template([h(_, _, _, _, 1), h(_, _, _, _, 2), h(_, _, _, _, 3), h(_, _, _, _, 4), h(_, _, _, _, 5)]). - - - member(A, [A, _, _, _, _]). - member(B, [_, B, _, _, _]). - member(C, [_, _, C, _, _]). - member(D, [_, _, _, D, _]). - member(E, [_, _, _, _, E]). - - - next(A, B, [A, B, _, _, _]). - next(B, C, [_, B, C, _, _]). - next(C, D, [_, _, C, D, _]). - next(D, E, [_, _, _, D, E]). - - -:- end_object. diff --git a/Logtalk/examples/puzzles/houses.lgt b/Logtalk/examples/puzzles/houses.lgt deleted file mode 100644 index 4bb043e7a..000000000 --- a/Logtalk/examples/puzzles/houses.lgt +++ /dev/null @@ -1,81 +0,0 @@ - -/* Houses logical puzzle: who owns the zebra and who drinks water? - - 1) Five colored houses in a row, each with an owner, a pet, cigarettes, and a drink. - 2) The English lives in the red house. - 3) The Spanish has a dog. - 4) They drink coffee in the green house. - 5) The Ukrainian drinks tea. - 6) The green house is next to the white house. - 7) The Winston smoker has a serpent. - 8) In the yellow house they smoke Kool. - 9) In the middle house they drink milk. - 10) The Norwegian lives in the first house from the left. - 11) The Chesterfield smoker lives near the man with the fox. - 12) In the house near the house with the horse they smoke Kool. - 13) The Lucky Strike smoker drinks juice. - 14) The Japanese smokes Kent. - 15) The Norwegian lives near the blue house. - -Who owns the zebra and who drinks water? -*/ - -:- object(houses). - - :- info([ - version is 1.0, - date is 2004/5/1, - author is 'Paulo Moura', - comment is 'Houses logical puzzle']). - - :- public(houses/1). - :- mode(houses(-list), one). - :- info(houses/1, [ - comment is 'Solution to the puzzle.', - argnames is ['Solution']]). - - :- public(print/1). - :- mode(print(+list), one). - :- info(print/1, [ - comment is 'Pretty print solution to the puzzle.', - argnames is ['Solution']]). - - houses(Solution) :- - template(Solution), % 1 - member(h(english, _, _, _, red), Solution), % 2 - member(h(spanish, dog, _, _, _), Solution), % 3 - member(h(_, _, _, coffee, green), Solution), % 4 - member(h(ukrainian, _, _, tea, _), Solution), % 5 - next(h(_, _, _, _, green), h(_, _, _, _, white), Solution), % 6 - member(h(_, snake, winston, _, _), Solution), % 7 - member(h(_, _, kool, _, yellow), Solution), % 8 - Solution = [_, _, h(_, _, _, milk, _), _, _], % 9 - Solution = [h(norwegian, _, _, _, _)| _], % 10 - next(h(_, fox, _, _, _), h(_, _, chesterfield, _, _), Solution), % 11 - next(h(_, _, kool, _, _), h(_, horse, _, _, _), Solution), % 12 - member(h(_, _, lucky, juice, _), Solution), % 13 - member(h(japonese, _, kent, _, _), Solution), % 14 - next(h(norwegian, _, _, _, _), h(_, _, _, _, blue), Solution), % 15 - member(h(_, _, _, water, _), Solution), % one of them drinks water - member(h(_, zebra, _, _, _), Solution). % one of them owns a zebra - - print([]). - print([House| Houses]) :- - write(House), nl, - print(Houses). - - % h(Nationality, Pet, Cigarette, Drink, Color) - template([h(_, _, _, _, _), h(_, _, _, _, _), h(_, _, _, _, _), h(_, _, _, _, _), h(_, _, _, _, _)]). - - member(A, [A, _, _, _, _]). - member(B, [_, B, _, _, _]). - member(C, [_, _, C, _, _]). - member(D, [_, _, _, D, _]). - member(E, [_, _, _, _, E]). - - next(A, B, [A, B, _, _, _]). - next(B, C, [_, B, C, _, _]). - next(C, D, [_, _, C, D, _]). - next(D, E, [_, _, _, D, E]). - -:- end_object. diff --git a/Logtalk/examples/puzzles/jam_thief.lgt b/Logtalk/examples/puzzles/jam_thief.lgt deleted file mode 100644 index 0160dba73..000000000 --- a/Logtalk/examples/puzzles/jam_thief.lgt +++ /dev/null @@ -1,69 +0,0 @@ -/* Logical puzzle: Who Stole the Jam? - -Someone has stolen the jam! The March Hare said he didn't do it (naturally!) The Mad Hatter proclaimed one of them (the Hare, the Hatter or the Dormouse) stole the jam, but of course it wasn't the Hatter himself. When asked whether the Mad Hatter and March Hare spoke the truth, the Dormouse said that one of the three (including herself) must have stolen the jam. - -By employing the very expensive services of Dr. Himmelheber, the famous psychiatrist, we eventually learned that not both the Dormous and the March Hare spoke the truth. - -Assuming, as we do, that fairy-tale characters either always lie or always tell the truth, it remains to discover who really stole the jam. - -(posted on comp.lang.prolog Usenet News group) -*/ - - -:- object(jam_thief). - - - :- info([ - version is 1.0, - date is 2004/4/29, - author is 'Paulo Moura', - comment is 'Who Stole the Jam logical puzzle']). - - :- public(thief/1). - :- mode(thief(?atom), zero_or_one). - :- info(thief/1, [ - comment is 'Thief that stole the jam.', - argnames is ['Thief']]). - - :- public(thief/2). - :- mode(thief(?atom, -list), zero_or_one). - :- info(thief/2, [ - comment is 'Thief that stole the jam.', - argnames is ['Thief', 'Justification']]). - - - thief(Thief) :- - (claim(dormouse, Thief); \+ claim(dormouse, Thief)), - (claim(hare, Thief); \+ claim(hare, Thief)), - (claim(hatter, Thief); \+ claim(hatter, Thief)), - (\+ claim(hare, Thief); \+ claim(dormouse, Thief)). - - - thief(Thief, [Reason1, Reason2, Reason3]) :- - ( claim(dormouse, Thief) -> Reason1 = trusty(dormouse) - ; \+ claim(dormouse, Thief) -> Reason1 = liar(dormouse)), - ( claim(hare, Thief) -> Reason2 = trusty(hare) - ; \+ claim(hare, Thief) -> Reason2 = liar(hare)), - ( claim(hatter, Thief) -> Reason3 = trusty(hatter) - ; \+ claim(hatter, Thief) -> Reason3 = liar(hatter)), - ( \+ claim(hare, Thief) - ; \+ claim(dormouse, Thief)). - - - claim(hare, Thief) :- - Thief \= hare. - - claim(hatter, Thief) :- - member(Thief, [hare, hatter, dormouse]), - Thief \= hatter. - - claim(dormouse, Thief) :- - member(Thief, [hare, hatter, dormouse]). - - - member(A, [A, _, _]). - member(B, [_, B, _]). - member(C, [_, _, C]). - - -:- end_object. diff --git a/Logtalk/examples/puzzles/loader.lgt b/Logtalk/examples/puzzles/loader.lgt deleted file mode 100644 index 6619d3656..000000000 --- a/Logtalk/examples/puzzles/loader.lgt +++ /dev/null @@ -1,4 +0,0 @@ - -:- initialization(( - logtalk_load(library(types_loader), [reload(skip)]), % allow for static binding - logtalk_load([potions, jam_thief, horses, houses, note, camp_swampy]))). diff --git a/Logtalk/examples/puzzles/note.lgt b/Logtalk/examples/puzzles/note.lgt deleted file mode 100644 index 4d9680b43..000000000 --- a/Logtalk/examples/puzzles/note.lgt +++ /dev/null @@ -1,86 +0,0 @@ - -/* Passing A Note logical puzzle by Sally Quinn - -Jack has a major crush on Jill. During study hall, he finally gathers all of his courage and writes her a note asking her out on Saturday night. The note passes to five students (who all read it) before it gets to Jill. Just as Jill gets the note, Mrs. Wilson the teacher confiscates it. After reading the note, she wants to know all who were involved in the note passing incident. She questions her students, and receives the following responses. - -The girl studying English passed it to Paul who passed it to the girl in green. -Josephine passed it to the boy in blue who gave it to Alexis who was reading. -The girl in black gave it to Jill. -Jack first gave it to Mary who was studying English. -The girl in black who was reading got the note from Derrick. - -Mrs. Wilson remembers the following facts from study hall. - -Paul was wearing yellow. -Derrick was studying French. -The girl in green was studying science. - -From the information given by the students, can you determine what color each culprit was wearing, the subject they were studying and the order that they received the note? Use the chart below to help you. - -Published on the web: - http://www.norfacad.pvt.k12.va.us/puzzles/note.htm -*/ - - -:- object(note). - - :- info([ - version is 1.0, - date is 2004/5/1, - author is 'Paulo Moura', - comment is 'Passing a note logical puzzle']). - - :- public(students/1). - :- mode(students(-list), one). - :- info(students/1, [ - comment is 'Solution to the puzzle.', - argnames is ['Solution']]). - - :- public(print/1). - :- mode(print(+list), one). - :- info(print/1, [ - comment is 'Pretty print solution to the puzzle.', - argnames is ['Solution']]). - - students(Solution) :- - template(Solution), - next(s(Girl1, english, _, _), s(paul, _, _, _), Solution), girl(Girl1), - next(s(paul, _, _, _), s(Girl2, _, green, _), Solution), girl(Girl2), - next(s(josephine, _, _, _), s(Boy1, _, blue, _), Solution), boy(Boy1), - next(s(Boy1, _, blue, _), s(alexis, reading, _, _), Solution), - member(s(Girl3, _, black, 5), Solution), girl(Girl3), - member(s(mary, english, _, 1), Solution), - next(s(derrick, _, _, _), s(Girl4, reading, black, _), Solution), girl(Girl4), - member(s(paul, _, yellow, _), Solution), - member(s(derrick, french, _, _), Solution), - member(s(Girl5, science, green, _), Solution), girl(Girl5), - member(s(_, math, _, _), Solution), - member(s(_, _, red, _), Solution). - - girl(alexis). - girl(josephine). - girl(mary). - - boy(derrick). - boy(paul). - - print([]). - print([Student| Students]) :- - write(Student), nl, - print(Students). - - % h(Name, Subject, Color, Place) - template([s(_, _, _, 1), s(_, _, _, 2), s(_, _, _, 3), s(_, _, _, 4), s(_, _, _, 5)]). - - member(A, [A, _, _, _, _]). - member(B, [_, B, _, _, _]). - member(C, [_, _, C, _, _]). - member(D, [_, _, _, D, _]). - member(E, [_, _, _, _, E]). - - next(A, B, [A, B, _, _, _]). - next(B, C, [_, B, C, _, _]). - next(C, D, [_, _, C, D, _]). - next(D, E, [_, _, _, D, E]). - -:- end_object. diff --git a/Logtalk/examples/puzzles/potions.lgt b/Logtalk/examples/puzzles/potions.lgt deleted file mode 100644 index 475094cf8..000000000 --- a/Logtalk/examples/puzzles/potions.lgt +++ /dev/null @@ -1,55 +0,0 @@ -/* -The description of this puzzle is easily found on the web. For example: - -http://www.csci.csusb.edu/dick/cs320/prolog/Potions.htm -*/ - - -:- object(potions). - - - :- info([ - version is 1.2, - date is 2006/3/26, - author is 'Paulo Moura', - comment is 'Harry Potter potions logical puzzle.']). - - :- uses(list, [select/3]). - - :- public(potions/7). - :- mode(potions(?atom, ?atom, ?atom, ?atom, ?atom, ?atom, ?atom), zero_or_one). - :- info(potions/7, [ - comment is 'Contents of the seven potions.', - argnames is ['P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7']]). - - - contents([wine, wine, poison, poison, poison, forward, backwards]). - - potions(P1, P2, P3, P4, P5, P6, P7) :- - contents(H1), - select(P1, H1, H2), - select(P7, H2, H3), - P1 \== P7, P1 \== forward, P7 \== forward, % second clue - select(P2, H3, H4), - P2 \== poison, - select(P3, H4, H5), - P3 \== poison, % third clue - select(P6, H5, H6), % fourth clue - P2 == P6, - select(P4, H6, H7), - select(P5, H7, []), - two_pairs_poison_wine([P1, P2, P3, P4, P5, P6, P7]). % first clue - - - two_pairs_poison_wine(S) :- - poison_wine_pair(S, R), - poison_wine_pair(R, _). - - poison_wine_pair([poison, wine| R], R) :- - !. - - poison_wine_pair([_| L], R) :- - poison_wine_pair(L, R). - - -:- end_object. diff --git a/Logtalk/examples/reflection/NOTES.txt b/Logtalk/examples/reflection/NOTES.txt deleted file mode 100644 index 609da8c97..000000000 --- a/Logtalk/examples/reflection/NOTES.txt +++ /dev/null @@ -1,24 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -Run this example with no other examples loaded at the same time. - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains an example that shows how to implement a reflective -class-based system. There are three main classes: - - object - root of the inheritance graph - class - default metaclass for all instantiable classes - abstract_class - default metaclass for all abstract classes - -Each class inherit all the methods form the other two classes and from -itself (without any inheritance loops of course ;-). - -You can find more sophisticated versions of these classes in the roots -example. diff --git a/Logtalk/examples/reflection/SCRIPT.txt b/Logtalk/examples/reflection/SCRIPT.txt deleted file mode 100644 index 6b912d130..000000000 --- a/Logtalk/examples/reflection/SCRIPT.txt +++ /dev/null @@ -1,135 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(reflection(loader)). -... - - -% print the (public and protected) interface of each class: - -| ?- (object, abstract_class, class)::print. - -Object: object - - interface: - new/1 - delete/1 - instances/1 - metaclass/0 - abstract_class/0 - strict_instance/0 - print/0 - -Object: abstract_class - - interface: - new/1 - delete/1 - instances/1 - metaclass/0 - abstract_class/0 - strict_instance/0 - print/0 - -Object: class - - interface: - new/1 - delete/1 - instances/1 - metaclass/0 - abstract_class/0 - strict_instance/0 - print/0 - -yes - - -% class is the metaclass of all classes: - -| ?- class::instances(Instances), class::metaclass. - -Instances = [class,abstract_class,object] -yes - - -% create an abstract_class, check it and print its interface: - -| ?- abstract_class::new(ac), ac::abstract_class, ac::print. - -Object: ac - - interface: - metaclass/0 - abstract_class/0 - strict_instance/0 - print/0 - -yes - - -% try to create an instance of the abstract class: - -| ?- ac::new(i). - -uncaught exception: error(existence_error(predicate_declaration,new(i)),ac::new(i),user) - - -% create a new instantiable class and print its interface: - -| ?- class::new(c), c::print. - -Object: c - - interface: - new/1 - delete/1 - instances/1 - metaclass/0 - abstract_class/0 - strict_instance/0 - print/0 - -yes - - -% create an instance of the new class: - -| ?- c::new(i), c::instances(Instances). - -Instances = [i] -yes - - -% because c does not declare any predicates, its instances have no interface: - -| ?- i::current_predicate(Predicate). - -no - - -% create an instance of object, root of the inheritance graph, and print its interface: - -| ?- object::new(j), j::print. - -Object: j - - interface: - strict_instance/0 - print/0 - -yes - - -% delete the dynamic objects that we created: - -| ?- c::delete(i), class::delete(c), abstract_class::delete(ac), object::delete(j). - -yes diff --git a/Logtalk/examples/reflection/loader.lgt b/Logtalk/examples/reflection/loader.lgt deleted file mode 100644 index de832b735..000000000 --- a/Logtalk/examples/reflection/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(reflection, [unknown(silent)])). diff --git a/Logtalk/examples/reflection/reflection.lgt b/Logtalk/examples/reflection/reflection.lgt deleted file mode 100644 index 758a72b9b..000000000 --- a/Logtalk/examples/reflection/reflection.lgt +++ /dev/null @@ -1,106 +0,0 @@ - -/* -In order to better grasp this example, draw a diagram of the hierarchy made of -the three objects below with their instantiation and specialization relations. -*/ - - -:- object(object, % root of the inheritance graph - instantiates(class)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Inheritance root for all objects.']). - - :- public(strict_instance/0). - :- mode(strict_instance, zero_or_one). - - :- public(print/0). - :- mode(print, one). - - strict_instance. % descendant instances of this class - % are, by default, strict instances - print :- - self(Self), - write('Object: '), writeq(Self), nl, nl, - write(' interface:'), nl, - forall( - ::current_predicate(Predicate), - (write(' '), writeq(Predicate), nl)), - nl. - -:- end_object. - - -:- object(class, % default metaclass for all instantiable classes - instantiates(class), - specializes(abstract_class)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Instantiation root and default metaclass for all classes.']). - - :- public(new/1). - :- mode(new(+object), zero_or_one). - - :- public(delete/1). - :- mode(delete(+object), zero_or_one). - - :- public(instances/1). - :- mode(instances(-list), one). - - new(Object) :- - self(Self), - create_object(Object, [instantiates(Self)], [], []). - - delete(Object) :- - self(Self), - instantiates_class(Object, Self), - \+ instantiates_class(_, Object), - \+ specializes_class(_, Object), - abolish_object(Object). - - instances(Instances) :- - self(Self), - findall(Instance, instantiates_class(Instance, Self), Instances). - - abstract_class :- % instances of this class are instantiable classes, - fail. % not abstract classes - -:- end_object. - - -:- object(abstract_class, % default metaclass for all abstract classes - instantiates(class), - specializes(object)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Default metaclass for all abstract classes.']). - - :- public(metaclass/0). - :- mode(metaclass, zero_or_one). - - :- public(abstract_class/0). - :- mode(abstract_class, zero_or_one). - - abstract_class :- % by default, descendant instances of this class are abstract - self(Self), % classes except this class itself which is an instantiable class - Self \= abstract_class. - - metaclass :- % descendant instances of this class are metaclasses if - self(Self), % their instances are themselves classes, i.e. if their - once(( % instances accept the abstract_class/0 message - instantiates_class(Class, Self), - Class::current_predicate(abstract_class/0))). - - strict_instance :- % instances of this class are not strict instances; - fail. % they are classes - -:- end_object. diff --git a/Logtalk/examples/relations/NOTES.txt b/Logtalk/examples/relations/NOTES.txt deleted file mode 100644 index 000bc9701..000000000 --- a/Logtalk/examples/relations/NOTES.txt +++ /dev/null @@ -1,15 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains rewritten versions of some of the objects provided -with previous, 1.x versions, of the Logtalk system. They are intended to -help the conversion of applications from Logtalk 1.x to 2.x and to -support most of the other examples provided with the current Logtalk -package. diff --git a/Logtalk/examples/relations/SCRIPT.txt b/Logtalk/examples/relations/SCRIPT.txt deleted file mode 100644 index 4e85e9f85..000000000 --- a/Logtalk/examples/relations/SCRIPT.txt +++ /dev/null @@ -1,15 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(relations(loader)). -... - - -% the objects in this example are used by several of the other examples. diff --git a/Logtalk/examples/relations/loader.lgt b/Logtalk/examples/relations/loader.lgt deleted file mode 100644 index 22a143907..000000000 --- a/Logtalk/examples/relations/loader.lgt +++ /dev/null @@ -1,7 +0,0 @@ - -:- initialization(( - logtalk_load( - [library(events_loader), library(types_loader), library(hierarchies_loader)], - [reload(skip)]), % allow for static binding - logtalk_load(roots(loader), [reload(skip)]), % allow for static binding - logtalk_load(relations))). diff --git a/Logtalk/examples/relations/relations.lgt b/Logtalk/examples/relations/relations.lgt deleted file mode 100644 index e7784977e..000000000 --- a/Logtalk/examples/relations/relations.lgt +++ /dev/null @@ -1,796 +0,0 @@ - -:- protocol(relationp). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Relations between objects protocol.']). - - :- private(tuple_/1). - :- dynamic(tuple_/1). - :- mode(tuple_(?list), zero_or_more). - :- info(tuple_/1, [ - comment is 'Stores the relation tuples.', - argnames is ['Tuple']]). - - :- public(tuple/1). - :- mode(tuple(?list), zero_or_more). - :- info(tuple/1, [ - comment is 'Returns a relation tuple.', - argnames is ['Tuple']]). - - :- public(tuples/1). - :- mode(tuples(-list), one). - :- info(tuples/1, [ - comment is 'Returns a list of all relation tuples.', - argnames is ['Tuples']]). - - :- public(add_tuple/1). - :- mode(add_tuple(+list), zero_or_one). - :- info(add_tuple/1, [ - comment is 'Adds a new relation tuple.', - argnames is ['Tuple']]). - - :- public(remove_tuple/1). - :- mode(remove_tuple(?list), zero_or_more). - :- info(remove_tuple/1, [ - comment is 'Removes a matching relation tuple.', - argnames is ['Tuple']]). - - :- public(remove_all_tuples/0). - :- mode(remove_all_tuples, one). - :- info(remove_all_tuples/0, [ - comment is 'Removes all relation tuples.']). - - :- public(number_of_tuples/1). - :- mode(number_of_tuples(-integer), one). - :- info(number_of_tuples/1, [ - comment is 'Returns the current number of relation tuples.', - argnames is ['Number']]). - - :- public(plays_role_in_tuple/3). - :- mode(plays_role_in_tuple(?object, ?atom, ?list), zero_or_more). - :- info(plays_role_in_tuple/3, [ - comment is 'List of tuples where an object plays a role.', - argnames is ['Object', 'Role', 'Tuples']]). - - :- public(plays_roles/2). - :- mode(plays_roles(?object, -list), zero_or_more). - :- info(plays_roles/2, [ - comment is 'Returns a list of all roles played by an object in the relation tuples.', - argnames is ['Object', 'Roles']]). - - :- public(plays_role_n_times/3). - :- mode(plays_role_n_times(?object, ?atom, -integer), zero_or_more). - :- info(plays_role_n_times/3, [ - comment is 'Number of times that an object plays a role in the relation tuples.', - argnames is ['Object', 'Role', 'Times']]). - - :- private(domain_/2). - :- dynamic(domain_/2). - :- mode(domain_(?atom, ?object), zero_or_more). - :- info(domain_/2, [ - comment is 'Table of role domains.', - argnames is ['Role', 'Domain']]). - - :- public(domains/1). - :- mode(domains(-list), zero_or_one). - :- info(domains/1, [ - comment is 'List of domains for all roles.', - argnames is ['Domains']]). - - :- public(domain/2). - :- mode(domain(?atom, ?object), zero_or_more). - :- info(domain/2, [ - comment is 'Role domain.', - argnames is ['Role', 'Domain']]). - - :- public(set_domains/1). - :- mode(set_domains(+list), zero_or_one). - :- info(set_domains/1, [ - comment is 'Set the domains for all roles.', - argnames is ['Domains']]). - - :- private(descriptor_/1). - :- dynamic(descriptor_/1). - :- mode(descriptor_(?list), zero_or_one). - :- info(descriptor_/1, [ - comment is 'Stores the relation tuple descriptor.', - argnames is ['Descriptor']]). - - :- public(descriptor/1). - :- mode(descriptor(?list), zero_or_one). - :- info(descriptor/1, [ - comment is 'Returns the relation tuple descriptor.', - argnames is ['Descriptor']]). - - :- public(degree/1). - :- mode(degree(?integer), zero_or_one). - :- info(degree/1, [ - comment is 'Descriptor length.', - argnames is ['Degree']]). - - :- public(set_descriptor/1). - :- mode(set_descriptor(+list), zero_or_one). - :- info(set_descriptor/1, [ - comment is 'Sets the relation tuple descriptor.', - argnames is ['Descriptor']]). - - :- private(key_/1). - :- dynamic(key_/1). - :- mode(key_(?list), zero_or_more). - :- info(key_/1, [ - comment is 'Stores the relation keys.', - argnames is ['Key']]). - - :- public(key/1). - :- mode(key(?list), zero_or_more). - :- info(key/1, [ - comment is 'Returns a relation key.', - argnames is ['Key']]). - - :- public(keys/1). - :- mode(keys(-list), one). - :- info(keys/1, [ - comment is 'Returns a list of all relation keys.', - argnames is ['Keys']]). - - :- public(set_keys/1). - :- mode(set_keys(+list), zero_or_one). - :- info(set_keys/1, [ - comment is 'Sets the relation keys.', - argnames is ['Keys']]). - - :- private(delete_option_/2). - :- dynamic(delete_option_/2). - :- mode(delete_option_(?atom, ?atom), zero_or_more). - :- info(delete_option_/2, [ - comment is 'Stores role delete options.', - argnames is ['Role', 'Option']]). - - :- public(delete_options/1). - :- mode(delete_options(-list), zero_or_one). - :- info(delete_options/1, [ - comment is 'Returns a list of all role - delete option pairs.', - argnames is ['Options']]). - - :- public(delete_option/2). - :- mode(delete_option(?atom, ?atom), zero_or_more). - :- info(delete_option/2, [ - comment is 'Returns role delete options.', - argnames is ['Role', 'Option']]). - - :- public(set_delete_options/1). - :- mode(set_delete_options(+list), zero_or_one). - :- info(set_delete_options/1, [ - comment is 'Sets the roles delete options.', - argnames is ['Options']]). - - :- private(cardinality_/3). - :- dynamic(cardinality_/3). - :- mode(cardinality_(?atom, ?nonvar, ?nonvar), zero_or_more). - :- info(cardinality_/3, [ - comment is 'Table of roles minimum and maximum cardinalities.', - argnames is ['Role', 'Min', 'Max']]). - - :- public(cardinalities/1). - :- mode(cardinalities(-list), zero_or_one). - :- info(cardinalities/1, [ - comment is 'List of minimum and maximum cardinalities of all roles.', - argnames is ['Cardinalities']]). - - :- public(cardinality/3). - :- mode(cardinality(?atom, ?nonvar, ?nonvar), zero_or_more). - :- info(cardinality/3, [ - comment is 'Role minimum and maximum cardinalities.', - argnames is ['Role', 'Min', 'Max']]). - - :- public(set_cardinalities/1). - :- mode(set_cardinalities(+list), zero_or_one). - :- info(cardinalities/1, [ - comment is 'Sets the minimum and maximum cardinalities of all roles.', - argnames is ['Cardinalities']]). - - :- protected(set_monitors/1). - :- mode(set_monitors(+list), one). - - :- protected(del_all_monitors/0). - :- mode(del_all_monitors, one). - - :- protected(del_monitors/1). - :- mode(del_monitors(+list), one). - - :- protected(restore_monitors/0). - :- mode(restore_monitors, zero_or_one). - -:- end_protocol. - - - -:- object(relation, - implements(relationp, monitoring), - instantiates(class), - specializes(object)). - - :- info([ - version is 1.3, - date is 2006/12/16, - author is 'Esteban Zimanyi, Paulo Moura', - comment is 'Enables the representation of relations between independent objects.']). - - :- uses(before_event_registry). - :- uses(after_event_registry). - :- uses(list, - [length/2, member/2, memberchk/2, nth1/3, same_length/2]). - - tuple(Tuple) :- - ::tuple_(Tuple). - - tuples(Tuples) :- - findall(Tuple, ::tuple_(Tuple), Tuples). - - add_tuple(Tuple) :- - \+ ::descriptor(_), - self(Self), - sender(Sender), - throw(error(descriptor_not_defined, Self::add_tuple(Tuple), Sender)). - - add_tuple(Tuple) :- - ::descriptor(Descriptor), - \+ same_length(Tuple, Descriptor), - self(Self), - sender(Sender), - throw(error(invalid_length, Self::add_tuple(Tuple), Sender)). - - add_tuple(Tuple) :- - ::descriptor(Descriptor), - ::key(Key), - make_tuple_template(Tuple, Descriptor, Key, Template), - ::tuple(Template), - self(Self), - sender(Sender), - throw(error(breaks_key(Key), Self::add_tuple(Tuple), Sender)). - - add_tuple(Tuple) :- - ::descriptor(Descriptor), - nth1(Position, Tuple, Object), - nth1(Position, Descriptor, Role), - ::cardinality(Role, _, Maximum), - ::plays_role_n_times(Object, Role, Number), - Maximum = Number, - self(Self), - sender(Sender), - throw(error(breaks_max_cardinality(Object, Role, Maximum), Self::add_tuple(Tuple), Sender)). - - add_tuple(Tuple) :- - ::descriptor(Descriptor), - nth1(Position, Tuple, Object), - nth1(Position, Descriptor, Role), - ::domain(Role, Domain), - (Domain::strict_instance -> - \+ Domain::valid(Object) - ; - \+ Object::ancestor(Domain)), - self(Self), - sender(Sender), - throw(error(breaks_domain(Object, Role, Domain), Self::add_tuple(Tuple), Sender)). - - add_tuple(Tuple) :- - ::assertz(tuple_(Tuple)), - ::set_monitors(Tuple). - - - make_tuple_template([], [], _, []). - make_tuple_template([Object| Objects], [Role| Roles], Key, [Var| Rest]) :- - (member(Role, Key) -> - Var = Object - ; - true), - make_tuple_template(Objects, Roles, Key, Rest). - - remove_tuple(Tuple) :- - \+ ::descriptor(_), - self(Self), - sender(Sender), - throw(error(descriptor_not_defined, Self::remove_tuple(Tuple), Sender)). - - remove_tuple(Tuple) :- - ::descriptor(Descriptor), - nth1(Position, Tuple, Object), - nth1(Position, Descriptor, Role), - ::cardinality(Role, Minimum, _), - ::plays_role_n_times(Object, Role, Number), - Minimum = Number, - self(Self), - sender(Sender), - throw(error(breaks_min_cardinality(Object, Role, Minimum), Self::remove_tuple(Tuple), Sender)). - - remove_tuple(Tuple) :- - ::retract(tuple_(Tuple)), - ::del_monitors(Tuple). - - remove_all_tuples :- - ::retractall(tuple_(_)), - ::del_all_monitors. - - number_of_tuples(Number) :- - findall(1, ::tuple_(_), List), - length(List, Number). - - plays_roles(Object, Roles) :- - ::descriptor(Descriptor), - setof(Role, - Tuple^Position^ (::tuple(Tuple), - member(Object, Tuple), - nth1(Position, Tuple, Object), - once(nth1(Position, Descriptor, Role))), - Roles). - - plays_role_in_tuple(Object, Role, Tuple) :- - ::descriptor(Descriptor), - ::tuple(Tuple), - nth1(Position, Tuple, Object), - nth1(Position, Descriptor, Role). - - plays_role_n_times(Object, Role, Number) :- - ::descriptor(Descriptor), - nth1(Position, Descriptor, Role), - setof(Tuple, - (::tuple(Tuple), - nth1(Position, Tuple, Object)), - Tuples), - length(Tuples, Number). - - domains(Domains) :- - ::descriptor(Descriptor), - domains(Descriptor, Domains). - - domains([], []). - domains([Role| Roles], [Domain| Domains]) :- - ::domain_(Role, Domain), - domains(Roles, Domains). - - domain(Role, Domain) :- - ::domain_(Role, Domain). - - set_domains(Domains) :- - \+ ::descriptor(_), - self(Self), - sender(Sender), - throw(error(descriptor_not_defined, Self::set_domains(Domains), Sender)). - - set_domains(Domains) :- - ::tuple(_), - self(Self), - sender(Sender), - throw(error(non_empty_relation, Self::set_domains(Domains), Sender)). - - set_domains(Domains) :- - ::descriptor(Descriptor), - set_domains(Domains, Descriptor). - - - set_domains([], []). - set_domains([Role| Roles], [Domain| Domains]) :- - ::retractall(domain_(Role, _)), - ::assertz(domain_(Role, Domain)), - set_domains(Roles, Domains). - - descriptor(Descriptor) :- - ::descriptor_(Descriptor). - - degree(Degree) :- - ::descriptor_(Descriptor), - length(Descriptor, Degree). - - set_descriptor(Descriptor) :- - \+ ::tuple(_), - ::assertz(descriptor_(Descriptor)), - ::set_keys([Descriptor]), - set_role_defaults(Descriptor). - - set_role_defaults([]). - set_role_defaults([Role| Roles]) :- - ::set_domain(Role, object), - ::set_cardinality(Role, 0, n), - ::set_delete_option(Role, cascade), - set_role_defaults(Roles). - - key(Key) :- - ::key_(Key). - - keys(Keys) :- - findall(Key, ::key_(Key), Keys). - - set_keys(Keys) :- - \+ ::descriptor(_), - self(Self), - sender(Sender), - throw(error(descriptor_not_defined, Self::set_keys(Keys), Sender)). - - set_keys(Keys) :- - ::tuple(_), - self(Self), - sender(Sender), - throw(error(non_empty_relation, Self::set_keys(Keys), Sender)). - - set_keys(Keys) :- - \+ valid_keys(Keys), - self(Self), - sender(Sender), - throw(error(invalid_key, Self::set_keys(Keys), Sender)). - - set_keys(Keys) :- - ::retractall(key_(_)), - set_keys2(Keys). - - set_keys2([]). - set_keys2([Key| Keys]) :- - ::assertz(key_(Key)), - set_keys2(Keys). - - valid_keys(Keys) :- - ::descriptor(Descriptor), - valid_keys(Keys, Descriptor). - - valid_keys([], _). - valid_keys([Key| Keys], Descriptor) :- - forall( - member(Role, Key), - memberchk(Role, Descriptor)), - valid_keys(Keys, Descriptor). - - delete_options(Options) :- - ::descriptor(Descriptor), - delete_options(Descriptor, Options). - - delete_options([], []). - delete_options([Role| Roles], [Option| Options]) :- - ::delete_option_(Role, Option), - delete_options(Roles, Options). - - delete_option(Role, Option) :- - ::delete_option_(Role, Option). - - set_delete_options(Options) :- - \+ ::descriptor(_), - self(Self), - sender(Sender), - throw(error(descriptor_not_defined, Self::set_delete_options(Options), Sender)). - - set_delete_options(Options) :- - ::tuple(_), - self(Self), - sender(Sender), - throw(error(non_empty_relation, Self::set_delete_options(Options), Sender)). - - set_delete_options(Options) :- - ::descriptor(Descriptor), - \+ same_length(Options, Descriptor), - self(Self), - sender(Sender), - throw(error(invalid_length, Self::set_delete_options(Options), Sender)). - - set_delete_options(Options) :- - \+ valid_delete_options(Options), - self(Self), - sender(Sender), - throw(error(invalid_delete_option, Self::set_delete_options(Options), Sender)). - - set_delete_options(Options) :- - ::descriptor(Descriptor), - set_delete_options(Descriptor, Options). - - set_delete_options([], []). - set_delete_options([Role| Roles], [Option| Options]) :- - ::retractall(delete_option_(Role, _)), - ::assertz(delete_option_(Role, Option)), - set_delete_options(Roles, Options). - - valid_delete_options([]). - valid_delete_options([Option| Options]) :- - once((Option = restrict; Option = cascade)), - valid_delete_options(Options). - - cardinalities(Cardinalities) :- - ::descriptor(Descriptor), - cardinalities(Descriptor, Cardinalities). - - cardinalities([], []). - cardinalities([Role| Roles], [(Min, Max)| Cardinalities]) :- - ::cardinality_(Role, Min, Max), - cardinalities(Roles, Cardinalities). - - cardinality(Role, Min, Max) :- - ::cardinality_(Role, Min, Max). - - set_cardinalities(Cardinalities) :- - \+ ::descriptor(_), - self(Self), - sender(Sender), - throw(error(descriptor_not_defined, Self::set_cardinalities(Cardinalities), Sender)). - - set_cardinalities(Cardinalities) :- - ::tuple(_), - self(Self), - sender(Sender), - throw(error(non_empty_relation, Self::set_cardinalities(Cardinalities), Sender)). - - set_cardinalities(Cardinalities) :- - \+ valid_cardinalities(Cardinalities), - self(Self), - sender(Sender), - throw(error(invalid_cardinality, Self::set_cardinalities(Cardinalities), Sender)). - - set_cardinalities(Cardinalities) :- - ::descriptor(Descriptor), - set_cardinalities(Cardinalities, Descriptor). - - - set_cardinalities([], []). - set_cardinalities([(Min, Max)| Cardinalities], [Role| Roles]) :- - ::retractall(cardinality_(Role, _, _)), - ::assertz(cardinality_(Role, Min, Max)), - set_cardinalities(Cardinalities, Roles). - - valid_cardinalities([]). - valid_cardinalities([Cardinality| Cardinalities]) :- - nonvar(Cardinality), - Cardinality = (Min, Max), - lower_cardinality(Min, Max), - valid_cardinalities(Cardinalities). - - lower_cardinality(I, n) :- - integer(I), !. - lower_cardinality(I, J) :- - integer(I), - integer(J), - I < J. - - free(Options) :- - ::remove_all_tuples, - ^^free(Options). - - set_monitors([]). - set_monitors([Object| Objects]) :- - (instantiates_class(Object, Class) -> - self(Self), - before_event_registry::set_monitor(Class, delete(Object, _), _, Self) - ; - true), - set_monitors(Objects). - - del_monitors([]). - del_monitors([Object| Objects]) :- - ((instantiates_class(Object, Class), - \+ (::tuple(Other), member(Object, Other))) -> - self(Self), - before_event_registry::del_monitors(Class, delete(Object, _), _, Self) - ; - true), - del_monitors(Objects). - - del_all_monitors :- - self(Self), - before_event_registry::del_monitors(_, _, _, Self), - after_event_registry::del_monitors(_, _, _, Self). - - before(_, delete(Object, Options), _) :- - !, - ((::delete_option(Role, restrict), - ::plays_role_in_tuple(Object, Role, Tuple)) -> - self(Self), - sender(Sender), - throw(error(can_not_be_deleted(Tuple, Object, Role), Self::delete(Object, Options), Sender)) - ; - forall( - ::plays_role_in_tuple(Object, Role, Tuple), - ::remove_tuple(Tuple))). - - before(_, _, _). - - after(_, _, _). - - restore_monitors :- - self(Self), - before_event_registry::del_monitors(_, _, _, Self), - after_event_registry::del_monitors(_, _, _, Self), - forall(::tuple(Tuple), ::set_monitors(Tuple)). - - print :- - ::descriptor(Descriptor), - write('descriptor:'), nl, write(' '), writeq(Descriptor), nl, - ::domains(Domains), - write('domains:'), nl, write(' '), writeq(Domains), nl, - ::cardinalities(Cardinalities), - write('cardinalities:'), nl, write(' '), writeq(Cardinalities), nl, - ::delete_options(Options), - write('delete options:'), nl, write(' '), writeq(Options), nl, - write('keys:'), nl, - forall(::key(Key), (write(' '), writeq(Key), nl)), - write('tuples:'), nl, - forall(::tuple(Tuple), (write(' '), writeq(Tuple), nl)). - -:- end_object. - - - -:- object(constrained_relation, - implements(monitoring), - instantiates(class), - specializes(relation)). - - :- info([ - version is 3.3, - date is 2006/12/16, - author is 'Paulo Moura', - comment is 'Enables the representation of relations with constraints on the state of participating objects.']). - - :- uses(list, - [member/2, memberchk/2, subtract/3]). - - :- private(activ_points_/3). - :- dynamic(activ_points_/3). - :- mode(activ_points_(?atom, ?event, -list), zero_or_more). - - :- public(activ_point/3). - :- mode(activ_point(?atom, ?event, ?callable), zero_or_more). - - :- public(activ_points/3). - :- mode(activ_points(?atom, ?event, -list), zero_or_more). - - :- public(set_activ_points/3). - :- mode(set_activ_points(+atom, +event, +list), one). - - :- protected(unique_messages/4). - :- mode(unique_messages(+list, +atom, +event, -list), one). - - :- protected(propagate/5). - :- mode(propagate(+atom, +callable, +object, +atom, +list), zero_or_one). - - before(Object, Message, Sender) :- - self(Self), - (Self \= Sender -> - forall( - (::activ_point(Role, before, Message), - ::plays_role_in_tuple(Object, Role, Tuple)), - ::propagate(before, Message, Object, Role, Tuple)) - ; - true), - ^^before(Object, Message, Sender). - - after(Object, Message, Sender) :- - self(Self), - (Self \= Sender -> - forall( - (::activ_point(Role, after, Message), - ::plays_role_in_tuple(Object, Role, Tuple)), - ::propagate(after, Message, Object, Role, Tuple)) - ; - true), - ^^after(Object, Message, Sender). - - set_monitors(Tuple) :- - ^^set_monitors(Tuple), - ::descriptor(Descriptor), - set_monitors(Tuple, Descriptor). - - set_monitors([], []). - set_monitors([Object| Objects], [Role| Roles]) :- - once(::activ_points(Role, before, Messages1)), % avoid spurious backtracking - set_object_before_monitors(Messages1, Object), - once(::activ_points(Role, after, Messages2)), % avoid spurious backtracking - set_object_after_monitors(Messages2, Object), - set_monitors(Objects, Roles). - - set_object_before_monitors([], _). - set_object_before_monitors([Message| Messages], Object) :- - self(Self), - before_event_registry::set_monitor(Object, Message, _, Self), - set_object_before_monitors(Messages, Object). - - set_object_after_monitors([], _). - set_object_after_monitors([Message| Messages], Object) :- - self(Self), - after_event_registry::set_monitor(Object, Message, _, Self), - set_object_after_monitors(Messages, Object). - - del_monitors(Tuple) :- - ^^del_monitors(Tuple), - ::descriptor(Descriptor), - del_monitors(Tuple, Descriptor). - - del_monitors([], []). - del_monitors([Object| Objects], [Role| Roles]) :- - del_object_monitors(Object, Role), - del_monitors(Objects, Roles). - - del_object_monitors(Object, Role) :- - ::plays_roles(Object, Roles) -> - (member(Role, Roles) -> - true - ; - del_object_monitors(Object, Role, Roles)) - ; - del_object_monitors(Object, Role, []). - - del_object_monitors(Object, Role, Roles) :- - ::unique_messages(Roles, Role, before, Messages1), - del_object_before_monitors(Messages1, Object), - ::unique_messages(Roles, Role, after, Messages2), - del_object_after_monitors(Messages2, Object). - - del_object_before_monitors([], _). - del_object_before_monitors([Message| Messages], Object) :- - self(Self), - before_event_registry::del_monitors(Object, Message, _, Self), - del_object_before_monitors(Messages, Object). - - del_object_after_monitors([], _). - del_object_after_monitors([Message| Messages], Object) :- - self(Self), - after_event_registry::del_monitors(Object, Message, _, Self), - del_object_after_monitors(Messages, Object). - - propagate(Event, Message, Object, Role, Tuple) :- - self(Self), - sender(Sender), - throw(error(desc_responsibility, Self::propagate(Event, Message, Object, Role, Tuple), Sender)). - - activ_point(Role, Event, Message) :- - ::activ_points_(Role, Event, Messages), - member(Message, Messages). - - activ_points(Role, Event, List) :- - ::activ_points_(Role, Event, List). - - set_activ_points(Role, Event, List) :- - \+ ::descriptor(_), - self(Self), - sender(Sender), - throw(error(descriptor_not_defined, Self::set_activ_points(Role, Event, List), Sender)). - - set_activ_points(Role, Event, List) :- - ::descriptor(Descriptor), - memberchk(Role, Descriptor), - ::retractall(activ_points_(Role, Event, _)), - ::assertz(activ_points_(Role, Event, List)). - - unique_messages(Roles, Role, Event, Messages) :- - ::activ_points_(Role, Event, Original), - filter_messages(Roles, Original, Event, Messages). - - filter_messages([], Messages, _, Messages). - filter_messages([Role| Roles], Original, Event, Messages) :- - ::activ_points_(Role, Event, Excluded), - subtract(Original, Excluded, Rest), - filter_messages(Roles, Rest, Event, Messages). - - set_descriptor(Descriptor) :- - ^^set_descriptor(Descriptor), - set_default_activ_points(Descriptor). - - set_default_activ_points([]). - set_default_activ_points([Role| Roles]) :- - ::set_activ_points(Role, before, []), - ::set_activ_points(Role, after, []), - set_default_activ_points(Roles). - - print :- - ^^print, - ::descriptor(Descriptor), - write('call activation points:'), nl, - findall(Messages, - (member(Role, Descriptor), - ::activ_points(Role, before, Messages)), - CallList), - write(' '), writeq(CallList), nl, - write('exit activation points:'), nl, - findall(Messages, - (member(Role, Descriptor), - ::activ_points(Role, after, Messages)), - ExitList), - write(' '), writeq(ExitList), nl. - -:- end_object. diff --git a/Logtalk/examples/roots/NOTES.txt b/Logtalk/examples/roots/NOTES.txt deleted file mode 100644 index 6103606d3..000000000 --- a/Logtalk/examples/roots/NOTES.txt +++ /dev/null @@ -1,47 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains rewritten versions of some of the objects provided -with previous, 1.x versions, of the Logtalk system. They are intended to -help the conversion of applications from Logtalk 1.x to 2.x and to -support most of the other examples provided with the current Logtalk -distribution. - -Short description of each example entity: - - class - default metaclass for all classes - classp - protocol of class class - - abstract_class - default metaclass for all abstract classes - abstract_classp - protocol of class abstract_class - - object - root class for class-based hierarchies - objectp - protocol of class object - - initialization - category defining methods for object initialization - - proto - root prototype for prototype-based hierarchies - protop - protocol for prototype proto - - nil - object used to represent a void reference - -Please note that the entities above are just example definitions. There is -nothing fundamental about either of them; they can and should be replaced -by definitions better fitted to the requirements of specific applications. diff --git a/Logtalk/examples/roots/SCRIPT.txt b/Logtalk/examples/roots/SCRIPT.txt deleted file mode 100644 index 02b9cfb19..000000000 --- a/Logtalk/examples/roots/SCRIPT.txt +++ /dev/null @@ -1,37 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(roots(loader)). -... - - -% some queries dealing with instance/class hierarchies: - -| ?- object::ancestors(Ancestors). - -Ancestors = [class, abstract_class, object] - -Yes - - -| ?- class::instances(Instances). - -Instances = [object, abstract_class, class] - -Yes - - -| ?- class::superclass(Super). - -Super = abstract_class ; - -Super = object ; - -No diff --git a/Logtalk/examples/roots/classes.lgt b/Logtalk/examples/roots/classes.lgt deleted file mode 100644 index 1fb9cf0c7..000000000 --- a/Logtalk/examples/roots/classes.lgt +++ /dev/null @@ -1,281 +0,0 @@ - -:- protocol(abstract_classp). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Default protocol for all abstract classes.']). - - :- public(metaclass/0). - :- mode(metaclass, zero_or_one). - :- info(metaclass/0, [ - comment is 'True if the object is a metaclass.']). - - :- public(abstract_class/0). - :- mode(abstract_class, zero_or_one). - :- info(metaclass/0, [ - comment is 'True if the object is an abstract class.']). - -:- end_protocol. - - - -:- object(abstract_class, - implements(abstract_classp), - instantiates(class), - specializes(object)). - - :- info([ - version is 2, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Default metaclass for all abstract classes.']). - - metaclass :- - self(Self), - instantiates_class(Class, Self), - this(This), - Class::ancestor(This). - - abstract_class :- - self(Self), - Self \= abstract_class. - - strict_instance :- - fail. - -:- end_object. - - - -:- protocol(classp). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Default protocol for all instantiable classes.']). - - :- public(new/1). - :- mode(new(?object), zero_or_one). - :- info(new/1, [ - comment is 'Creates a new instance.', - argnames is ['Instance']]). - - :- public(new/2). - :- mode(new(?object, +list), zero_or_one). - :- info(new/2, [ - comment is 'Creates a new instance using a list of initialization options.', - argnames is ['Instance', 'Options']]). - - :- public(clone/2). - :- mode(clone(+object, ?object), zero_or_one). - :- info(clone/2, [ - comment is 'Clones an instance.', - argnames is ['Instance', 'Clone']]). - - :- public(instance_base_name/1). - :- mode(instance_base_name(-atom), one). - :- info(instance_base_name/1, [ - comment is 'Base name to generated new instance names.', - argnames is ['Name']]). - - :- public(delete/1). - :- mode(delete(+object), zero_or_one). - :- info(delete/1, [ - comment is 'Deletes a dynamic instance.', - argnames is ['Instance']]). - - :- public(delete/2). - :- mode(delete(+object, +list), zero_or_one). - :- info(delete/2, [ - comment is 'Deletes a dynamic instance using a list of deleting options.', - argnames is ['Instance', 'Options']]). - - :- public(delete_all/0). - :- mode(delete_all, zero_or_one). - :- info(delete_all/0, [ - comment is 'Deletes all dynamic instances. Fails if some dynamic instance can not be deleted.']). - - :- public(delete_all/1). - :- mode(delete_all(+list), zero_or_one). - :- info(delete_all/1, [ - comment is 'Deletes all dynamic instances using a list of deleting options. Fails if some dynamic instance can not be deleted.', - argnames is ['Options']]). - - :- public(equals/2). - :- mode(equals(+object, +object), zero_or_one). - :- info(equals/2, [ - comment is 'The two instances represents the same object for some definition of equality.', - argnames is ['Instance1', 'Instance2']]). - -:- end_protocol. - - - -:- object(class, - implements(classp), - instantiates(class), - specializes(abstract_class)). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2005/3/12, - comment is 'Default metaclass for all classes.']). - - :- private(instance_counter_/1). - :- dynamic(instance_counter_/1). - :- mode(instance_counter_(?integer), zero_or_one). - :- info(instance_counter_/1, [ - comment is 'Stores a counter of created instances.', - argnames is ['Counter']]). - - new(Object) :- - ::new(Object, []). - - new(Object, Options) :- - valid_new_identifier(Object), - self(Self), - create_object(Object, [instantiates(Self)], [], []), - Object::init(Options). - - clone(Object, Clone) :- - self(Self), - sender(Sender), - throw(error(subclass_responsability, Self::clone(Object, Clone), Sender)). - - delete(Object) :- - ::delete(Object, []). - - delete(Object, Options) :- - ::instance(Object), - Object::free(Options), - abolish_object(Object). - - delete_all :- - ::delete_all([]). - - delete_all(Options) :- - ::instance(Instance), - object_property(Instance, (dynamic)), - ::delete(Instance, Options), - fail. - - delete_all(_) :- - \+ (::instance(Instance), - object_property(Instance, (dynamic))). - - instance_base_name(i). - - instance_counter_(0). - - valid_new_identifier(Identifier) :- - var(Identifier), !, - retract(instance_counter_(Last)), - ::instance_base_name(Base), - functor(Base, Functor, Arity), - number_codes(Arity, Codes), - atom_codes(Atom, Codes), - repeat, - next_integer(Last, Next), - number_codes(Next, Codes2), - atom_codes(Atom2, Codes2), - atom_concat(Functor, Atom2, Identifier), - atom_concat(Identifier, Atom, Prefix), - \+ {current_predicate(Prefix/_)}, - asserta(instance_counter_(Next)), - !. - valid_new_identifier(Identifier) :- - once((atom(Identifier); compound(Identifier))), - functor(Identifier, Functor, Arity), - number_codes(Arity, Codes), - atom_codes(Atom, Codes), - atom_concat(Functor, Atom, Prefix), - \+ {current_predicate(Prefix/_)}. - - next_integer(N, N1) :- - N1 is N + 1. - next_integer(N, N2) :- - N1 is N + 1, - next_integer(N1, N2). - - equals(Instance1, Instance2) :- - self(Self), - sender(Sender), - throw(error(subclass_responsability, Self::equals(Instance1, Instance2), Sender)). - - abstract_class :- - fail. - -:- end_object. - - - -:- protocol(objectp). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Default protocol for all objects.']). - - :- public(strict_instance/0). - :- mode(strict_instance, zero_or_one). - :- info(strict_instance/0, [ - comment is 'True if the object is strictly an instance.']). - - :- public(print/0). - :- mode(print, one). - :- info(print/0, [ - comment is 'Pretty prints an object description.']). - - :- public(nil/0). - :- mode(nil, zero_or_one). - :- info(nil/0, [ - comment is 'True if the object represents a void reference.']). - -:- end_protocol. - - - -:- object(object, - implements(objectp, monitoring), - imports(initialization, class_hierarchy), - instantiates(class)). - - :- info([ - version is 1.1, - date is 2006/12/14, - author is 'Paulo Moura', - comment is 'Minimal predicates for all objects. Default root of the inheritance graph.']). - - :- uses(event_registry). - - strict_instance. - - default_free_option(del_monitors). - - process_free_option(del_monitors) :- - self(Self), - event_registry::del_monitors(Self, _, _, _), - event_registry::del_monitors(_, _, Self, _), - event_registry::del_monitors(_, _, _, Self). - - nil :- - fail. - - print :- - self(Self), - writeq(Self), nl, nl, - forall( - ::current_predicate(Predicate), - (writeq(Predicate), nl)), - nl. - - before(_, _, _). - - after(_, _, _). - -:- end_object. diff --git a/Logtalk/examples/roots/initialization.lgt b/Logtalk/examples/roots/initialization.lgt deleted file mode 100644 index e09bfcc71..000000000 --- a/Logtalk/examples/roots/initialization.lgt +++ /dev/null @@ -1,232 +0,0 @@ - -:- category(initialization). - - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2000/11/5, - comment is 'Object initialization protocol.']). - - - :- uses(list). - - - :- public(init/1). - - :- mode(init(+list), zero_or_one). - - :- info(init/1, - [comment is 'Intialize an object with the given list of options.', - argnames is ['Options']]). - - - :- public(valid_init_option/1). - - :- mode(valid_init_option(+nonvar), zero_or_one). - - :- info(valid_init_option/1, - [comment is 'True if the argument is a valid initialization option.', - argnames is ['Option']]). - - - :- public(valid_init_options/1). - - :- mode(valid_init_options(+list), zero_or_one). - - :- info(valid_init_options/1, - [comment is 'True if the argument is list of valid initialization options.', - argnames is ['Options']]). - - - :- public(default_init_options/1). - - :- mode(default_init_options(+list), one). - - :- info(default_init_options/1, - [comment is 'List of default initilization options.', - argnames is ['Options']]). - - - :- public(default_init_option/1). - - :- mode(default_init_option(?nonvar), zero_or_more). - - :- info(default_init_option/1, - [comment is 'Default initilization option.', - argnames is ['Option']]). - - - :- protected(process_init_option/1). - - :- mode(process_init_option(?nonvar), zero_or_one). - - :- info(process_init_option/1, - [comment is 'Process initilization option.', - argnames is ['Option']]). - - - :- private(process_init_options/1). - - :- mode(process_init_options(+list), zero_or_one). - - :- info(process_init_options/1, - [comment is 'Process a list of initilization options.', - argnames is ['Options']]). - - - :- public(free/1). - - :- mode(free(+list), zero_or_one). - - :- info(free/1, - [comment is 'Release an object with the given list of options.', - argnames is ['Options']]). - - - :- public(valid_free_option/1). - - :- mode(valid_free_option(+nonvar), zero_or_one). - - :- info(valid_init_option/1, - [comment is 'True if the argument is a valid delete option.', - argnames is ['Option']]). - - - :- public(valid_free_options/1). - - :- mode(valid_free_options(+list), zero_or_one). - - :- info(valid_free_options/1, - [comment is 'True if the argument is list of valid delete options.', - argnames is ['Options']]). - - - :- public(default_free_options/1). - - :- mode(default_free_options(+list), one). - - :- info(default_free_options/1, - [comment is 'List of default delete options.', - argnames is ['Options']]). - - - :- public(default_free_option/1). - - :- mode(default_free_option(?nonvar), zero_or_more). - - :- info(default_free_option/1, - [comment is 'Default delete option.', - argnames is ['Option']]). - - - :- protected(process_free_option/1). - - :- mode(process_free_option(?nonvar), zero_or_one). - - :- info(process_free_option/1, - [comment is 'Process delete option.', - argnames is ['Option']]). - - - :- private(process_free_options/1). - - :- mode(process_free_options(+list), zero_or_one). - - :- info(process_free_options/1, - [comment is 'Process a list of delete options.', - argnames is ['Options']]). - - - :- private(merge_options/3). - - :- mode(merge_options(+list, +list, -list), one). - - :- info(merge_options/3, - [comment is 'Constructs a complete list of options complementing the explicit options with the default ones.', - argnames is ['Options', 'Defaults', 'Result']]). - - - init(Options) :- - ::valid_init_options(Options), - ::default_init_options(Defaults), - ::merge_options(Options, Defaults, Options2), - ::process_init_options(Options2). - - - default_init_options(Defaults) :- - findall(Default, ::default_init_option(Default), Defaults). - - - valid_init_options([]). - - valid_init_options([Option| Options]) :- - ::valid_init_option(Option), - valid_init_options(Options). - - - valid_init_option(_). - - - process_init_options([]). - - process_init_options([Option| Options]) :- - once(::process_init_option(Option)), - process_init_options(Options). - - - process_init_option(Option) :- - self(Self), - sender(Sender), - throw(error(existence_error(predicate_definition), Self::process_init_option(Option), Sender)). - - - - free(Options) :- - ::valid_free_options(Options), - ::default_free_options(Defaults), - ::merge_options(Options, Defaults, Options2), - ::process_free_options(Options2). - - - default_free_options(Defaults) :- - findall(Default, ::default_free_option(Default), Defaults). - - - valid_free_options([]). - - valid_free_options([Option| Options]) :- - ::valid_free_option(Option), - valid_free_options(Options). - - - valid_free_option(_). - - - process_free_options([]). - - process_free_options([Option| Options]) :- - once(::process_free_option(Option)), - process_free_options(Options). - - - process_free_option(Option) :- - self(Self), - sender(Sender), - throw(error(existence_error(predicate_definition), Self::process_free_option(Option), Sender)). - - - merge_options([], Defaults, Defaults). - - merge_options([Option-Value| Options], Defaults, [Option-Value| Options2]) :- - !, - (list::select(Option-_, Defaults, Defaults2) -> - merge_options(Options, Defaults2, Options2) - ; - merge_options(Options, Defaults, Options2)). - - merge_options([Option| Options], Defaults, [Option| Options2]) :- - merge_options(Options, Defaults, Options2). - - -:- end_category. diff --git a/Logtalk/examples/roots/loader.lgt b/Logtalk/examples/roots/loader.lgt deleted file mode 100644 index 2762b6076..000000000 --- a/Logtalk/examples/roots/loader.lgt +++ /dev/null @@ -1,8 +0,0 @@ - -:- initialization(( - logtalk_load( - [library(events_loader), library(types_loader), library(hierarchies_loader)], - [reload(skip)]), % allow for static binding - logtalk_load( - [initialization, classes, prototypes, nil], - [unknown(silent)]))). diff --git a/Logtalk/examples/roots/nil.lgt b/Logtalk/examples/roots/nil.lgt deleted file mode 100644 index 7f91d5368..000000000 --- a/Logtalk/examples/roots/nil.lgt +++ /dev/null @@ -1,16 +0,0 @@ - -:- object(nil, - instantiates(object)). - - - :- info([ - version is 1.0, - date is 2000/7/24, - author is 'Paulo Moura', - comment is 'Used to represent a void reference.']). - - - nil. - - -:- end_object. diff --git a/Logtalk/examples/roots/prototypes.lgt b/Logtalk/examples/roots/prototypes.lgt deleted file mode 100644 index 636e3fdf6..000000000 --- a/Logtalk/examples/roots/prototypes.lgt +++ /dev/null @@ -1,62 +0,0 @@ - -:- protocol(protop). - - :- info([ - version is 1.0, - date is 2000/7/24, - author is 'Paulo Moura', - comment is 'Default protocol for all prototypes.']). - - :- public(clone/1). - :- mode(clone(?object), zero_or_one). - :- info(clone/1, [ - comment is 'Clones a prototype.', - argnames is ['Clone']]). - - :- public(print/0). - :- mode(print, one). - :- info(print/0, [ - comment is 'Pretty prints an object description.']). - -:- end_protocol. - - - -:- object(proto, - implements(protop, monitoring), - imports(initialization, proto_hierarchy)). - - :- info([ - version is 1.2, - date is 2006/12/14, - author is 'Paulo Moura', - comment is 'Minimal predicates for all prototypes. Default root of the extension graph.']). - - :- uses(event_registry, [del_monitors/4]). - - clone(Clone) :- - self(Self), - sender(Sender), - throw(error(descendant_responsability, Self::clone(Clone), Sender)). - - default_free_option(del_monitors). - - process_free_option(del_monitors) :- - self(Self), - del_monitors(Self, _, _, _), - del_monitors(_, _, Self, _), - del_monitors(_, _, _, Self). - - print :- - self(Self), - writeq(Self), nl, nl, - forall( - ::current_predicate(Predicate), - (writeq(Predicate), nl)), - nl. - - before(_, _, _). - - after(_, _, _). - -:- end_object. diff --git a/Logtalk/examples/searching/NOTES.txt b/Logtalk/examples/searching/NOTES.txt deleted file mode 100644 index d9a10c722..000000000 --- a/Logtalk/examples/searching/NOTES.txt +++ /dev/null @@ -1,46 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -You will also need to load the following files in the library directory: -dates_loader, types_loader, events_loader, metapredicates_loader, and -hierarchies_loader. Alternatively, you can just load the library all_loader -file. - -Some of the code in this folder is adopted, with permission, from the book -"Prolog Programming for Artificial Intelligence" by Ivan Bratko. - -For a description of the search problems, please see a classical AI book -(such as the one above) or visit the url . - -This example defines two hierarchies of objects, one for representing -state-spaces and another for representing search methods: - - state_space - farmer - water_jug - salt(Quantity, Measure1, Measure2) - heuristic_state_space - bridge - eight_puzzle - miss_cann - - search_strategy - blind_search(Bound) - breadth_first(Bound) - depth_first(Bound) - heuristic_search(Threshold) - best_first(Threshold) - hill_climbing(Threshold) - -Taken together, these two hierarchies implement a framework for solving -state-space search problems in Logtalk. There is also a monitor object, -"performance", which tries to measure the time taken to find a solution, -the branching factor while searching for a solution, and the number of -transitions made to find a solution. diff --git a/Logtalk/examples/searching/SCRIPT.txt b/Logtalk/examples/searching/SCRIPT.txt deleted file mode 100644 index 8f42c5c7c..000000000 --- a/Logtalk/examples/searching/SCRIPT.txt +++ /dev/null @@ -1,354 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(searching(loader)). -... - - -% farmer, cabbage, goat and wolf problem - -| ?- farmer::initial_state(Initial), depth_first(10)::solve(farmer, Initial, Path), farmer::print_path(Path). - -cgwf.<__>..........____ -c_w_..........<__>.f_g_ -c_wf.<__>..........__g_ -__w_..........<__>.fcg_ -_gwf.<__>.........._c__ -_g__..........<__>.fc_w -_g_f.<__>.........._c_w -____..........<__>.fcgw - -Path = [(north,north,north,north),(north,south,north,south),(north,south,north,north),(south,south,north,south),(south,north,north,north),(south,north,south,south),(south,north,south,north),(south,south,south,south)], -Initial = (north,north,north,north) ? - -yes - - -% missionaires and cannibals problem, solved using a hill-climbing strategy - -| ?- miss_cann::initial_state(Initial), hill_climbing(16)::solve(miss_cann, Initial, Path, Cost), miss_cann::print_path(Path). - -MMMCCC.<__>.......... -MMCC..........<__>.MC -MMMCC.<__>..........C -MMM..........<__>.CCC -MMMC.<__>..........CC -MC..........<__>.MMCC -MMCC.<__>..........MC -CC..........<__>.MMMC -CCC.<__>..........MMM -C..........<__>.MMMCC -CC.<__>..........MMMC -..........<__>.MMMCCC - -Cost = 15, -Path = [((3,3),left,0,0),((2,2),right,1,1),((3,2),left,0,1),((3,0),right,0,3),((3,1),left,0,2),((1,1),right,2,2),((2,2),left,1,1),((0,2),right,3,1),((0,3),left,3,0),((0,1),right,3,2),((0,2),left,3,1),((0,0),right,3,3)], -Initial = ((3,3),left,0,0) -yes - - -% same problem as above with the addition of a monitor to measure hill-climbing performance - -| ?- performance::init, miss_cann::initial_state(Initial), hill_climbing(16)::solve(miss_cann, Initial, Path, Cost), miss_cann::print_path(Path), performance::report. - -MMMCCC.<__>.......... -MMCC..........<__>.MC -MMMCC.<__>..........C -MMM..........<__>.CCC -MMMC.<__>..........CC -MC..........<__>.MMCC -MMCC.<__>..........MC -CC..........<__>.MMMC -CCC.<__>..........MMM -C..........<__>.MMMCC -CC.<__>..........MMMC -..........<__>.MMMCCC -solution length: 12 -number of state transitions: 26 -ratio solution length / state transitions: 0.461538 -minimum branching degree: 1 -average branching degree: 2.30769 -maximum branching degree: 3 -time: 0.02 - -Cost = 15, -Path = [((3,3),left,0,0),((2,2),right,1,1),((3,2),left,0,1),((3,0),right,0,3),((3,1),left,0,2),((1,1),right,2,2),((2,2),left,1,1),((0,2),right,3,1),((0,3),left,3,0),((0,1),right,3,2),((0,2),left,3,1),((0,0),right,3,3)], -Initial = ((3,3),left,0,0) ? - -yes - - -% bridge problem, solved using a hill climbing strategy - -| ?- performance::init, bridge::initial_state(Initial), hill_climbing(30)::solve(bridge, Initial, Path, Cost), bridge::print_path(Path), performance::report. - - _|____________|_ lamp 1 3 6 8 12 -1 3 lamp _|____________|_ 6 8 12 -3 _|____________|_ lamp 1 6 8 12 -1 3 6 lamp _|____________|_ 8 12 -3 6 _|____________|_ lamp 1 8 12 -3 6 8 12 lamp _|____________|_ 1 -6 8 12 _|____________|_ lamp 1 3 -1 3 6 8 12 lamp _|____________|_ -solution length: 8 -state transitions: 367 -ratio solution length / state transitions: 0.0217984 -minimum branching degree: 1 -average branching degree: 7.32579 -maximum branching degree: 15 -time: 0.28 - -Initial = [], right, [1, 3, 6, 8, 12] -Path = [ ([], right, [1, 3, 6, 8, 12]), ([1, 3], left, [6, 8, 12]), ([3], right, [1, 6, 8, 12]), ([1, 3, 6], left, [8, 12]), ([3, 6], right, [1, 8|...]), ([3, 6|...], left, [1]), ([6|...], right, [...|...]), ([...|...], ..., ...)] -Cost = 29 - -yes - - -% water jugs problem solved using a breadth and a depth first strategy, with performance monitors -% it's interesting to compare the results - -| ?- performance::init, water_jug::initial_state(Initial), breadth_first(6)::solve(water_jug, Initial, Path), water_jug::print_path(Path), performance::report. - -4-gallon jug: 0 -3-gallon jug: 0 - -4-gallon jug: 0 -3-gallon jug: 3 - -4-gallon jug: 3 -3-gallon jug: 0 - -4-gallon jug: 3 -3-gallon jug: 3 - -4-gallon jug: 4 -3-gallon jug: 2 - -4-gallon jug: 0 -3-gallon jug: 2 - -solution length: 6 -number of state transitions: 109 -ratio solution length / state transitions: 0.0550459 -minimum branching degree: 2 -average branching degree: 3.63158 -maximum branching degree: 4 -time: 0.02 - -Path = [(0,0),(0,3),(3,0),(3,3),(4,2),(0,2)], -Initial = (0,0) ? - -yes - - -| ?- performance::init, water_jug::initial_state(Initial), depth_first(10)::solve(water_jug, Initial, Path), water_jug::print_path(Path), performance::report. - -4-gallon jug: 0 -3-gallon jug: 0 - -4-gallon jug: 4 -3-gallon jug: 0 - -4-gallon jug: 4 -3-gallon jug: 3 - -4-gallon jug: 0 -3-gallon jug: 3 - -4-gallon jug: 3 -3-gallon jug: 0 - -4-gallon jug: 3 -3-gallon jug: 3 - -4-gallon jug: 4 -3-gallon jug: 2 - -4-gallon jug: 0 -3-gallon jug: 2 - -solution length: 8 -number of state transitions: 12 -ratio solution length / state transitions: 0.666667 -minimum branching degree: 1 -average branching degree: 2 -maximum branching degree: 3 -time: 0.00 - -Path = [(0,0),(4,0),(4,3),(0,3),(3,0),(3,3),(4,2),(0,2)], -Initial = (0,0) ? - -yes - - -% salt puzzle using breadth first search - -| ?- performance::init, salt(100, 500, 200)::initial_state(Initial), breadth_first(6)::solve(salt(100, 500, 200), Initial, Path), salt(100, 500, 200)::print_path(Path), performance::report. - -(0, 0, 0) all_empty -(0, 500, 0) fill(m1) -(0, 300, 200) transfer(m1, m2) -(0, 300, 0) empty(m2) -(0, 100, 200) transfer(m1, m2) -(100, 0, 200) transfer(m1, acc) -solution length: 6 -state transitions: 476 -ratio solution length / state transitions: 0.0126050420168067 -minimum branching degree: 1 -average branching degree: 4.05829596412556 -maximum branching degree: 6 -time: 0.0899999999999999 - -Initial = 0, 0, 0, all_empty -Path = [(0, 0, 0, all_empty), (0, 500, 0, fill(m1)), (0, 300, 200, transfer(m1, m2)), (0, 300, 0, empty(m2)), (0, 100, 200, transfer(m1, m2)), (100, 0, 200, transfer(m1, acc))] - -yes - - -| ?- performance::init, salt(200, 250, 550)::initial_state(Initial), breadth_first(7)::solve(salt(200, 250, 550), Initial, Path), salt(200, 250, 550)::print_path(Path), performance::report. - -(0, 0, 0) all_empty -(0, 250, 0) fill(m1) -(0, 0, 250) transfer(m1, m2) -(0, 250, 250) fill(m1) -(0, 0, 500) transfer(m1, m2) -(0, 250, 500) fill(m1) -(0, 200, 550) transfer(m1, m2) -(200, 0, 550) transfer(m1, acc) -solution length: 8 -state transitions: 3037 -ratio solution length / state transitions: 0.00263417846559104 -minimum branching degree: 1 -average branching degree: 4.22404371584699 -maximum branching degree: 6 -time: 1.41 - -Initial = 0, 0, 0, all_empty -Path = [(0, 0, 0, all_empty), (0, 250, 0, fill(m1)), (0, 0, 250, transfer(m1, m2)), (0, 250, 250, fill(m1)), (0, 0, 500, transfer(m1, m2)), (0, 250, 500, fill(m1)), (0, 200, 550, transfer(m1, m2)), (200, 0, 550, transfer(m1, acc))] - -yes - - -| ?- performance::init, salt(100, 250, 550)::initial_state(Initial), breadth_first(11)::solve(salt(100, 250, 550), Initial, Path), salt(100, 250, 550)::print_path(Path), performance::report. - -(0, 0, 0) all_empty -(0, 0, 550) fill(m2) -(0, 250, 300) transfer(m2, m1) -(0, 0, 300) empty(m1) -(0, 250, 50) transfer(m2, m1) -(50, 250, 0) transfer(m2, acc) -(50, 0, 0) empty(m1) -(50, 0, 550) fill(m2) -(50, 250, 300) transfer(m2, m1) -(50, 0, 300) empty(m1) -(50, 250, 50) transfer(m2, m1) -(100, 250, 0) transfer(m2, acc) -solution length: 12 -state transitions: 289904 -ratio solution length / state transitions: 4.13930128594293e-5 -minimum branching degree: 1 -average branching degree: 4.50438946528332 -maximum branching degree: 6 -time: 1882.81 - -Initial = 0, 0, 0, all_empty -Path = [(0, 0, 0, all_empty), (0, 0, 550, fill(m2)), (0, 250, 300, transfer(m2, m1)), (0, 0, 300, empty(m1)), (0, 250, 50, transfer(m2, m1)), (50, 250, 0, transfer(m2, acc)), (50, 0, 0, empty(m1)), (50, 0, 550, fill(m2)), (50, 250, 300, transfer(m2, m1)), (50, 0, 300, empty(m1)), (50, 250, 50, transfer(m2, m1)), (100, 250, 0, transfer(m2, acc))] - -yes - - -% eight puzzle solved using a hill-climbing strategy - -| ?- performance::init, eight_puzzle::initial_state(five_steps, Initial), hill_climbing(25)::solve(eight_puzzle, Initial, Path, Cost), eight_puzzle::print_path(Path), performance::report. - -283 -164 -7 5 - -283 -1 4 -765 - -2 3 -184 -765 - - 23 -184 -765 - -123 - 84 -765 - -123 -8 4 -765 -solution length: 6 -number of state transitions: 15 -ratio solution length / state transitions: 0.4 -minimum branching degree: 2 -average branching degree: 3.13333 -maximum branching degree: 4 -time: 0.01 - -Cost = 5, -Path = [[2/1,1/2,1/3,3/3,3/2,3/1,2/2,1/1,2/3],[2/2,1/2,1/3,3/3,3/2,3/1,2/1,1/1,2/3],[2/3,1/2,1/3,3/3,3/2,3/1,2/1,1/1,2/2],[1/3,1/2,2/3,3/3,3/2,3/1,2/1,1/1,2/2],[1/2,1/3,2/3,3/3,3/2,3/1,2/1,1/1,2/2],[2/2,1/3,2/3,3/3,3/2,3/1,2/1,1/1,1/2]], -Initial = [2/1,1/2,1/3,3/3,3/2,3/1,2/2,1/1,2/3] ? - -yes - - -% eight puzzle solved using a best-first strategy - -| ?- performance::init, eight_puzzle::initial_state(five_steps, Initial), best_first(25)::solve(eight_puzzle, Initial, Path, Cost), eight_puzzle::print_path(Path), performance::report. - -283 -164 -7 5 - -283 -1 4 -765 - -2 3 -184 -765 - - 23 -184 -765 - -123 - 84 -765 - -123 -8 4 -765 -solution length: 6 -number of state transitions: 15 -ratio solution length / state transitions: 0.4 -minimum branching degree: 2 -average branching degree: 3.13333 -maximum branching degree: 4 -time: 0.02 - -Cost = 5, -Path = [[2/1,1/2,1/3,3/3,3/2,3/1,2/2,1/1,2/3],[2/2,1/2,1/3,3/3,3/2,3/1,2/1,1/1,2/3],[2/3,1/2,1/3,3/3,3/2,3/1,2/1,1/1,2/2],[1/3,1/2,2/3,3/3,3/2,3/1,2/1,1/1,2/2],[1/2,1/3,2/3,3/3,3/2,3/1,2/1,1/1,2/2],[2/2,1/3,2/3,3/3,3/2,3/1,2/1,1/1,1/2]], -Initial = [2/1,1/2,1/3,3/3,3/2,3/1,2/2,1/1,2/3] ? - -yes - - -% turn off performance monitor - -| ?- performance::stop. diff --git a/Logtalk/examples/searching/best_first1.lgt b/Logtalk/examples/searching/best_first1.lgt deleted file mode 100644 index 7a2521c2d..000000000 --- a/Logtalk/examples/searching/best_first1.lgt +++ /dev/null @@ -1,104 +0,0 @@ - -:- object(best_first(Threshold), - instantiates(heuristic_search(Threshold))). - - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2005/10/22, - comment is 'Best first heuristic state space search strategy.', - source is 'Example adopted from the book "Prolog Programming for Artificial Intelligence" by Ivan Bratko.', - parnames is ['Threshold']]). - - - :- uses(list, [member/2, reverse/2]). - - :- private(expand/8). - :- private(succlist/5). - :- private(bestf/3). - :- private(continue/9). - :- private(f/2). - :- private(insert/4). - - - search(Space, State, Threshold, Solution, Cost) :- - expand([], l(State, 0/0), Threshold, _, yes, Path, Space, Cost), - reverse(Path, Solution). - - - expand(Path, l(State,Cost/_), _, _, yes, [State|Path], Space, Cost) :- - Space::goal_state(State). - - expand(Path, l(State,F/G), Threshold, Tree, Solved, Solution, Space, Cost) :- - F =< Threshold, - (bagof(Next/Cost2, - (Space::next_state(State, Next, Cost2), \+ member(Next, Path)), - Successors) -> - succlist(G, Successors, Trees, Threshold, Space), - bestf(Trees, F2, Threshold), - expand(Path, t(State, F2/G, Trees), Threshold, Tree, Solved, Solution, Space, Cost) - ; - Solved = never). - - expand(Path, t(State, F/G,[Tree| Trees]), Threshold, Tree3, Solved, Solution, Space, Cost) :- - F =< Threshold, - bestf(Trees, Threshold2, Threshold), - expand([State|Path], Tree, Threshold2, Tree2, Solved2, Solution, Space, Cost), - continue(Path, t(State, F/G, [Tree2| Trees]), Threshold, Tree3, Solved2, Solved, Solution, Space, Cost). - - - expand(_, t(_, _, []), _, _, never, _, _, _) :- - !. - - expand(_, Tree, Threshold, Tree, no, _, _, _) :- - f(Tree, F), - F > Threshold. - - - continue(_, _, _, _, yes, yes, _, _, _). - - continue(Path, t(State, _/G, [Tree| Trees]), Threshold, Tree2, no, Solved, Solution, Space, Cost) :- - insert(Tree, Trees, NewTrees, Threshold), - bestf(NewTrees, F, Threshold), - expand(Path, t(State, F/G, NewTrees), Threshold, Tree2, Solved, Solution, Space, Cost). - - continue(Path,t(State, _/G, [_| Trees]), Threshold, Tree2, never, Solved, Solution, Space, Cost) :- - bestf(Trees, F, Threshold), - expand(Path, t(State, F/G, Trees), Threshold, Tree2, Solved, Solution, Space, Cost). - - - succlist(_, [], [], _, _). - - succlist(G0, [State/Cost| Rest], Trees, Threshold, Space) :- - G is G0 + Cost, - Space::heuristic(State, H), - F is G + H, - succlist(G0, Rest, Trees2, Threshold, Space), - insert(l(State, F/G), Trees2, Trees, Threshold). - - - insert(Tree, [], [Tree], _) :- - !. - - insert(Tree, Trees, [Tree| Trees], Threshold) :- - f(Tree, F), - bestf(Trees, F2, Threshold), - F =< F2, - !. - - insert(Tree, [Tree1| Trees], [Tree1| Trees1], Threshold) :- - insert(Tree, Trees, Trees1, Threshold). - - - f(l(_, F/_), F). - f(t(_, F/_, _), F). - - - bestf([Tree| _], F, _) :- - f(Tree, F). - - bestf([], Threshold, Threshold). - - -:- end_object. diff --git a/Logtalk/examples/searching/blind_search1.lgt b/Logtalk/examples/searching/blind_search1.lgt deleted file mode 100644 index 292575a04..000000000 --- a/Logtalk/examples/searching/blind_search1.lgt +++ /dev/null @@ -1,38 +0,0 @@ - -:- object(blind_search(_), - instantiates(class), - specializes(search_strategy)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 1998/3/23, - comment is 'Blind search state space strategies.', - parnames is ['Bound']]). - - - :- public(bound/1). - :- mode(bound(?integer), zero_or_one). - :- info(bound/1, - [comment is 'Search depth bound.', - argnames is ['Bound']]). - - - :- protected(search/4). - :- mode(search(+object, +nonvar, +integer, -list), zero_or_more). - :- info(search/4, - [comment is 'State space search solution.', - argnames is ['Space', 'State', 'Bound', 'Path']]). - - - bound(Bound) :- - parameter(1, Bound). - - - solve(Space, State, Path) :- - ::bound(Bound), - ::search(Space, State, Bound, Path). - - -:- end_object. diff --git a/Logtalk/examples/searching/breadth_first1.lgt b/Logtalk/examples/searching/breadth_first1.lgt deleted file mode 100644 index a3cd63c34..000000000 --- a/Logtalk/examples/searching/breadth_first1.lgt +++ /dev/null @@ -1,59 +0,0 @@ - -:- object(breadth_first(Bound), - instantiates(blind_search(Bound))). - - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2005/10/22, - comment is 'Breadth first state space search strategy.', - source is 'Example adopted from the book "Prolog Programming for Artificial Intelligence" by Ivan Bratko.', - parnames is ['Bound']]). - - - :- uses(list, [member/2, reverse/2]). - - - search(Space, State, Bound, Solution) :- - breadt(Space, l(State), Bound, Path), - reverse(Path, Solution). - - - breadt(Space, Tree, Bound, Solution) :- - expand([], Tree, Tree2, Solved, Solution, Space, Bound), - (Solved -> - true - ; - breadt(Space, Tree2, Bound, Solution)). - - - expand(Path, l(State), _, true, [State| Path], Space, _) :- - Space::goal_state(State). - - expand(Path, l(State), t(State, Subs), fail, _, Space, Bound) :- - Bound > 0, - bagof(l(Next), - (Space::next_state(State, Next), - \+ member(Next, [State| Path])), - Subs). - - expand(Path, t(State,Subs), t(State, Subs2), Solved, Solution, Space, Bound) :- - expandall([State| Path], Subs, [], Subs2, Solved, Solution, Space, Bound). - - - expandall(_, [], [Tree| Trees], [Tree| Trees], fail, _, _, _). - - expandall(Path, [Tree| Trees], Trees2, Subs2, Solved, Solution, Space, Bound) :- - Bound > 0, - Bound2 is Bound -1, - expand(Path, Tree, Tree2, Solved2, Solution, Space, Bound2), - (Solved2 -> - Solved = true - ; - expandall(Path, Trees, [Tree2| Trees2], Subs2, Solved, Solution, Space, Bound)) - ; - expandall(Path, Trees, Trees2, Subs2, Solved, Solution, Space, Bound). - - -:- end_object. diff --git a/Logtalk/examples/searching/bridge.lgt b/Logtalk/examples/searching/bridge.lgt deleted file mode 100644 index 4ffab38a7..000000000 --- a/Logtalk/examples/searching/bridge.lgt +++ /dev/null @@ -1,79 +0,0 @@ - -:- object(bridge, - instantiates(heuristic_state_space)). - - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2004/8/15, - comment is 'Bridge puzzle.']). - - - :- uses(list, [append/3]). - :- uses(numberlist, [min/2, max/2]). - :- uses(set, [insert/3, insert_all/3, select/3]). - - - initial_state(start, ([], right, [1,3,6,8,12])). - - - goal_state(end, ([1,3,6,8,12], left, [])). - - - next_state((Left1, left, Right1), (Left2, right, Right2), Slower) :- % two persons - append(List, [Person1| Persons], Left1), - select(Person2, Persons, Others), - append(List, Others, Left2), - insert_all([Person1, Person2], Right1, Right2), - (Person1 > Person2 -> - Slower = Person1 - ; - Slower = Person2). - - next_state((Left1, right, Right1), (Left2, left, Right2), Slower) :- % two persons - append(List, [Person1| Persons], Right1), - select(Person2, Persons, Others), - append(List, Others, Right2), - insert_all([Person1, Person2], Left1, Left2), - (Person1 > Person2 -> - Slower = Person1 - ; - Slower = Person2). - - next_state((Left1, left, Right1), (Left2, right, Right2), Person) :- % one person - select(Person, Left1, Left2), - insert(Right1, Person, Right2). - - next_state((Left1, right, Right1), (Left2, left, Right2), Person) :- % one person - select(Person, Right1, Right2), - insert(Left1, Person, Left2). - - - heuristic((Left, Lamp, Right), Heuristic) :- - Lamp = left -> - list::min(Left, Heuristic) - ; - list::max(Right, Max), - list::min(Right, Min), - Heuristic is Max + Min. - - - print_state((Left, Lamp, Right)) :- - write_list(Left), - (Lamp = left -> - write(' lamp _|____________|_ ') - ; - write(' _|____________|_ lamp ')), - write_list(Right), - nl. - - - write_list([]). - - write_list([Head| Tail]) :- - write(Head), write(' '), - write_list(Tail). - - -:- end_object. diff --git a/Logtalk/examples/searching/depth_first1.lgt b/Logtalk/examples/searching/depth_first1.lgt deleted file mode 100644 index 8b9bdfc52..000000000 --- a/Logtalk/examples/searching/depth_first1.lgt +++ /dev/null @@ -1,33 +0,0 @@ - -:- object(depth_first(Bound), - instantiates(blind_search(Bound))). - - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2005/10/22, - comment is 'Depth first state space search strategy.', - parnames is ['Bound']]). - - - :- uses(list, [member/2, reverse/2]). - - - search(Space, State, Bound, Solution) :- - depth(Space, State, Bound, [], Path), - reverse(Path, Solution). - - - depth(Space, State, _, Path, [State| Path]) :- - Space::goal_state(State). - - depth(Space, State, Bound, Path, Solution) :- - Bound > 0, - Space::next_state(State, Next), - \+ member(Next, [State| Path]), - Bound2 is Bound - 1, - depth(Space, Next, Bound2, [State| Path], Solution). - - -:- end_object. diff --git a/Logtalk/examples/searching/eight_puzzle.lgt b/Logtalk/examples/searching/eight_puzzle.lgt deleted file mode 100644 index 15a70aed3..000000000 --- a/Logtalk/examples/searching/eight_puzzle.lgt +++ /dev/null @@ -1,105 +0,0 @@ - -:- object(eight_puzzle, - instantiates(heuristic_state_space)). - - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2004/8/15, - comment is 'Eight puzzle heuristic state space search problem.']). - - - :- uses(list, [member/2]). - - - initial_state(four_steps, [2/2,1/3,3/2,2/3,3/3,3/1,2/1,1/1,1/2]). - - initial_state(five_steps, [2/1,1/2,1/3,3/3,3/2,3/1,2/2,1/1,2/3]). - - initial_state(eighteen_steps, [2/2,2/3,1/3,3/1,1/2,2/1,3/3,1/1,3/2]). - - - goal_state(goal, [2/2,1/3,2/3,3/3,3/2,3/1,2/1,1/1,1/2]). - - - print_state([S0,S1,S2,S3,S4,S5,S6,S7,S8]) :- - member(Y, [3, 2, 1]), - nl, - member(X, [1, 2, 3]), - member(Tile-X/Y, [' '-S0,1-S1,2-S2,3-S3,4-S4,5-S5,6-S6,7-S7,8-S8]), - write(Tile), - fail. - - print_state(_) :- - nl. - - - next_state([Empty| L], [Tile| L2], 1) :- - swap(Empty, Tile, L, L2). - - - swap(Empty, Tile, [Tile| L], [Empty| L]) :- - dist(Empty, Tile, 1). - - swap(Empty, Tile, [Tile2| L], [Tile2| L2]) :- - swap(Empty, Tile, L, L2). - - - dist(X/Y, X2/Y2, D) :- - abs_diff(X, X2, Dx), - abs_diff(Y, Y2, Dy), - D is Dx + Dy. - - - abs_diff(A, B, D) :- - A > B -> - D is A - B - ; - D is B - A. - - - heuristic([_| L], H) :- - goal_state(_, [_| G]), - totdist(L, G, 0, D), - seq(L, S), - H is D + 3*S. - - - totdist([], [], D, D). - - totdist([T| L], [T2| L2], Acc, D) :- - dist(T, T2, D1), - Acc2 is Acc + D1, - totdist(L, L2, Acc2, D). - - - seq([First| L], S) :- - seq([First| L], First, 0, S). - - - seq([T1, T2| L], First, Acc, S) :- - score(T1, T2, S1), - Acc2 is Acc + S1, - seq([T2| L], First, Acc2, S). - - seq([Last], First, Acc, S) :- - score(Last, First, Score), - S is Acc + Score. - - - score(2/2, _, 1) :- !. - - score(1/3, 2/3, 0) :- !. - score(2/3, 3/3, 0) :- !. - score(3/3, 3/2, 0) :- !. - score(3/2, 3/1, 0) :- !. - score(3/1, 2/1, 0) :- !. - score(2/1, 1/1, 0) :- !. - score(1/1, 1/2, 0) :- !. - score(1/2, 1/3, 0) :- !. - - score(_, _, 2) :- !. - - -:- end_object. diff --git a/Logtalk/examples/searching/farmer.lgt b/Logtalk/examples/searching/farmer.lgt deleted file mode 100644 index e79939445..000000000 --- a/Logtalk/examples/searching/farmer.lgt +++ /dev/null @@ -1,63 +0,0 @@ - -:- object(farmer, - instantiates(state_space)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 1998/3/23, - comment is 'Farmer, cabbage, goat, and wolf state space search problem.']). - - - initial_state(start, (north, north, north, north)). - - - goal_state(end, (south, south, south, south)). - - - next_state((Cabbage, Goat, Wolf, Farmer), (FCabbage, Goat, Wolf, FFarmer)) :- - same_side(Farmer, Cabbage), - \+ same_side(Goat, Wolf), - flip(Farmer, FFarmer), - flip(Cabbage, FCabbage). - - next_state((Cabbage, Goat, Wolf, Farmer), (Cabbage, FGloat, Wolf, FFarmer)) :- - same_side(Farmer, Goat), - flip(Farmer, FFarmer), - flip(Goat, FGloat). - - next_state((Cabbage, Goat, Wolf, Farmer), (Cabbage, Goat, FWolf, FFarmer)) :- - same_side(Farmer, Wolf), - \+ same_side(Cabbage, Goat), - flip(Farmer, FFarmer), - flip(Wolf, FWolf). - - next_state((Cabbage, Goat, Wolf, Farmer), (Cabbage, Goat, Wolf, FFarmer)) :- - \+ same_side(Cabbage, Goat), - \+ same_side(Goat, Wolf), - flip(Farmer, FFarmer). - - - flip(north, south). - - flip(south, north). - - - same_side(north, north). - - same_side(south, south). - - - print_state((Cabbage, Goat, Wolf, Farmer)) :- - (Cabbage = north -> write(c); write('_')), - (Goat = north -> write(g); write('_')), - (Wolf = north -> write(w); write('_')), - (Farmer = north -> write('f.<__>.........._'); write('_..........<__>.f')), - (Cabbage = north -> write('_'); write(c)), - (Goat = north -> write('_'); write(g)), - (Wolf = north -> write('_'); write(w)), - nl. - - -:- end_object. diff --git a/Logtalk/examples/searching/heuristic_search1.lgt b/Logtalk/examples/searching/heuristic_search1.lgt deleted file mode 100644 index e17f31367..000000000 --- a/Logtalk/examples/searching/heuristic_search1.lgt +++ /dev/null @@ -1,48 +0,0 @@ - -:- object(heuristic_search(_), - instantiates(class), - specializes(search_strategy)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 1998/3/23, - comment is 'Heuristic state space search strategies.', - parnames is ['Threshold']]). - - - :- public(threshold/1). - :- mode(threshold(?number), one). - :- info(threshold/1, - [comment is 'Search cost threshold.', - argnames is ['Threshold']]). - - :- public(solve/4). - :- mode(solve(+object, +nonvar, -list, -number), zero_or_more). - :- info(solve/4, - [comment is 'State space search solution.', - argnames is ['Space', 'State', 'Path', 'Cost']]). - - - :- protected(search/5). - :- mode(search(+object, +nonvar, +number, -list, -number), zero_or_more). - :- info(search/5, - [comment is 'State space search solution.', - argnames is ['Space', 'State', 'Threshold', 'Path', 'Cost']]). - - - solve(Space, State, Path) :- - ::solve(Space, State, Path, _). - - - solve(Space, State, Path, Cost) :- - ::threshold(Threshold), - ::search(Space, State, Threshold, Path, Cost). - - - threshold(Threshold) :- - parameter(1, Threshold). - - -:- end_object. diff --git a/Logtalk/examples/searching/heuristic_state_space.lgt b/Logtalk/examples/searching/heuristic_state_space.lgt deleted file mode 100644 index 24a38fc66..000000000 --- a/Logtalk/examples/searching/heuristic_state_space.lgt +++ /dev/null @@ -1,36 +0,0 @@ - -:- object(heuristic_state_space, - instantiates(class), - specializes(state_space)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 1998/3/23, - comment is 'Heuristic state space.']). - - - :- public(next_state/3). - - :- mode(next_state(+nonvar, -nonvar, -number), zero_or_more). - - :- info(next_state/3, - [comment is 'Generates a state sucessor.', - argnames is ['State', 'Next', 'Cost']]). - - - :- public(heuristic/2). - - :- mode(heuristic(+nonvar, -number), one). - - :- info(heuristic/2, - [comment is 'Estimates state distance to a goal state.', - argnames is ['State', 'Estimate']]). - - - next_state(Prev, Next) :- - ::next_state(Prev, Next, _). - - -:- end_object. diff --git a/Logtalk/examples/searching/hill_climbing1.lgt b/Logtalk/examples/searching/hill_climbing1.lgt deleted file mode 100644 index afa6bb9ae..000000000 --- a/Logtalk/examples/searching/hill_climbing1.lgt +++ /dev/null @@ -1,43 +0,0 @@ - -:- object(hill_climbing(Threshold), - instantiates(heuristic_search(Threshold))). - - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2004/8/15, - comment is 'Hill climbing heuristic state space search strategy.', - parnames is ['Threshold']]). - - - :- uses(list, - [member/2, reverse/2, sort/2]). - - :- private(hill/7). - - - search(Space, State, Threshold, Solution, Cost) :- - hill(Space, State, Threshold, [], Path, 0, Cost), - reverse(Path, Solution). - - - hill(Space, State, _, Path, [State| Path], Cost, Cost) :- - Space::goal_state(State). - - hill(Space, State, Threshold, Path, Solution, SoFar, Total) :- - findall( - (Estimate, Cost, Next), - (Space::next_state(State, Next, Cost), - \+ member(Next, [State| Path]), - Space::heuristic(Next, Guess), - Estimate is Guess + Cost), - States), - sort(States, SortedStates), - member((_, Cost2, Next2), SortedStates), - SoFar2 is SoFar + Cost2, - SoFar2 =< Threshold, - hill(Space, Next2, Threshold, [State| Path], Solution, SoFar2, Total). - - -:- end_object. diff --git a/Logtalk/examples/searching/loader.lgt b/Logtalk/examples/searching/loader.lgt deleted file mode 100644 index 63a39a3de..000000000 --- a/Logtalk/examples/searching/loader.lgt +++ /dev/null @@ -1,22 +0,0 @@ - -:- initialization(( - logtalk_load(library(all_loader), [reload(skip)]), % allow for static binding - logtalk_load(roots(loader), [reload(skip)]), % allow for static binding - logtalk_load([ - state_space, - water_jug, - salt3, - farmer, - heuristic_state_space, - bridge, - eight_puzzle, - miss_cann, - search_strategy, - blind_search1, - breadth_first1, - depth_first1, - heuristic_search1, - best_first1, - hill_climbing1, - performance], - [events(on)]))). diff --git a/Logtalk/examples/searching/miss_cann.lgt b/Logtalk/examples/searching/miss_cann.lgt deleted file mode 100644 index fe7f8ea8b..000000000 --- a/Logtalk/examples/searching/miss_cann.lgt +++ /dev/null @@ -1,85 +0,0 @@ - -:- object(miss_cann, - instantiates(heuristic_state_space)). - - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2000/11/21, - comment is 'Missionaries and cannibals heuristic state space search problem.']). - - - :- uses(loop, [forto/3]). - - - initial_state(start, ((3,3), left, (0,0))). - - - goal_state(end, ((0,0), right, (3,3))). - - - print_state(((Me,Ce), B, (Md,Cd))) :- - forto(1, Me, write('M')), - forto(1, Ce, write('C')), - (B = left -> - write('.<__>..........') - ; - write('..........<__>.')), - forto(1, Md, write('M')), - forto(1, Cd, write('C')), - nl. - - - next_state(((Me,Ce),left,(Md,Cd)), ((Me2,Ce2),right,(Md2,Cd2)), 1) :- %mm - Me >= 2, - once((Me - 2 =:= 0; Me - 2 >= Ce)), - Cd =< 2, - Me2 is Me - 2, - Ce2 is Ce, - Md2 is Md + 2, - Cd2 is Cd. - - next_state(((Me,Ce),left,(Md,Cd)), ((Me2,Ce2),right,(Md2,Cd2)), 2) :- %m - Me >= 1, - once((Me - 1 =:= 0; Me - 1 >= Ce)), - Cd =< 1, - Me2 is Me - 1, - Ce2 is Ce, - Md2 is Md + 1, - Cd2 is Cd. - - next_state(((Me,Ce),left,(Md,Cd)), ((Me2,Ce2),right,(Md2,Cd2)), 1) :- %cc - Ce >= 2, - once((Md >= Cd + 2; Md =:= 0)), - Me2 is Me, - Ce2 is Ce - 2, - Md2 is Md, - Cd2 is Cd + 2. - - next_state(((Me,Ce),left,(Md,Cd)), ((Me2,Ce2),right,(Md2,Cd2)), 2) :- %c - Ce >= 1, - once((Md >= Cd + 1; Md =:= 0)), - Me2 is Me, - Ce2 is Ce - 1, - Md2 is Md, - Cd2 is Cd + 1. - - next_state(((Me,Ce),left,(Md,Cd)), ((Me2,Ce2),right,(Md2,Cd2)), 1) :- %mc - Me >= 1, - Ce >= 1, - Md >= Cd, - Me2 is Me - 1, - Ce2 is Ce - 1, - Md2 is Md + 1, - Cd2 is Cd + 1. - - next_state(((Me,Ce),right,(Md,Cd)), ((Me2,Ce2),left,(Md2,Cd2)), Cost) :- - next_state(((Md,Cd),left,(Me,Ce)), ((Md2,Cd2),right,(Me2,Ce2)), Cost). - - - heuristic(((_, _), _, (Md, Cd)), Cost) :- - Cost is 6 - (Md + Cd). - - -:- end_object. diff --git a/Logtalk/examples/searching/performance.lgt b/Logtalk/examples/searching/performance.lgt deleted file mode 100644 index db8da76b8..000000000 --- a/Logtalk/examples/searching/performance.lgt +++ /dev/null @@ -1,161 +0,0 @@ - -:- object(performance, - implements(monitoring)). - - - :- info([ - version is 1.3, - author is 'Paulo Moura', - date is 2006/12/14, - comment is 'Performance monitor for state space searches.']). - - - :- uses(event_registry). - :- uses(before_event_registry). - :- uses(after_event_registry). - - :- uses(list, [length/2]). - :- uses(numberlist, [min/2, max/2, sum/2]). - :- uses(time, [cpu_time/1]). - - - :- private(transitions_/3). - :- dynamic(transitions_/3). - :- mode(transitions_(?state, ?state, ?integer), zero_or_more). - - :- private(solution_length_/1). - :- dynamic(solution_length_/1). - :- mode(solution_length_(?integer), zero_or_one). - - :- private(time_/1). - :- dynamic(time_/1). - :- mode(time_(-number), zero_or_one). - - :- public(time/1). - :- mode(time(-number), zero_or_one). - - :- public(transitions/1). - :- mode(transitions(-number), zero_or_one). - - :- public(branching/3). - :- mode(branching(-integer, -float, -integer), zero_or_one). - - :- public(report/0). - :- mode(report, zero_or_one). - - :- public(init/0). - :- mode(init, one). - - :- public(stop/0). - :- mode(stop, one). - - - report :- - solution_length_(Length), - transitions(Number), - Ratio is Length / Number, - branching(Minimum, Average, Maximum), - time(Time), - write('solution length: '), write(Length), nl, - write('state transitions (including past solutions): '), write(Number), nl, - write('ratio solution length / state transitions: '), write(Ratio), nl, - write('minimum branching degree: '), write(Minimum), nl, - write('average branching degree: '), write(Average), nl, - write('maximum branching degree: '), write(Maximum), nl, - write('time: '), write(Time), nl. - - report :- % clean up for next solution - retractall(time_(_)), - retractall(solution_length_(_)), - cpu_time(Start), - asserta(time_(Start)), - fail. - - - transitions(Number) :- - findall(N, transitions_(_, _, N), List), - sum(List, Number). - - - time(Time) :- - cpu_time(End), - retract(time_(Start)), - Time is End - Start. - - - branching(Minimum, Average, Maximum) :- - findall( - Length, - (transitions_(State1, _, _), - findall(State2, transitions_(State1, State2, _), States2), - length(States2, Length)), - Lengths), - min(Lengths, Minimum), - max(Lengths, Maximum), - sum(Lengths, Sum), - length(Lengths, Length), - Average is Sum / Length. - - - init :- - self(Self), - event_registry::set_monitor(_, solve(_, _, _), _, Self), - after_event_registry::set_monitor(_, next_state(_, _), _, Self), - event_registry::set_monitor(_, solve(_, _, _, _), _, Self), - after_event_registry::set_monitor(_, next_state(_, _, _), _, Self), - retractall(transitions_(_, _, _)), - retractall(time_(_)), - retractall(solution_length_(_)). - - - stop :- - self(Self), - before_event_registry::del_monitors(_, _, _, Self), - after_event_registry::del_monitors(_, _, _, Self). - - - before(_, solve(_, _, _), _) :- - !, - retractall(transitions_(_, _, _)), - cpu_time(Start), - retractall(time_(_)), - asserta(time_(Start)). - - before(_, solve(_, _, _, _), _) :- - !, - retractall(transitions_(_, _, _)), - cpu_time(Start), - retractall(time_(_)), - asserta(time_(Start)). - - - after(_, next_state(S1, S2), _) :- - !, - (retract(transitions_(S1, S2, N)) -> - N2 is N + 1 - ; - N2 is 1), - assertz(transitions_(S1, S2, N2)). - - after(_, next_state(S1, S2, _), _) :- - !, - (retract(transitions_(S1, S2, N)) -> - N2 is N + 1 - ; - N2 is 1), - assertz(transitions_(S1, S2, N2)). - - after(_, solve(_, _, Solution), _) :- - !, - length(Solution, Length), - retractall(solution_length_(_)), - asserta(solution_length_(Length)). - - after(_, solve(_, _, Solution, _), _) :- - !, - length(Solution, Length), - retractall(solution_length_(_)), - asserta(solution_length_(Length)). - - -:- end_object. diff --git a/Logtalk/examples/searching/salt3.lgt b/Logtalk/examples/searching/salt3.lgt deleted file mode 100755 index b3e41f58b..000000000 --- a/Logtalk/examples/searching/salt3.lgt +++ /dev/null @@ -1,119 +0,0 @@ -/* - Salt state-space search problem - - 2003 Portuguese National Logical Programming Contest problem - http://paginas.fe.up.pt/~eol/LP/0304/documents/Exercicios_CNPL.PDF - -Introduction: - Mr Silva sells salt. He has to measure the quantity requested by his - customers by using two measures and an accumulator. Neither has any - measuring markers. Those measures can easily be broken and he has to - replace them each time it happens. More, a substitution can be made - by a measure with a different capacity than the one being replaced. - -Objective: - To produce a program, given the capacity of two measures and the - intended quantity, which helps Mr. Silva knowing if it is possible - to obtain the amount requested by his customer, and if so, measuring - the intended quantity in the least amount of steps. - -Remarks: - This problem is similar to the Water Jug's' problem. It is more general, - seeing that the Water Jug's problem uses static values for the jugs - capacities and the final goal. -*/ - - -:- object(salt(_Acumulator, _Measure1, _Measure2), - instantiates(state_space)). - - - :- info([ - version is 1.0, - author is 'Paula Marisa Sampaio', - date is 2005/06/08, - comment is 'Salt state-space search problem.']). - - - % each state is represented by a compound term with four arguments: (Acumulator, Measure1, Measure2, Step) - - initial_state(initial, (0, 0, 0, all_empty)). - - - % the intended salt quantity must end up on the acumulator - - goal_state(acumulator, (Acumulator, _, _, _)) :- - parameter(1, Acumulator). - - - % state transitions: - - - % emptying a measure into the accumulator - - next_state((Acc, X, Y, _), (NewAcc, 0, Y, transfer(m1, acc))) :- - X > 0, - NewAcc is Acc + X. - - next_state((Acc, X, Y, _), (NewAcc, X, 0, transfer(m2, acc))) :- - Y > 0, - NewAcc is Acc + Y. - - - % filling up of one of the measures - - next_state((Acc, X, Y, Step), (Acc, MaxX, Y, fill(m1))) :- - parameter(2, MaxX), - X < MaxX, - Step \= empty(m1). - - next_state((Acc, X, Y, Step), (Acc, X, MaxY, fill(m2))) :- - parameter(3, MaxY), - Y < MaxY, - Step \= empty(m2). - - - % either pouring of a measure into the other till it is filled up - % or all content of a measure into the other one - - next_state((Acc, X, Y, _), (Acc, W, Z, transfer(m2, m1))) :- - parameter(2, MaxX), - Y > 0, - X < MaxX, - (X + Y >= MaxX -> - W = MaxX, - Z is Y - (MaxX - X) - ; - W is X + Y, - Z = 0 - ). - - next_state((Acc, X, Y, _), (Acc, W, Z, transfer(m1, m2))) :- - parameter(3, MaxY), - X > 0, - Y < MaxY, - (X + Y >= MaxY -> - W is X - (MaxY - Y), - Z = MaxY - ; - W = 0, - Z is X + Y - ). - - - % throwing out the contents of a measure; does not afect the accumulator - - next_state((Acc, X, Y, Step), (Acc, 0, Y, empty(m1))) :- - X > 0, - Step \= fill(m1). - - next_state((Acc, X, Y, Step), (Acc, X, 0, empty(m2))) :- - Y > 0, - Step \= fill(m2). - - - print_state((Acc, X, Y, Step)) :- - write('('), write((Acc, X, Y)), write(') '), write(Step), nl. - - -:- end_object. diff --git a/Logtalk/examples/searching/search_strategy.lgt b/Logtalk/examples/searching/search_strategy.lgt deleted file mode 100644 index 6ea0fe4b1..000000000 --- a/Logtalk/examples/searching/search_strategy.lgt +++ /dev/null @@ -1,21 +0,0 @@ - -:- object(search_strategy, - instantiates(abstract_class), - specializes(object)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 1998/3/23, - comment is 'State space search strategies.']). - - - :- public(solve/3). - :- mode(solve(+object, +nonvar, -list), zero_or_more). - :- info(solve/3, - [comment is 'State space search solution.', - argnames is ['Space', 'State', 'Path']]). - - -:- end_object. diff --git a/Logtalk/examples/searching/state_space.lgt b/Logtalk/examples/searching/state_space.lgt deleted file mode 100644 index 38cdd6c45..000000000 --- a/Logtalk/examples/searching/state_space.lgt +++ /dev/null @@ -1,76 +0,0 @@ - -:- object(state_space, - instantiates(class), - specializes(object)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 1998/3/23, - comment is 'State space description predicates.']). - - - :- public(initial_state/1). - :- mode(initial_state(?nonvar), one_or_more). - :- info(initial_state/1, - [comment is 'Initial state.', - argnames is ['State']]). - - :- public(initial_state/2). - :- mode(initial_state(?atom, ?nonvar), zero_or_more). - :- info(initial_state/2, - [comment is 'Named initial state.', - argnames is ['Name', 'State']]). - - :- public(next_state/2). - :- mode(next_state(+nonvar, -nonvar), zero_or_more). - :- info(next_state/2, - [comment is 'Generates a state sucessor.', - argnames is ['State', 'Next']]). - - :- public(goal_state/1). - :- mode(goal_state(?nonvar), one_or_more). - :- info(goal_state/1, - [comment is 'Goal state.', - argnames is ['State']]). - - :- public(goal_state/2). - :- mode(goal_state(?atom, ?nonvar), zero_or_more). - :- info(goal_state/2, - [comment is 'Named goal state.', - argnames is ['Name', 'State']]). - - :- public(print_state/1). - :- mode(print_state(+nonvar), one). - :- info(print_state/1, - [comment is 'Pretty print state.', - argnames is ['State']]). - - :- public(print_path/1). - :- mode(print_path(+list), one). - :- info(print_path/1, - [comment is 'Pretty print a path (list of states).', - argnames is ['Path']]). - - - initial_state(State) :- - ::initial_state(_, State). - - - goal_state(State) :- - ::goal_state(_, State). - - - print_state(State) :- - writeq(State), nl. - - - print_path([]). - - print_path([State| States]) :- - ::print_state(State), - print_path(States). - - -:- end_object. diff --git a/Logtalk/examples/searching/water_jug.lgt b/Logtalk/examples/searching/water_jug.lgt deleted file mode 100644 index cc5b39183..000000000 --- a/Logtalk/examples/searching/water_jug.lgt +++ /dev/null @@ -1,59 +0,0 @@ - -:- object(water_jug, - instantiates(state_space)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 1998/3/23, - comment is 'Water jug state space search problem.']). - - - initial_state(start, (0, 0)). - - - goal_state(end1, (2, 0)). - - goal_state(end2, (0, 2)). - - - next_state((X, Y), (4, Y)) :- - X < 4. - - next_state((X, Y),(X, 3)) :- - Y < 3. - - next_state((X, Y), (4, Z)) :- - Y > 0, X < 4, - Aux is X + Y, Aux >= 4, - Z is Y - (4 - X). - - next_state((X, Y), (Z, 3)) :- - X > 0, Y < 3, - Aux is X + Y, Aux >= 3, - Z is X - (3 - Y). - - next_state((X, Y),(Z, 0)) :- - Y > 0, - Aux is X + Y, Aux =< 4, - Z is Y + X. - - next_state((X, Y),(0, Z)) :- - X > 0, - Aux is X + Y, Aux =< 3, - Z is Y + X. - - next_state((X, Y), (0, Y)) :- - X > 0. - - next_state((X, Y), (X, 0)) :- - Y > 0. - - - print_state((X, Y)) :- - write('4-gallon jug: '), write(X), nl, - write('3-gallon jug: '), write(Y), nl, nl. - - -:- end_object. diff --git a/Logtalk/examples/shapes/NOTES.txt b/Logtalk/examples/shapes/NOTES.txt deleted file mode 100644 index 6e71f55e3..000000000 --- a/Logtalk/examples/shapes/NOTES.txt +++ /dev/null @@ -1,28 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This directory contains two versions, one prototype-based and the -other one class-based, of a very simple geometric shapes hierarchy. - -The aim of this example is to compare the pros and cons of using -either prototypes or classes for defining object hierarchies. - -ph - prototype-based version - -ch - class-based version - -Both versions define the following hierarchy of objects: - - shape - polygon - regular_polygon - square - q1 - q2 diff --git a/Logtalk/examples/shapes/ch/NOTES.txt b/Logtalk/examples/shapes/ch/NOTES.txt deleted file mode 100644 index 1ed2ccb62..000000000 --- a/Logtalk/examples/shapes/ch/NOTES.txt +++ /dev/null @@ -1,10 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT -file. diff --git a/Logtalk/examples/shapes/ch/SCRIPT.txt b/Logtalk/examples/shapes/ch/SCRIPT.txt deleted file mode 100644 index 4d474dbcc..000000000 --- a/Logtalk/examples/shapes/ch/SCRIPT.txt +++ /dev/null @@ -1,40 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(shapes_ch(loader)). -... - - -% try some simple queries: - - -| ?- square::nsides(N). - -! error( - existence_error(predicate_declaration, nsides(_)), - square::nsides(N), - user) - - -| ?- q1::(color(Color), side(Side), position(X, Y)). - -Color = red -Side = 1 -X = 0 -Y = 0 -yes - - -| ?- q2::(side(Side), area(Area), perimeter(Perimeter)). - -Side = 3 -Area = 9 -Perimeter = 12 -yes diff --git a/Logtalk/examples/shapes/ch/ch.lgt b/Logtalk/examples/shapes/ch/ch.lgt deleted file mode 100644 index 0699d4939..000000000 --- a/Logtalk/examples/shapes/ch/ch.lgt +++ /dev/null @@ -1,132 +0,0 @@ - -% "shape" abstract class - -:- object(shape, - instantiates(abstract_class), - specializes(object)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2003/2/3, - comment is 'Generic geometric shape.']). - - :- public(color/1). - :- mode(color(?atom), zero_or_one). - :- info(color/1, [ - comment is 'Shape color.', - argnames is ['Color']]). - - :- public(position/2). - :- mode(position(?integer, ?integer), zero_or_one). - :- info(position/2, [ - comment is 'Shape position.', - argnames is ['X', 'Y']]). - - color(red). % default shape color - - position(0, 0). % default shape position - -:- end_object. - - -% "polygon" abstract class - -:- object(polygon, - instantiates(abstract_class), - specializes(shape)). - - :- info([ - author is 'Paulo Moura', - version is 1.1, - date is 2004/1/8, - comment is 'Generic polygon.']). - - :- public(nsides/1). - :- mode(nsides(?integer), zero_or_one). - :- info(nsides/1, [ - comment is 'Polygon number of sides.', - argnames is ['Number']]). - - :- public(area/1). - :- mode(area(-float), zero_or_one). - :- info(area/1, [ - comment is 'Polygon area.', - argnames is ['Area']]). - - :- public(perimeter/1). - :- mode(perimeter(?atom), zero_or_one). - :- info(perimeter/1, [ - comment is 'Polygon perimeter.', - argnames is ['Perimeter']]). - -:- end_object. - - -% "regular_polygon" abstract class - -:- object(regular_polygon, - instantiates(abstract_class), - specializes(polygon)). - - :- info([ - author is 'Paulo Moura', - version is 1.1, - date is 2004/1/8, - comment is 'Generic regular polygon.']). - - :- public(side/1). - :- mode(side(?atom), zero_or_one). - :- info(side/1, [ - comment is 'Regular polygon side length.', - argnames is ['Length']]). - - side(1). % default side length - - perimeter(Perimeter) :- - ::nsides(Number), - ::side(Side), - Perimeter is Number*Side. - -:- end_object. - - -% "square" instantiable class - -:- object(square, - instantiates(class), - specializes(regular_polygon)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2003/2/3, - comment is 'Geometric square.']). - - nsides(4). - - area(Area) :- - ::side(Side), - Area is Side*Side. - -:- end_object. - - -:- object(q1, - instantiates(square)). - - % inherits default values for position/2, color/1, and side/1 - -:- end_object. - - -:- object(q2, - instantiates(square)). - - position(2, 3). - - color(blue). - - side(3). - -:- end_object. diff --git a/Logtalk/examples/shapes/ch/loader.lgt b/Logtalk/examples/shapes/ch/loader.lgt deleted file mode 100644 index e699c7db4..000000000 --- a/Logtalk/examples/shapes/ch/loader.lgt +++ /dev/null @@ -1,5 +0,0 @@ - -:- initialization(( - logtalk_load(library(all_loader), [reload(skip)]), % allow for static binding - logtalk_load(roots(loader), [reload(skip)]), % allow for static binding - logtalk_load(ch))). diff --git a/Logtalk/examples/shapes/ph/NOTES.txt b/Logtalk/examples/shapes/ph/NOTES.txt deleted file mode 100644 index 1ed2ccb62..000000000 --- a/Logtalk/examples/shapes/ph/NOTES.txt +++ /dev/null @@ -1,10 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT -file. diff --git a/Logtalk/examples/shapes/ph/SCRIPT.txt b/Logtalk/examples/shapes/ph/SCRIPT.txt deleted file mode 100644 index d27c16e60..000000000 --- a/Logtalk/examples/shapes/ph/SCRIPT.txt +++ /dev/null @@ -1,44 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(shapes_ph(loader)). -... - - -% try some simple queries: - - -| ?- square::nsides(N). - -N = 4 -yes - - -| ?- square::area(A). - -A = 1 -yes - - -| ?- q1::(color(Color), side(Side), position(X, Y)). - -Color = red -Side = 1 -X = 0 -Y = 0 -yes - - -| ?- q2::(side(Side), area(Area), perimeter(Perimeter)). - -Side = 3 -Area = 9 -Perimeter = 12 -yes diff --git a/Logtalk/examples/shapes/ph/loader.lgt b/Logtalk/examples/shapes/ph/loader.lgt deleted file mode 100644 index d69e1580b..000000000 --- a/Logtalk/examples/shapes/ph/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(ph)). diff --git a/Logtalk/examples/shapes/ph/ph.lgt b/Logtalk/examples/shapes/ph/ph.lgt deleted file mode 100644 index 3f540a87e..000000000 --- a/Logtalk/examples/shapes/ph/ph.lgt +++ /dev/null @@ -1,117 +0,0 @@ - -:- object(shape). % an object with no hierarchy relations with other - % objects is always compiled as a prototype - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2003/2/3, - comment is 'Generic geometric shape.']). - - :- public(color/1). - :- mode(color(?atom), zero_or_one). - :- info(color/1, [ - comment is 'Shape color.', - argnames is ['Color']]). - - :- public(position/2). - :- mode(position(?integer, ?integer), zero_or_one). - :- info(position/2, [ - comment is 'Shape position.', - argnames is ['X', 'Y']]). - - color(red). % default shape color - - position(0, 0). % default shape position - -:- end_object. - - -:- object(polygon, - extends(shape)). - - :- info([ - author is 'Paulo Moura', - version is 1.1, - date is 2004/1/8, - comment is 'Generic polygon.']). - - :- public(nsides/1). - :- mode(nsides(?integer), zero_or_one). - :- info(nsides/1, [ - comment is 'Polygon number of sides.', - argnames is ['Number']]). - - :- public(area/1). - :- mode(area(-float), zero_or_one). - :- info(area/1, [ - comment is 'Polygon area.', - argnames is ['Area']]). - - :- public(perimeter/1). - :- mode(perimeter(?atom), zero_or_one). - :- info(perimeter/1, [ - comment is 'Polygon perimeter.', - argnames is ['Perimeter']]). - -:- end_object. - - -:- object(regular_polygon, - extends(polygon)). - - :- info([ - author is 'Paulo Moura', - version is 1.1, - date is 2004/1/8, - comment is 'Generic regular polygon.']). - - :- public(side/1). - :- mode(side(?atom), zero_or_one). - :- info(side/1, [ - comment is 'Regular polygon side length.', - argnames is ['Length']]). - - side(1). % default side length - - perimeter(Perimeter) :- - ::nsides(Number), - ::side(Side), - Perimeter is Number*Side. - -:- end_object. - - -:- object(square, - extends(regular_polygon)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2003/2/3, - comment is 'Geometric square.']). - - nsides(4). - - area(Area) :- - ::side(Side), - Area is Side*Side. - -:- end_object. - - -:- object(q1, - extends(square)). - -:- end_object. - - -:- object(q2, - extends(square)). - - position(2, 3). - - color(blue). - - side(3). - -:- end_object. diff --git a/Logtalk/examples/sicstus/NOTES.txt b/Logtalk/examples/sicstus/NOTES.txt deleted file mode 100644 index 8263acafa..000000000 --- a/Logtalk/examples/sicstus/NOTES.txt +++ /dev/null @@ -1,11 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -The examples in this folder are adopted from the SICStus Prolog manual. - -To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/sicstus/SCRIPT.txt b/Logtalk/examples/sicstus/SCRIPT.txt deleted file mode 100644 index 719eaa16b..000000000 --- a/Logtalk/examples/sicstus/SCRIPT.txt +++ /dev/null @@ -1,113 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and necessary library supporting files: - -| ?- logtalk_load(sicstus(loader)). -... - - -% try some simple queries: - - -| ?- sort(rational)::sort([1/8, 2/7, 6/5, 2/9, 1/3], Sorted). - -Sorted = [1/8, 2/9, 2/7, 1/3, 6/5] -yes - - -| ?- sort(colours)::sort([orange, indigo, red, yellow, violet, blue, green], Sorted). - -Sorted = [red, orange, yellow, green, blue, indigo, violet] -yes - - -% using the pseudo-object user implies using the Prolog built-in standard -% order operators: - -| ?- sort(user)::sort([3, 1, 4, 2, 9], Sorted). - -Sorted = [1, 2, 3, 4, 9] -yes - - -% some messages testing object parameter passing and using: - -| ?- red_circle(3)::color(Color). - -Color = red -yes - - -| ?- red_circle(3)::area(Area). - -Area = 28.274334 -yes - - -| ?- red_circle(3)::ancestors(As). - -As = [circle(3, red), ellipse(3, 3, red)] -yes - - -% show the execution context using a method (context/3) that is defined in the -% hierarchy root and specialized (using super calls) in each descendant: - -| ?- red_circle(3)::context. - -red_circle1 -self: red_circle(3) -this: red_circle(3) -sender: user - -circle2 -self: red_circle(3) -this: circle(3,red) -sender: user - -ellipse3 -self: red_circle(3) -this: ellipse(3,3,red) -sender: user - -yes - - -% send a conjunction of messages/goals to an object; just some useful syntax -% sugar: - -| ?- square(2)::(side(Side), width(Width), height(Height), area(Area)). - -Side = 2 -Width = 2 -Height = 2 -Area = 4 -yes - - -% find all messages accepted by an object: - -| ?- square(2)::current_predicate(Pred). - -Pred = side/1 ; -Pred = width/1 ; -Pred = height/1 ; -Pred = area/1 -yes - - -% find all data on a specific message accepted by an object: - -| ?- square(_)::predicate_property(side(_), Prop). - -Prop = public ; -Prop = static ; -Prop = declared_in(square(_133)) ; -Prop = defined_in(square(_164)) -yes diff --git a/Logtalk/examples/sicstus/loader.lgt b/Logtalk/examples/sicstus/loader.lgt deleted file mode 100644 index 8067edaf5..000000000 --- a/Logtalk/examples/sicstus/loader.lgt +++ /dev/null @@ -1,6 +0,0 @@ - -:- initialization(( - logtalk_load( - [library(hierarchies_loader), library(types_loader)], - [reload(skip)]), % allow for static binding - logtalk_load([ovals, polygons, sorting]))). diff --git a/Logtalk/examples/sicstus/ovals.lgt b/Logtalk/examples/sicstus/ovals.lgt deleted file mode 100644 index abe266cf9..000000000 --- a/Logtalk/examples/sicstus/ovals.lgt +++ /dev/null @@ -1,169 +0,0 @@ - -:- object(math_constants). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Implements predicates for retriving common mathematical constants.']). - - :- public(pi/1). - :- mode(pi(-float), one). - - :- public(e/1). - :- mode(e(-float), one). - - pi(Pi) :- - Pi is 4.0*atan(1.0). - - e(E) :- - E is exp(1.0). - -:- end_object. - - -:- object(ellipse(_RX, _RY, _Color), - imports(proto_hierarchy)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Parametric object for representing geometric ellipses.', - parnames is ['RX', 'RY', 'Color'], - source is 'Example adopted from the SICStus Objects documentation.']). - - :- uses(math_constants). - - :- public(color/1). - :- mode(color(?atom), zero_or_one). - :- info(color/1, [ - comment is 'Ellipse color.', - argnames is ['Color']]). - - :- public(rx/1). - :- mode(rx(?number), zero_or_one). - :- info(rx/1, [ - comment is 'Ellipse x axis.', - argnames is ['Rx']]). - - :- public(ry/1). - :- mode(ry(?number), zero_or_one). - :- info(ry/1, [ - comment is 'Ellipse y axis.', - argnames is ['Ry']]). - - :- public(area/1). - :- mode(area(-number), one). - :- info(area/1, [ - comment is 'Ellipse area.', - argnames is ['Area']]). - - :- public(context/0). - :- mode(context, one). - :- info(context/0, [ - comment is 'Shows execution context (self, this and sender values).']). - - color(Color) :- - parameter(3, Color). - - rx(Rx) :- - parameter(1, Rx). - - ry(Ry) :- - parameter(2, Ry). - - area(Area) :- - ::rx(Rx), - ::ry(Ry), - math_constants::pi(Pi), - Area is Rx*Ry*Pi. - - context :- - write(ellipse3), nl, - self(Self), write('self: '), writeq(Self), nl, - this(This), write('this: '), writeq(This), nl, - sender(Sender), write('sender: '), writeq(Sender), nl, nl. - -:- end_object. - - -:- object(circle(Radius, Color), - extends(ellipse(Radius, Radius, Color))). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Parametric object for representing geometric circles.', - parnames is ['Radius', 'Color'], - source is 'Example adopted from the SICStus Objects documentation.']). - - :- public(r/1). - :- mode(r(?number), zero_or_one). - :- info(r/1, [ - comment is 'Circle radius.', - argnames is ['Radius']]). - - r(Radius) :- - parameter(1, Radius). - - color(Color) :- - parameter(2, Color). - - rx(Radius) :- - ::r(Radius). - - ry(Radius) :- - ::r(Radius). - - context :- - write(circle2), nl, - self(Self), write('self: '), writeq(Self), nl, - this(This), write('this: '), writeq(This), nl, - sender(Sender), write('sender: '), writeq(Sender), nl, nl, - ^^context. - -:- end_object. - - -:- object(circle1(Color), - extends(circle(1, Color))). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Parametric object for representing geometric circles with radius = 1.', - parnames is ['Color'], - source is 'Example adopted from the SICStus Objects documentation.']). - - context :- - write(circle11), nl, - self(Self), write('self: '), writeq(Self), nl, - this(This), write('this: '), writeq(This), nl, - sender(Sender), write('sender: '), writeq(Sender), nl, - ^^context. - -:- end_object. - - -:- object(red_circle(Radius), - extends(circle(Radius, red))). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Parametric object for representing geometric red circles.', - parnames is ['Radius'], - source is 'Example adopted from the SICStus Objects documentation.']). - - context :- - write(red_circle1), nl, - self(Self), write('self: '), writeq(Self), nl, - this(This), write('this: '), writeq(This), nl, - sender(Sender), write('sender: '), writeq(Sender), nl, nl, - ^^context. - -:- end_object. diff --git a/Logtalk/examples/sicstus/polygons.lgt b/Logtalk/examples/sicstus/polygons.lgt deleted file mode 100644 index 10b8f9248..000000000 --- a/Logtalk/examples/sicstus/polygons.lgt +++ /dev/null @@ -1,68 +0,0 @@ - -:- object(rectangle(_Width, _Height)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Parametric object for representing geometric rectangles.', - parnames is ['Width', 'Height']]). - - :- public(width/1). - :- mode(width(?number), zero_or_one). - :- info(width/1, [ - comment is 'Rectangle width.', - argnames is ['Width']]). - - :- public(height/1). - :- mode(height(?number), zero_or_one). - :- info(height/1, [ - comment is 'Rectangle height.', - argnames is ['Height']]). - - :- public(area/1). - :- mode(area(-number), one). - :- info(area/1, [ - comment is 'Rectangle area.', - argnames is ['Area']]). - - width(Width) :- - parameter(1, Width). - - height(Height) :- - parameter(2, Height). - - area(Area) :- - ::width(Width), - ::height(Height), - Area is Width*Height. - -:- end_object. - - -:- object(square(Side), - extends(rectangle(Side, Side))). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Parametric object for representing geometric squares.', - parnames is ['Side']]). - - :- public(side/1). - :- mode(side(?number), zero_or_one). - :- info(side/1, [ - comment is 'Square side.', - argnames is ['Side']]). - - side(Side) :- - parameter(1, Side). - - width(Width) :- - parameter(1, Width). - - height(Height) :- - parameter(1, Height). - -:- end_object. diff --git a/Logtalk/examples/sicstus/sorting.lgt b/Logtalk/examples/sicstus/sorting.lgt deleted file mode 100644 index 9627d906f..000000000 --- a/Logtalk/examples/sicstus/sorting.lgt +++ /dev/null @@ -1,119 +0,0 @@ - -:- object(sort(_Type)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'List sorting parameterized by the type of the list elements.', - parnames is ['Type'], - source is 'Example adopted from the SICStus Objects documentation.']). - - :- uses(list). - :- calls(comparingp). - - :- public(sort/2). - :- mode(sort(+list, -list), one). - :- info(sort/2, [ - comment is 'Sorts a list in ascending order.', - argnames is ['List', 'Sorted']]). - - :- private(partition/4). - :- mode(partition(+list, +nonvar, -list, -list), one). - :- info(partition/4, [ - comment is 'List partition in two sub-lists using a pivot.', - argnames is ['List', 'Pivot', 'Lowers', 'Biggers']]). - - sort([], []). - sort([P| L], S) :- - partition(L, P, Small, Large), - sort(Small, S0), - sort(Large, S1), - list::append(S0, [P| S1], S). - - partition([], _, [], []). - partition([X| L1], P, Small, Large) :- - parameter(1, Type), - ( (Type::(X < P)) -> - Small = [X| Small1], Large = Large1 - ; Small = Small1, Large = [X| Large1] - ), - partition(L1, P, Small1, Large1). - -:- end_object. - - -:- object(rational, - implements(comparingp)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Implements comparison between rational numbers represented as Num/Den.']). - - N1/D1 < N2/D2 :- - {N1*D2 < N2*D1}. - - N1/D1 =< N2/D2 :- - {N1*D2 =< N2*D1}. - - N1/D1 > N2/D2 :- - {N1*D2 > N2*D1}. - - N1/D1 >= N2/D2 :- - {N1*D2 >= N2*D1}. - - N1/D1 =:= N2/D2 :- - {N1*D2 =:= N2*D1}. - - N1/D1 =\= N2/D2 :- - {N1*D2 =\= N2*D1}. - -:- end_object. - - -:- object(colours, - implements(comparingp)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 2000/4/22, - comment is 'Implements comparison between visible colors.']). - - Colour1 < Colour2 :- - order(Colour1, N1), - order(Colour2, N2), - {N1 < N2}. - - Colour1 =< Colour2 :- - order(Colour1, N1), - order(Colour2, N2), - {N1 =< N2}. - - Colour1 > Colour2 :- - order(Colour1, N1), - order(Colour2, N2), - {N1 > N2}. - - Colour1 >= Colour2 :- - order(Colour1, N1), - order(Colour2, N2), - {N1 >= N2}. - - Colour1 =:= Colour2 :- - {Colour1 == Colour2}. - - Colour1 =\= Colour2 :- - {Colour1 \== Colour2}. - - order(red, 1). - order(orange, 2). - order(yellow, 3). - order(green, 4). - order(blue, 5). - order(indigo, 6). - order(violet, 7). - -:- end_object. diff --git a/Logtalk/examples/symdiff/NOTES.txt b/Logtalk/examples/symdiff/NOTES.txt deleted file mode 100644 index 338e832a0..000000000 --- a/Logtalk/examples/symdiff/NOTES.txt +++ /dev/null @@ -1,24 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains an example of using parametric objects to implement -symbolic expression differentiation and simplification. - -Current limitations: - - - the expression that we intend to differentiate or simplify - must be a compound term. Accepted functors are *, +, -, **, and log. - - - use as a variable the atom x. - - - only integers can be used as constants. - -This example is still incomplete. For example, using sum distribution -property to simplify expressions is not yet implemented. diff --git a/Logtalk/examples/symdiff/SCRIPT.txt b/Logtalk/examples/symdiff/SCRIPT.txt deleted file mode 100644 index 45c396759..000000000 --- a/Logtalk/examples/symdiff/SCRIPT.txt +++ /dev/null @@ -1,41 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(symdiff(loader)). -... - - -% simplify the expression x^1 + x0 - x1 - -| ?- (x**1 + x*0 - x*1)::simplify(S). - -S = 0 - -yes - - -% differentiate and then simplify the expression 2x^3 + x^2 - 4x - -| ?- (2*x**3 + x**2 - 4*x)::diff(D), D::simplify(S). - -D = 2*(3*x**2*1)+2*x**1*1-4*1 -S = 2*(3*x**2)+2*x-4 - -yes - - -% differentiate and then simplify the expression ln(x^2 + 2x - 7) + 4x - -| ?- (log(x**2 + 2*x - 7) + 4*x)::diff(D), D::simplify(S). - -D = (2*x**1*1+2*1)*(x**2+2*x-7)** -1+4*1 -S = (2*x+2)*(x**2+2*x-7)** -1+4 - -yes diff --git a/Logtalk/examples/symdiff/loader.lgt b/Logtalk/examples/symdiff/loader.lgt deleted file mode 100644 index 520b0caf7..000000000 --- a/Logtalk/examples/symdiff/loader.lgt +++ /dev/null @@ -1,8 +0,0 @@ -/* -On Windows, the compilation of this example generates invalid file names for -the XML documenting files, wence the xmldocs(off) option used below. No problems -on MacOS X and no problems expect in other POSIX systems. -*/ - -:- initialization( - logtalk_load(symdiff, [xmldocs(off)])). diff --git a/Logtalk/examples/symdiff/symdiff.lgt b/Logtalk/examples/symdiff/symdiff.lgt deleted file mode 100644 index bc868e353..000000000 --- a/Logtalk/examples/symdiff/symdiff.lgt +++ /dev/null @@ -1,334 +0,0 @@ - -:- protocol(symdiffp). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 1999/12/29, - comment is 'Symbolic differentiation and simplification protocol.', - source is 'Example based on the Clocksin and Mellish Prolog book.']). - - :- public(diff/1). - :- mode(diff(-expression), one). - :- info(diff/1, [ - comment is 'Returns the symbolic differentiation of self.', - argnames is ['Expression']]). - - :- public(simplify/1). - :- mode(simplify(-expression), one). - :- info(simplify/1, [ - comment is 'Returns the symbolic simplification of self.', - argnames is ['Expression']]). - -:- end_protocol. - - - -:- object(x, - implements(symdiffp)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 1999/12/29, - comment is 'Symbolic differentiation and simplification of a variable.', - source is 'Example based on the Clocksin and Mellish Prolog book.']). - - diff(1). - - simplify(x). - -:- end_object. - - - -:- object(_ + _, - implements(symdiffp)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 1999/12/29, - parnames is ['Expression1', 'Expression2'], - comment is 'Symbolic differentiation and simplification of +/2 expressions.', - source is 'Example based on the Clocksin and Mellish Prolog book.']). - - diff(Diff) :- - this(X + Y), - once(diff(X, Y, Diff)). - - diff(I, J, 0) :- - integer(I), - integer(J). - - diff(X, J, DX) :- - integer(J), - X::diff(DX). - - diff(I, Y, DY) :- - integer(I), - Y::diff(DY). - - diff(X, Y, DX + DY) :- - X::diff(DX), - Y::diff(DY). - - - simplify(S) :- - this(X + Y), - once(simplify(X, Y, S)). - - - simplify(I, J, S) :- - integer(I), - integer(J), - S is I + J. - - simplify(X, 0, S) :- - X::simplify(S). - - simplify(0, Y, S) :- - Y::simplify(S). - - simplify(X, J, S + J) :- - integer(J), - X::simplify(S). - - simplify(I, Y, I + S) :- - integer(I), - Y::simplify(S). - - simplify(X, Y, S) :- - X::simplify(SX), - Y::simplify(SY), - (X + Y \= SX + SY -> - (SX + SY)::simplify(S) - ; - S = SX + SY). - -:- end_object. - - - -:- object(_ - _, - implements(symdiffp)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 1999/12/29, - parnames is ['Expression1', 'Expression2'], - comment is 'Symbolic differentiation and simplification of -/2 expressions.', - source is 'Example based on the Clocksin and Mellish Prolog book.']). - - diff(Diff) :- - this(X - Y), - once(diff(X, Y, Diff)). - - diff(I, J, 0) :- - integer(I), - integer(J). - - diff(X, J, DX) :- - integer(J), - X::diff(DX). - - diff(I, Y, DY) :- - integer(I), - Y::diff(DY). - - diff(X, Y, DX - DY) :- - X::diff(DX), - Y::diff(DY). - - - simplify(S) :- - this(X - Y), - once(simplify(X, Y, S)). - - - simplify(X, X, 0). - - simplify(I, J, S) :- - integer(I), - integer(J), - S is I - J. - - simplify(X, 0, S) :- - X::simplify(S). - - simplify(0, Y, S) :- - Y::simplify(S). - - simplify(X, J, S - J) :- - integer(J), - X::simplify(S). - - simplify(I, Y, I - S) :- - integer(I), - Y::simplify(S). - - simplify(X, Y, S) :- - X::simplify(SX), - Y::simplify(SY), - (X - Y \= SX - SY -> - (SX - SY)::simplify(S) - ; - S = SX - SY). - -:- end_object. - - - -:- object(_ * _, - implements(symdiffp)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 1999/12/29, - parnames is ['Expression1', 'Expression2'], - comment is 'Symbolic differentiation and simplification of */2 expressions.', - source is 'Example based on the Clocksin and Mellish Prolog book.']). - - diff(Diff) :- - this(X * Y), - once(diff(X, Y, Diff)). - - diff(I, J, 0) :- - integer(I), - integer(J). - - diff(0, _, 0). - - diff(_, 0, 0). - - diff(X, J, J * DX) :- - integer(J), - X::diff(DX). - - diff(I, Y, I * DY) :- - integer(I), - Y::diff(DY). - - diff(X, Y, X * DY + DX * Y) :- - X::diff(DX), - Y::diff(DY). - - - simplify(S) :- - this(X * Y), - once(simplify(X, Y, S)). - - - simplify(I, J, S) :- - integer(I), - integer(J), - S is I * J. - - simplify(0, _, 0). - - simplify(_, 0, 0). - - simplify(1, Y, SY) :- - Y::simplify(SY). - - simplify(X, 1, SX) :- - X::simplify(SX). - - simplify(I, Y, I * SY) :- - integer(I), - Y::simplify(SY). - - simplify(X, J, J * SX) :- - integer(J), - X::simplify(SX). - - simplify(X, Y, SX * SY) :- - X::simplify(SX), - Y::simplify(SY). - -:- end_object. - - - -:- object(_ ** _, - implements(symdiffp)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 1999/12/29, - parnames is ['Expression', 'Power'], - comment is 'Symbolic differentiation and simplification of **/2 expressions.', - source is 'Example based on the Clocksin and Mellish Prolog book.']). - - diff(Diff) :- - this(X ** Y), - once(diff(X, Y, Diff)). - - diff(X, Y, Y * X ** Y2 * DX) :- - integer(Y), - Y2 is Y - 1, - X::diff(DX). - - diff(X, Y, Y * X ** Y2 * DX) :- - Y2 = Y - 1, - X::diff(DX). - - - simplify(S) :- - this(X ** Y), - once(simplify(X, Y, S)). - - - simplify(_, 0, 1). - - simplify(X, 1, X). - - simplify(X, Y, S ** Y) :- - integer(Y), - X::simplify(S). - - simplify(X, Y, SX ** SY) :- - X::simplify(SX), - Y::simplify(SY). - -:- end_object. - - - -:- object(log(_), - implements(symdiffp)). - - :- info([ - author is 'Paulo Moura', - version is 1.0, - date is 1999/12/29, - parnames is ['Expression'], - comment is 'Symbolic differentiation and simplification of log/1 expressions.', - source is 'Example based on the Clocksin and Mellish Prolog book.']). - - diff(Diff) :- - this(log(X)), - once(diff(X, Diff)). - - diff(I, 0) :- - integer(I). - - diff(X, DX * X ** -1) :- - X::diff(DX). - - simplify(S) :- - this(log(X)), - once(simplify(X, S)). - - simplify(1, 0). - - simplify(I, Log) :- - integer(I), - Log is log(I). - - simplify(X, X). - -:- end_object. diff --git a/Logtalk/examples/tabling/NOTES.txt b/Logtalk/examples/tabling/NOTES.txt deleted file mode 100644 index cfb13e98f..000000000 --- a/Logtalk/examples/tabling/NOTES.txt +++ /dev/null @@ -1,13 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains an example of using tabled predicates within objects. -Currently supported compilers include B-Prolog, XSB, and YAP (when compiled -with tabling enabled). diff --git a/Logtalk/examples/tabling/SCRIPT.txt b/Logtalk/examples/tabling/SCRIPT.txt deleted file mode 100644 index 60523c60e..000000000 --- a/Logtalk/examples/tabling/SCRIPT.txt +++ /dev/null @@ -1,32 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(tabling(loader)). -... - - -% use tabling to cope with a left-recursive path finding predicate -% (the order of the solutions may depend on the tabling strategy): - -| ?- paths::path(1, Y). - -Y = 2 ? ; -Y = 4 ? ; -Y = 3 ? ; -Y = 5 ? -yes - - -% use tabling to avoid repeated calculation of Fibonacci numbers: - -| ?- fibonacci::fib(30, F). - -F = 1346269 -yes diff --git a/Logtalk/examples/tabling/loader.lgt b/Logtalk/examples/tabling/loader.lgt deleted file mode 100644 index f4df76457..000000000 --- a/Logtalk/examples/tabling/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(tabling)). diff --git a/Logtalk/examples/tabling/tabling.lgt b/Logtalk/examples/tabling/tabling.lgt deleted file mode 100644 index 0b6fde8ac..000000000 --- a/Logtalk/examples/tabling/tabling.lgt +++ /dev/null @@ -1,48 +0,0 @@ - -:- object(paths). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2007/05/14, - comment is 'Simple tabling example using graph paths.', - source is 'Direct conversion to Logtalk of a XSB tabling example.']). - - :- public(path/2). - :- table(path/2). - - path(X,Y) :- path(X,Z), edge(Z,Y). - path(X,Y) :- edge(X,Y). - - edge(1,2). - edge(2,2). - edge(2,4). - edge(2,3). - edge(3,5). - -:- end_object. - - -:- object(fibonacci). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2007/05/28, - comment is 'Simple tabling example using Fibonacci numbers.', - source is 'Direct conversion to Logtalk of a B-Prolog tabling example.']). - - :- public(fib/2). - :- table(fib/2). - - fib(0, 1). - fib(1, 1). - fib(N,F) :- - N > 1, - N1 is N - 1, - N2 is N - 2, - fib(N1, F1), - fib(N2, F2), - F is F1 + F2. - -:- end_object. diff --git a/Logtalk/examples/testing/NOTES.txt b/Logtalk/examples/testing/NOTES.txt deleted file mode 100644 index a18c2d371..000000000 --- a/Logtalk/examples/testing/NOTES.txt +++ /dev/null @@ -1,14 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This folder contains a preliminary framework for defining and running -unit tests in Logtalk. - -The unit tests framework is inspired on the works of Joachim Schimpf -(ECLiPSe library "test_util") and Jan Wielemaker (SWI-Prolog "plunit" -package). diff --git a/Logtalk/examples/testing/SCRIPT.txt b/Logtalk/examples/testing/SCRIPT.txt deleted file mode 100644 index 393e09a8f..000000000 --- a/Logtalk/examples/testing/SCRIPT.txt +++ /dev/null @@ -1,15 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(testing(loader)). -... - - -% take a look at the "results.txt" file in the example directory \ No newline at end of file diff --git a/Logtalk/examples/testing/loader.lgt b/Logtalk/examples/testing/loader.lgt deleted file mode 100644 index 093b3d154..000000000 --- a/Logtalk/examples/testing/loader.lgt +++ /dev/null @@ -1,4 +0,0 @@ - -:- initialization(( - logtalk_load(library(lgtunit), [reload(skip)]), % allow for static binding - logtalk_load(testing))). diff --git a/Logtalk/examples/testing/testing.lgt b/Logtalk/examples/testing/testing.lgt deleted file mode 100644 index 261f5cdcf..000000000 --- a/Logtalk/examples/testing/testing.lgt +++ /dev/null @@ -1,134 +0,0 @@ - -:- object(ctx_call_tests, - extends(lgtunit)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2007/04/17, - comment is 'Tests < 0, - eraser::pick_up, - chalk::pick_up, - self(Self), - write(Self), write(' is writing...'), nl, - random::random(1, 5, Random), % simulate a variable amount - thread_sleep(Random), % of time spending on writing - chalk::release, - eraser::release, - N2 is N - 1, - run(N2). - -:- end_category. - - -:- object(teacher, - imports(running)). - - -:- end_object. - - -:- object(student, - imports(running)). - - -:- end_object. diff --git a/Logtalk/examples/threads/blackboard/loader.lgt b/Logtalk/examples/threads/blackboard/loader.lgt deleted file mode 100644 index 50cd187cc..000000000 --- a/Logtalk/examples/threads/blackboard/loader.lgt +++ /dev/null @@ -1,4 +0,0 @@ - -:- initialization(( - logtalk_load(library(random_loader), [reload(skip)]), % allow for static binding - logtalk_load(blackboard))). diff --git a/Logtalk/examples/threads/buffer/NOTES.txt b/Logtalk/examples/threads/buffer/NOTES.txt deleted file mode 100644 index 70c82b160..000000000 --- a/Logtalk/examples/threads/buffer/NOTES.txt +++ /dev/null @@ -1,14 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains a simple multi-threading example illustrating how -to use the Logtalk built-in predicates threaded_wait/1 and threaded_notify/1 -for synchronizing threads writing to and reading from a buffer that can -only contain an item at the same time. diff --git a/Logtalk/examples/threads/buffer/SCRIPT.txt b/Logtalk/examples/threads/buffer/SCRIPT.txt deleted file mode 100644 index 2d8dbfd6e..000000000 --- a/Logtalk/examples/threads/buffer/SCRIPT.txt +++ /dev/null @@ -1,68 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(buffer(loader)). -... - - -% start the producer and the consumer, each one running in its own thread: - -| ?- threaded_ignore(producer(2)::run(25)), threaded_ignore(consumer(5)::run(25)). - - produced item 0 (1/7 items in the buffer) - consumed item 0 (0/7 items in the buffer) - produced item 1 (1/7 items in the buffer) - produced item 2 (2/7 items in the buffer) - produced item 3 (3/7 items in the buffer) - produced item 4 (4/7 items in the buffer) - consumed item 1 (3/7 items in the buffer) - produced item 5 (4/7 items in the buffer) - produced item 6 (5/7 items in the buffer) - produced item 7 (6/7 items in the buffer) - consumed item 2 (5/7 items in the buffer) - produced item 8 (6/7 items in the buffer) - consumed item 3 (5/7 items in the buffer) - produced item 9 (6/7 items in the buffer) - consumed item 4 (5/7 items in the buffer) - produced item 10 (6/7 items in the buffer) - consumed item 5 (5/7 items in the buffer) - produced item 11 (6/7 items in the buffer) - produced item 12 (7/7 items in the buffer) - consumed item 6 (6/7 items in the buffer) - produced item 13 (7/7 items in the buffer) - consumed item 7 (6/7 items in the buffer) - produced item 14 (7/7 items in the buffer) - consumed item 8 (6/7 items in the buffer) - produced item 15 (7/7 items in the buffer) - consumed item 9 (6/7 items in the buffer) - produced item 16 (7/7 items in the buffer) - consumed item 10 (6/7 items in the buffer) - produced item 17 (7/7 items in the buffer) - consumed item 11 (6/7 items in the buffer) - produced item 18 (7/7 items in the buffer) - consumed item 12 (6/7 items in the buffer) - produced item 19 (7/7 items in the buffer) - consumed item 13 (6/7 items in the buffer) - produced item 20 (7/7 items in the buffer) - consumed item 14 (6/7 items in the buffer) - produced item 21 (7/7 items in the buffer) - consumed item 15 (6/7 items in the buffer) - produced item 22 (7/7 items in the buffer) - consumed item 16 (6/7 items in the buffer) - produced item 23 (7/7 items in the buffer) - consumed item 17 (6/7 items in the buffer) - produced item 24 (7/7 items in the buffer) - consumed item 18 (6/7 items in the buffer) - consumed item 19 (5/7 items in the buffer) - consumed item 20 (4/7 items in the buffer) - consumed item 21 (3/7 items in the buffer) - consumed item 22 (2/7 items in the buffer) - consumed item 23 (1/7 items in the buffer) - consumed item 24 (0/7 items in the buffer) diff --git a/Logtalk/examples/threads/buffer/buffer.lgt b/Logtalk/examples/threads/buffer/buffer.lgt deleted file mode 100644 index 28572d506..000000000 --- a/Logtalk/examples/threads/buffer/buffer.lgt +++ /dev/null @@ -1,116 +0,0 @@ - -:- object(buffer(_MaxCapacity)). - - :- info([ - version is 2.1, - author is 'Paulo Moura', - date is 2007/9/16, - comment is 'Producer-consumer problem with a bounded buffer.']). - - :- threaded. - - :- public(put/1). - :- mode(put(?integer), one). - :- info(put/1, [ - comment is 'Put an item in the buffer.']). - - :- public(get/1). - :- mode(get(?integer), one). - :- info(get/1, [ - comment is 'Get an item from the buffer.']). - - :- private(item_/1). - :- dynamic(item_/1). - - :- private(size_/1). - :- dynamic(size_/1). - - size_(0). - - :- synchronized([put_item/1, get_item/1]). - - put_item(Item) :- - parameter(1, MaxCapacity), - assertz(item_(Item)), - retract(size_(N)), - N2 is N + 1, - assertz(size_(N2)), - write(' produced item '), write(Item), - write(' ('), write(N2), write('/'), write(MaxCapacity), write(' items in the buffer'), write(')'), nl. - - get_item(Item) :- - parameter(1, MaxCapacity), - retract(item_(Item)), - retract(size_(N)), - N2 is N - 1, - assertz(size_(N2)), - write(' consumed item '), write(Item), - write(' ('), write(N2), write('/'), write(MaxCapacity), write(' items in the buffer'), write(')'), nl. - - put(Item) :- - parameter(1, MaxCapacity), - size_(N), - ( N =:= MaxCapacity -> % if the maximum buffer capacity have been - threaded_wait(vacancy), % reached, wait until an item is consumed - put(Item) % be sure to consume all "vacancy" notifications before proceeding - ; put_item(Item), - ( N =:= 0 -> - threaded_notify(not_empty) - ; true - ) - ). - - get(Item) :- - parameter(1, MaxCapacity), - size_(N), - ( N =:= 0 -> % if the buffer is empty, wait - threaded_wait(not_empty), % until an item is produced - get(Item) % be sure to consume all "not_empty" notifications before proceeding - ; get_item(Item), - ( N =:= MaxCapacity -> - threaded_notify(vacancy) - ; true - ) - ). - -:- end_object. - - -:- object(producer(_MaxTime)). - - :- public(run/1). - - run(N) :- - run(0, N). - - run(N, N) :- !. - run(M, N) :- - M < N, - parameter(1, MaxTime), - random::random(1, MaxTime, Random), % simulate a variable amount of - thread_sleep(Random), % time to produce a new item - buffer(7)::put(M), - M2 is M + 1, - run(M2, N). - -:- end_object. - - -:- object(consumer(_MaxTime)). - - :- public(run/1). - - run(N) :- - run(0, N). - - run(N, N) :- !. - run(M, N) :- - M < N, - parameter(1, MaxTime), - random::random(1, MaxTime, Random), % simulate a variable amount of - thread_sleep(Random), % time to produce a new item - buffer(7)::get(_Item), - M2 is M + 1, - run(M2, N). - -:- end_object. diff --git a/Logtalk/examples/threads/buffer/loader.lgt b/Logtalk/examples/threads/buffer/loader.lgt deleted file mode 100644 index 78a3a0d45..000000000 --- a/Logtalk/examples/threads/buffer/loader.lgt +++ /dev/null @@ -1,4 +0,0 @@ - -:- initialization(( - logtalk_load(library(random_loader), [reload(skip)]), % allow for static binding - logtalk_load(buffer))). diff --git a/Logtalk/examples/threads/functions/NOTES.txt b/Logtalk/examples/threads/functions/NOTES.txt deleted file mode 100644 index 1b6af0e29..000000000 --- a/Logtalk/examples/threads/functions/NOTES.txt +++ /dev/null @@ -1,14 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains a simple multi-threading example illustrating how -to create threads for competing goals, which one performing the same -task using diferent methods. The first goal to complete leads to the -immediate termination of the threads running the remaining goals. diff --git a/Logtalk/examples/threads/functions/SCRIPT.txt b/Logtalk/examples/threads/functions/SCRIPT.txt deleted file mode 100644 index f8264db24..000000000 --- a/Logtalk/examples/threads/functions/SCRIPT.txt +++ /dev/null @@ -1,71 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the loading the example: - -| ?- logtalk_load(functions(loader)). -... - - -% find the roots of some functions using each one of provided methods: - -| ?- bisection::find_root(f1, 1.0, 2.3, 1.0e-15, Zero). - -Zero = 2.0 -yes - -| ?- newton::find_root(f1, 1.0, 2.3, 1.0e-15, Zero). - -Zero = 2.0 -yes -| ?- muller::find_root(f1, 1.0, 2.3, 1.0e-15, Zero). - -Zero = 2.0 -yes - -| ?- bisection::find_root(f2, 1.0, 1.3, 1.0e-15, Zero). - -Zero = 1.25809265664599 -yes - -| ?- newton::find_root(f2, 1.0, 1.3, 1.0e-15, Zero). - -Zero = 1.25809265664599 -yes - -| ?- muller::find_root(f2, 1.0, 1.3, 1.0e-15, Zero). - -Zero = 1.25809265664599 -yes - - -% find the roots of some functions running all methods at once using multi-threading: - -| ?- function_root::find_root(f1, 1.0, 2.3, 1.0e-15, Zero, Method). - -Zero = 2.0 -Method = bisection -yes - -| ?- function_root::find_root(f2, 1.0, 1.3, 1.0e-15, Zero, Method). - -Zero = 1.25809265664599 -Method = newton -yes - -| ?- function_root::find_root(f3, 0.0, 3.0, 1.0e-15, Zero, Method). - -Zero = 1.4142135623731 -Method = newton -yes - -| ?- function_root::find_root(f4, -1.0, 2.0, 1.0e-15, Zero, Method). - -Zero = -8.88178419700125e-16 -Method = bisection -yes diff --git a/Logtalk/examples/threads/functions/functions.lgt b/Logtalk/examples/threads/functions/functions.lgt deleted file mode 100644 index 0f02e88ad..000000000 --- a/Logtalk/examples/threads/functions/functions.lgt +++ /dev/null @@ -1,263 +0,0 @@ - -:- protocol(find_rootp). - - :- info([ - version is 1.1, - author is 'Paulo Moura and Paulo Nunes', - date is 2006/11/26, - comment is 'Default protocol for root find algorithms.']). - - :- public(find_root/5). - :- mode(find_root(+object_identifier, +float, +float, +float, -float), one). - :- info(find_root/5, [ - comment is 'Find the root of a function in the interval [A, B] given a maximum aproximation error.', - argnames is ['Function', 'A', 'B', 'Error', 'Zero']]). - -:- end_protocol. - - - -:- protocol(functionp). - - :- info([ - version is 1.1, - author is 'Paulo Moura and Paulo Nunes', - date is 2006/11/26, - comment is 'Default protocol for real functions of a single real variable.']). - - :- public(eval/2). - :- mode(eval(+float, -float), one). - :- info(eval/2, [ - comment is 'Calculates the function value.', - argnames is ['X', 'Fx']]). - - :- public(evald/2). - :- mode(evald(+float, -float), one). - :- info(evald/2, [ - comment is 'Calculates the value of the function derivative.', - argnames is ['X', 'DFx']]). - -:- end_protocol. - - - -:- object(f1, - implements(functionp)). - - % x^2 - 4 - % 2.0 - - eval(X, Y) :- - Y is X * X - 4. - - evald(X, Y) :- - Y is 2 * X. - -:- end_object. - - - -:- object(f2, - implements(functionp)). - - % x^7 + 9x^5 - 13x - 17 - % 1.29999999999945448 - - eval(X, Y) :- - Y is X**7 + 9*X**5 - 13*X - 17. - - evald(X, Y) :- - Y is 7*X**6 + 45*X**4 - 13. - -:- end_object. - - - -:- object(f3, - implements(functionp)). - - % (x - sqrt(2))^7 - % 1.41421356237309537 - - eval(X, Y) :- - Y is (X - sqrt(2.0))**8. - - evald(X, Y) :- - Y is 8*(X - sqrt(2.0))**7. - -:- end_object. - - - -:- object(f4, - implements(functionp)). - - % x + x^2*sin(2.0/x) - % 0.0 - - eval(X, Y) :- - Y is X + (X**2)*sin(2.0/X). - - evald(X, Y) :- - Y is 1 + 2*X*sin(2.0/X) - 2*cos(2.0/X). - -:- end_object. - - - -:- object(bisection, - implements(find_rootp)). - - :- info([ - version is 1.2, - author is 'Paulo Moura and Paulo Nunes', - date is 2007/7/7, - comment is 'Bisection algorithm.']). - - find_root(Function, A, B, Error, Zero) :- - Function::eval(A, Fa), - Function::eval(B, Fb), - ( Fa > 0.0, Fb < 0.0 -> - true - ; Fa < 0.0, Fb > 0.0 - ), - X0 is (A + B) / 2.0, - Function::eval(X0, F0), - bisection(Function, A, B, X0, F0, Error, Zero). - - bisection(_, _, _, Xn, Fn, Error, Xn) :- - abs(Fn) < Error, - !. - bisection(Function, An, Bn, _, _, Error, Zero) :- - Xn1 is (An + Bn) / 2.0, - Function::eval(Xn1, Fn1), - Function::eval(An, FAn), - ( Fn1*FAn < 0.0 -> - An1 is An, - Bn1 is Xn1 - ; An1 is Xn1, - Bn1 is Bn - ), - bisection(Function, An1, Bn1, Xn1, Fn1, Error, Zero). - -:- end_object. - - - -:- object(newton, - implements(find_rootp)). - - :- info([ - version is 1.2, - author is 'Paul Crocker... No More Coffee', - date is 2007/07/06, - comment is 'Newton algorithm.']). - - find_root(Function, Xa, Xb, Deviation, Zero) :- - Ac is (Xb - Xa) / 2, - newton(Function, Xa, Ac, Deviation, Zero). - - newton(_, Zero, Ac, Deviation, Zero) :- - abs(Ac) < Deviation, - !. - newton(Function, X0, Ac, Deviation, Zero):- - Xn1 is X0 + Ac, - Function::eval(Xn1, Fx), - Function::evald(Xn1, DFx), - Ac2 is -(Fx/DFx), - newton(Function, Xn1, Ac2, Deviation, Zero). - -:- end_object. - - -:- object(muller, - implements(find_rootp)). - - :- info([ - version is 1.2, - author is 'Paulo Moura and Paulo Nunes', - date is 2006/11/26, - comment is 'Muller algorithm.']). - - find_root(Function, Xa, Xb, Deviation, Zero) :- - Xc is (Xa + Xb) / 2.0, - muller(Function, Xa, Xc, Xb, Deviation, Zero). - - muller(Function, Xa, Xb, Xc, Deviation, Zero) :- - Function::eval(Xa, Ya), - Function::eval(Xb, Yb), - Function::eval(Xc, Yc), - H1 is Xb - Xa, - DDba is (Yb - Ya) / H1, - Ac is Deviation + 1.0, - muller(Function, Xa, Xb, Xc, Deviation, Ya, Yb, Yc, Ac, H1, DDba, Zero). - - muller(_, _, _, Xc, Deviation, _, _, _, Ac, _, _, Xc) :- - abs(Ac) < Deviation, - !. - muller(Function, Xa, Xb, Xc, Deviation, _, Yb, Yc, _, _, DDba, Zero) :- - H2n is Xc - Xb, - DDcbn is (Yc - Yb) / H2n, - Cn is (DDcbn - DDba) / (Xc - Xa), - Bn is DDcbn + H2n * Cn, - Rn is Bn * Bn - 4.0 * Yc * Cn, - ( Rn < 0.0 -> - fail - ; V is sqrt(Rn) - ), - ( Bn > 0.0 -> - Dn is Bn + V - ; Dn is Bn - V - ), - Acn is -(2 * Yc / Dn), - Xan is Xb, - Xbn is Xc, - Xcn is Xc + Acn, - Yan is Yb, - Ybn is Yc, - Function::eval(Xcn, Ycn), - H1n is H2n, - DDban is DDcbn, - muller(Function, Xan, Xbn, Xcn, Deviation, Yan, Ybn, Ycn, Acn, H1n, DDban, Zero). - -:- end_object. - - - -:- object(function_root, - implements(find_rootp)). - - :- info([ - version is 2.0, - author is 'Paulo Moura and Paulo Nunes', - date is 2007/07/05, - comment is 'Multi-threading interface to root finding algorithms.']). - - :- threaded. - - :- public(find_root/6). - :- mode(find_root(+object_identifier, +float, +float, +float, -float, -object_identifier), one). - :- info(find_root/6, [ - comment is 'Finds the root of a function in the interval [A, B] given a maximum aproximation error. Returns the method used.', - argnames is ['Function', 'A', 'B', 'Error', 'Zero', 'Method']]). - - find_root(Function, A, B, Error, Zero, Algorithm) :- - threaded(( - (bisection::find_root(Function, A, B, Error, Zero), Algorithm = bisection) - ; (newton::find_root(Function, A, B, Error, Zero), Algorithm = newton) - ; (muller::find_root(Function, A, B, Error, Zero), Algorithm = muller) - )). - -% an alternative, possibly better definition would be to make the methods simply fail in case of error: -% -% find_root(Function, A, B, Error, Zero, Algorithm) :- -% threaded(( -% (catch(bisection::find_root(Function, A, B, Error, Zero), _, fail), Algorithm = bisection) -% ; (catch(newton::find_root(Function, A, B, Error, Zero), _, fail), Algorithm = newton) -% ; (catch(muller::find_root(Function, A, B, Error, Zero), _, fail), Algorithm = muller) -% )). - - find_root(Function, A, B, Error, Zero) :- - find_root(Function, A, B, Error, Zero, _). - -:- end_object. diff --git a/Logtalk/examples/threads/functions/loader.lgt b/Logtalk/examples/threads/functions/loader.lgt deleted file mode 100644 index e4cb00472..000000000 --- a/Logtalk/examples/threads/functions/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(functions)). diff --git a/Logtalk/examples/threads/nondet/NOTES.txt b/Logtalk/examples/threads/nondet/NOTES.txt deleted file mode 100644 index 61c9798d6..000000000 --- a/Logtalk/examples/threads/nondet/NOTES.txt +++ /dev/null @@ -1,12 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder illustrates non-deterministic multi-threading calls and the -use of tags to distinguish between multi-threading calls. diff --git a/Logtalk/examples/threads/nondet/SCRIPT.txt b/Logtalk/examples/threads/nondet/SCRIPT.txt deleted file mode 100644 index 09d3908da..000000000 --- a/Logtalk/examples/threads/nondet/SCRIPT.txt +++ /dev/null @@ -1,104 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the loading the example: - -| ?- logtalk_load(nondet(loader)). -... - - -% make a threaded call with a non-deterministic goal: - -| ?- threaded_call(lists::member(X, [1,2,3])). - -X = _G189 -yes - -% retrieve through backtracking all solutions for the non-deterministic goal: - -| ?- threaded_exit(lists::member(X, [1,2,3])). - -X = 1 ; -X = 2 ; -X = 3 ; -no - - -% make a threaded call by commiting to the first solution found: - -| ?- threaded_once(lists::member(X, [1,2,3])). - -X = _G189 -yes - -% retrieve through backtracking the goal solution: - -| ?- threaded_exit(lists::member(X, [1,2,3])). - -X = 1 ; -no - - -% when two or more variant calls are made... - -| ?- threaded_call(lists::member(X, [1,2,3])), threaded_call(lists::member(Y, [1,2,3])). - -X = _G189 Y =_G190 -yes - -% ...the first threaded_exit/1 call will pick one of them: - -| ?- threaded_exit(lists::member(X, [1,2,3])). - -X = 1 ; -X = 2 ; -X = 3 ; -no - -% ...and a second threaded_exit/1 call will pick the remaining one: - -| ?- threaded_exit(lists::member(X, [1,2,3])). - -X = 1 ; -X = 2 ; -X = 3 ; -no - - -% tags may be used to distinguish between threaded calls if needed: - -| ?- threaded_call(lists::member(X, [1,2,3]), Tag). - -Tag = 1 -yes - -| ?- threaded_call(lists::member(X, [1,2,3]), Tag). - -Tag = 2 -yes - -| ?- threaded_exit(lists::member(X, [1,2,3]), 2). - -X = 1 ; -X = 2 ; -X = 3 ; -no - - -% use a subsumed goal instead of a variant of the original goal: - -| ?- threaded_call(lists::member(X, [1,2,3,2])). - -X = _G189 -yes - -| ?- threaded_exit(lists::member(2, [1,2,3,2])). - -More ; -More ; -no diff --git a/Logtalk/examples/threads/nondet/loader.lgt b/Logtalk/examples/threads/nondet/loader.lgt deleted file mode 100644 index f3e51a6a6..000000000 --- a/Logtalk/examples/threads/nondet/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(nondet)). diff --git a/Logtalk/examples/threads/nondet/nondet.lgt b/Logtalk/examples/threads/nondet/nondet.lgt deleted file mode 100644 index 820befef7..000000000 --- a/Logtalk/examples/threads/nondet/nondet.lgt +++ /dev/null @@ -1,10 +0,0 @@ - -:- object(lists). - - :- public(member/2). - - member(H, [H| _]). - member(H, [_| T]) :- - member(H, T). - -:- end_object. diff --git a/Logtalk/examples/threads/philosophers/NOTES.txt b/Logtalk/examples/threads/philosophers/NOTES.txt deleted file mode 100644 index a08d789bd..000000000 --- a/Logtalk/examples/threads/philosophers/NOTES.txt +++ /dev/null @@ -1,22 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains a Logtalk implementation of the classical "dining -philosophers" multi-threading problem. - -For more information, consult e.g. the following URL: - - http://en.wikipedia.org/wiki/Dining_philosophers_problem - -Two different implementations are provided, both using the same solution for -avoiding deadlock (which is having one philosopher picking its chopsticks -in a different order from the other philosophers; see the URL above for -details): one implementations uses a category and five philosopher objects -while the second implementation uses a parametric object. diff --git a/Logtalk/examples/threads/philosophers/SCRIPT.txt b/Logtalk/examples/threads/philosophers/SCRIPT.txt deleted file mode 100644 index bbda13b7b..000000000 --- a/Logtalk/examples/threads/philosophers/SCRIPT.txt +++ /dev/null @@ -1,112 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(philosophers(loader)). -... - - -% five meals for each philosopher, each one spending a maximum of five seconds of continuous thinking or eating: - -| ?- threaded_ignore(p1::run(5, 5)), threaded_ignore(p2::run(5, 5)), threaded_ignore(p3::run(5, 5)), threaded_ignore(p4::run(5, 5)), threaded_ignore(p5::run(5, 5)). - -Yes -Philosopher p3 thinking for 1 seconds. -Philosopher p1 thinking for 2 seconds. -Philosopher p2 thinking for 3 seconds. -Philosopher p4 thinking for 4 seconds. -Philosopher p5 thinking for 3 seconds. -Philosopher p3 eating for 2 seconds with chopsticks cs3 and cs2. -Philosopher p1 eating for 3 seconds with chopsticks cs5 and cs1. -Philosopher p2 thinking for 3 seconds. -Philosopher p3 thinking for 2 seconds. -Philosopher p5 thinking for 1 seconds. -Philosopher p4 eating for 1 seconds with chopsticks cs4 and cs3. -Philosopher p5 thinking for 1 seconds. -Philosopher p1 thinking for 3 seconds. -Philosopher p4 thinking for 1 seconds. -Philosopher p3 eating for 2 seconds with chopsticks cs3 and cs2. -Philosopher p5 eating for 2 seconds with chopsticks cs5 and cs4. -Philosopher p2 thinking for 3 seconds. -Philosopher p4 thinking for 2 seconds. -Philosopher p3 thinking for 2 seconds. -Philosopher p5 thinking for 1 seconds. -Philosopher p1 eating for 3 seconds with chopsticks cs5 and cs1. -Philosopher p4 eating for 4 seconds with chopsticks cs4 and cs3. -Philosopher p5 thinking for 1 seconds. -Philosopher p2 thinking for 1 seconds. -Philosopher p3 thinking for 4 seconds. -Philosopher p5 thinking for 2 seconds. -Philosopher p2 thinking for 4 seconds. -Philosopher p1 thinking for 1 seconds. -Philosopher p5 thinking for 1 seconds. -Philosopher p4 thinking for 4 seconds. -Philosopher p1 eating for 1 seconds with chopsticks cs5 and cs1. -Philosopher p5 thinking for 3 seconds. -Philosopher p3 eating for 2 seconds with chopsticks cs3 and cs2. -Philosopher p1 thinking for 3 seconds. -Philosopher p2 thinking for 4 seconds. -Philosopher p3 thinking for 3 seconds. -Philosopher p5 eating for 4 seconds with chopsticks cs5 and cs4. -Philosopher p4 thinking for 3 seconds. -Philosopher p1 thinking for 4 seconds. -Philosopher p2 eating for 1 seconds with chopsticks cs1 and cs2. -Philosopher p3 thinking for 3 seconds. -Philosopher p4 thinking for 3 seconds. -Philosopher p2 thinking for 1 seconds. -Philosopher p5 thinking for 2 seconds. -Philosopher p2 eating for 3 seconds with chopsticks cs1 and cs2. -Philosopher p1 thinking for 4 seconds. -Philosopher p3 thinking for 3 seconds. -Philosopher p5 eating for 2 seconds with chopsticks cs5 and cs4. -Philosopher p4 thinking for 1 seconds. -Philosopher p4 thinking for 4 seconds. -Philosopher p2 thinking for 1 seconds. -Philosopher p5 thinking for 4 seconds. -Philosopher p1 eating for 4 seconds with chopsticks cs5 and cs1. -Philosopher p2 thinking for 2 seconds. -Philosopher p3 eating for 2 seconds with chopsticks cs3 and cs2. -Philosopher p2 thinking for 3 seconds. -Philosopher p3 thinking for 1 seconds. -Philosopher p4 eating for 1 seconds with chopsticks cs4 and cs3. -Philosopher p5 thinking for 1 seconds. -Philosopher p3 thinking for 4 seconds. -Philosopher p4 thinking for 4 seconds. -Philosopher p1 thinking for 2 seconds. -Philosopher p5 eating for 2 seconds with chopsticks cs5 and cs4. -Philosopher p2 eating for 2 seconds with chopsticks cs1 and cs2. -Philosopher p1 thinking for 3 seconds. -Philosopher p5 thinking for 4 seconds. -Philosopher p2 thinking for 2 seconds. -Philosopher p3 eating for 4 seconds with chopsticks cs3 and cs2. -Philosopher p4 thinking for 2 seconds. -Philosopher p1 eating for 3 seconds with chopsticks cs5 and cs1. -Philosopher p2 thinking for 1 seconds. -Philosopher p4 thinking for 3 seconds. -Philosopher p2 thinking for 1 seconds. -Philosopher p5 thinking for 3 seconds. -p3 terminated. -Philosopher p2 thinking for 3 seconds. -p1 terminated. -Philosopher p4 eating for 3 seconds with chopsticks cs4 and cs3. -Philosopher p5 thinking for 4 seconds. -Philosopher p2 eating for 4 seconds with chopsticks cs1 and cs2. -Philosopher p4 thinking for 4 seconds. -Philosopher p5 eating for 1 seconds with chopsticks cs5 and cs4. -Philosopher p2 thinking for 1 seconds. -p5 terminated. -Philosopher p2 eating for 4 seconds with chopsticks cs1 and cs2. -Philosopher p4 eating for 3 seconds with chopsticks cs4 and cs3. -p4 terminated. -p2 terminated. - - -% same problem as above but using a parametric object for representing the philosophers: - -| ?- threaded_ignore(philosopher(p1,cs1,cs2)::run(5, 5)), threaded_ignore(philosopher(p2,cs2,cs3)::run(5, 5)), threaded_ignore(philosopher(p3,cs3,cs4)::run(5, 5)), threaded_ignore(philosopher(p4,cs4,cs5)::run(5, 5)), threaded_ignore(philosopher(p5,cs1,cs5)::run(5, 5)). diff --git a/Logtalk/examples/threads/philosophers/loader.lgt b/Logtalk/examples/threads/philosophers/loader.lgt deleted file mode 100644 index 9672e20be..000000000 --- a/Logtalk/examples/threads/philosophers/loader.lgt +++ /dev/null @@ -1,4 +0,0 @@ - -:- initialization(( - logtalk_load(library(random_loader), [reload(skip)]), % allow for static binding - logtalk_load(philosophers))). diff --git a/Logtalk/examples/threads/philosophers/philosophers.lgt b/Logtalk/examples/threads/philosophers/philosophers.lgt deleted file mode 100644 index f963bfe7c..000000000 --- a/Logtalk/examples/threads/philosophers/philosophers.lgt +++ /dev/null @@ -1,277 +0,0 @@ - -:- category(chopstick). - - :- info([ - version is 2.0, - author is 'Paulo Moura', - date is 2007/3/19, - comment is 'Dining philosophers problem: chopstick representation.']). - - :- public(pick_up/0). - :- mode(pick_up, zero_or_one). - :- info(pick_up/0, [ - comment is 'A Philosopher picks up the chopstick.']). - - :- public(put_down/0). - :- mode(put_down, zero_or_one). - :- info(put_down/0, [ - comment is 'A Philosopher puts down the chopstick.']). - - % chopstick actions (picking up and putting down) are synchronized using a notification - % such that a chopstick can only be handled by a single philosopher at a time: - - pick_up :- - threaded_wait(available). - - put_down :- - threaded_notify(available). - -:- end_category. - - -:- object(cs1, - imports(chopstick)). - - :- threaded. - :- initialization(threaded_notify(available)). - -:- end_object. - - -:- object(cs2, - imports(chopstick)). - - :- threaded. - :- initialization(threaded_notify(available)). - -:- end_object. - - -:- object(cs3, - imports(chopstick)). - - :- threaded. - :- initialization(threaded_notify(available)). - -:- end_object. - - -:- object(cs4, - imports(chopstick)). - - :- threaded. - :- initialization(threaded_notify(available)). - -:- end_object. - - -:- object(cs5, - imports(chopstick)). - - :- threaded. - :- initialization(threaded_notify(available)). - -:- end_object. - - -:- category(philosopher). - - :- info([ - version is 2.0, - author is 'Paulo Moura', - date is 2007/1/3, - comment is 'Dining philosophers problem: philosopher representation.']). - - :- public(left_chopstick/1). - :- mode(left_chopstick(?object_identifier), zero_or_one). - :- info(left_chopstick/1, [ - comment is 'Chopstick at the left of a philosopher.', - argnames is ['Chopstick']]). - - :- public(right_chopstick/1). - :- mode(right_chopstick(?object_identifier), zero_or_one). - :- info(right_chopstick/1, [ - comment is 'Chopstick at the right of a philosopher.', - argnames is ['Chopstick']]). - - :- public(run/2). - :- mode(run(+integer, +integer), one). - :- info(run/2, [ - comment is 'Runs Count number of thinking/eating cycles, with each activity taking MaxTime (in seconds).', - argnames is ['Count', 'MaxTime']]). - - :- private(message/1). - :- synchronized(message/1). - :- mode(message(+list), one). - :- info(message/1, [ - comment is 'Writes all the terms on a list as an atomic operation.', - argnames is ['Atoms']]). - - :- uses(random, [random/3]). - - run(0, _) :- - this(Philosopher), - message([Philosopher, ' terminated.']). - - run(Count, MaxTime) :- - Count > 0, - think(MaxTime), - eat(MaxTime), - Count2 is Count - 1, - run(Count2, MaxTime). - - think(MaxTime):- - this(Philosopher), - random(1, MaxTime, ThinkTime), - message(['Philosopher ', Philosopher, ' thinking for ', ThinkTime, ' seconds.']), - thread_sleep(ThinkTime). - - eat(MaxTime):- - this(Philosopher), - random(1, MaxTime, EatTime), - ::left_chopstick(LeftStick), - ::right_chopstick(RightStick), - LeftStick::pick_up, - RightStick::pick_up, - message(['Philosopher ', Philosopher, ' eating for ', EatTime, ' seconds with chopsticks ', LeftStick, ' and ', RightStick, '.']), - thread_sleep(EatTime), - ::LeftStick::put_down, - ::RightStick::put_down. - - % writing a message needs to be synchronized as it's accomplished - % using a combination of individual write/1 and nl/0 calls: - message([]) :- - nl, - flush_output. - message([Atom| Atoms]) :- - write(Atom), - message(Atoms). - -:- end_category. - - -:- object(p1, - imports(philosopher)). - - left_chopstick(cs1). - right_chopstick(cs2). - -:- end_object. - - -:- object(p2, - imports(philosopher)). - - left_chopstick(cs2). - right_chopstick(cs3). - -:- end_object. - - -:- object(p3, - imports(philosopher)). - - left_chopstick(cs3). - right_chopstick(cs4). - -:- end_object. - - -:- object(p4, - imports(philosopher)). - - left_chopstick(cs4). - right_chopstick(cs5). - -:- end_object. - - -:- object(p5, - imports(philosopher)). - - left_chopstick(cs1). % change order so that the chopsticks are picked - right_chopstick(cs5). % in different order from the other philosophers - -:- end_object. - - -:- object(philosopher(_Philosopher, _LeftChopstick, _RightShopstick)). - - :- info([ - version is 2.0, - author is 'Paulo Moura', - date is 2007/1/3, - comment is 'Dining philosophers problem: philosopher representation.']). - - :- public(left_chopstick/1). - :- mode(left_chopstick(?object_identifier), zero_or_one). - :- info(left_chopstick/1, [ - comment is 'Chopstick at the left of a philosopher.', - argnames is ['Chopstick']]). - - :- public(right_chopstick/1). - :- mode(right_chopstick(?object_identifier), zero_or_one). - :- info(right_chopstick/1, [ - comment is 'Chopstick at the right of a philosopher.', - argnames is ['Chopstick']]). - - :- public(run/2). - :- mode(run(+integer, +integer), one). - :- info(run/2, [ - comment is 'Runs Count number of thinking/eating cycles, with each activity taking MaxTime (in seconds).', - argnames is ['Count', 'MaxTime']]). - - :- private(message/1). - :- synchronized(message/1). - :- mode(message(+list), one). - :- info(message/1, [ - comment is 'Writes all the terms on a list as an atomic operation.', - argnames is ['Atoms']]). - - :- uses(random, [random/3]). - - left_chopstick(LeftStick) :- - parameter(2, LeftStick). - - rigth_chopstick(RightStick) :- - parameter(3, RightStick). - - run(0, _) :- - parameter(1, Philosopher), - message([Philosopher, ' terminated.']). - - run(Count, MaxTime) :- - Count > 0, - think(MaxTime), - eat(MaxTime), - Count2 is Count - 1, - run(Count2, MaxTime). - - think(MaxTime):- - random(1, MaxTime, ThinkTime), - parameter(1, Philosopher), - message(['Philosopher ', Philosopher, ' thinking for ', ThinkTime, ' seconds.']), - thread_sleep(ThinkTime). - - eat(MaxTime):- - random(1, MaxTime, EatTime), - parameter(2, LeftStick), - parameter(3, RightStick), - LeftStick::pick_up, - RightStick::pick_up, - parameter(1, Philosopher), - message(['Philosopher ', Philosopher, ' eating for ', EatTime, ' seconds with chopsticks ', LeftStick, ' and ', RightStick, '.']), - thread_sleep(EatTime), - ::LeftStick::put_down, - ::RightStick::put_down. - - % writing a message needs to be synchronized as it's accomplished - % using a combination of individual write/1 and nl/0 calls: - message([]) :- - nl, - flush_output. - message([Atom| Atoms]) :- - write(Atom), - message(Atoms). - -:- end_object. diff --git a/Logtalk/examples/threads/primes/NOTES.txt b/Logtalk/examples/threads/primes/NOTES.txt deleted file mode 100644 index 5ee316c4e..000000000 --- a/Logtalk/examples/threads/primes/NOTES.txt +++ /dev/null @@ -1,23 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains a simple example of calculating prime numbers in a -given interval using multiple threads. Try to run the example in single -and multi-processor (or multi-core) computers and compare the results. -Most Prolog compilers allows you to measure the time taken for proving -a goal using proprietary predicates. - -Note that this example is only meant to illustrate how to use Logtalk -multi-threading predicates, not to taken as the efficient solution for -finding primes numbers on a given interval (with or without threads). - -You probably want to play with the list size in order to find out when the -list is big enough to make the use of multi-threading worth performance-wise -(i.e. to compensate the overhead of thread creation and management). diff --git a/Logtalk/examples/threads/primes/SCRIPT.txt b/Logtalk/examples/threads/primes/SCRIPT.txt deleted file mode 100644 index c08547faa..000000000 --- a/Logtalk/examples/threads/primes/SCRIPT.txt +++ /dev/null @@ -1,49 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the loading the example: - -| ?- logtalk_load(primes(loader)). -... - - -% NOTE: the example queries below use a SWI-Prolog proprietary predicate -% time/1 in order to get accurate goal times. For other Prolog compilers, -% replace the time/1 call by any appropriate timing calls (e.g. cputime/0). - - -% calculate the prime numbers in a given interval using a single thread: - -?- time(primes(1)::primes(1, 500000, Primes)). -% 67,657,287 inferences, 11.97 CPU in 12.27 seconds (98% CPU, 5652238 Lips) - -Primes = [2, 3, 5, 7, 11, 13, 17, 19, 23|...] - -Yes - - -% calculate the prime numbers in a given interval by splitting the interval -% in two sub-intervals and using a thread per sub-interval: - -?- time(primes(2)::primes(1, 500000, Primes)). -% 77 inferences, 11.71 CPU in 7.50 seconds (156% CPU, 7 Lips) - -Primes = [2, 3, 5, 7, 11, 13, 17, 19, 23|...] - -Yes - - -% calculate the prime numbers in a given interval by splitting the interval -% in four sub-intervals and using a thread per sub-interval: - -?- time(primes(4)::primes(1, 500000, Primes)). -% 129 inferences, 11.57 CPU in 3.99 seconds (290% CPU, 11 Lips) - -Primes = [2, 3, 5, 7, 11, 13, 17, 19, 23|...] - -Yes diff --git a/Logtalk/examples/threads/primes/loader.lgt b/Logtalk/examples/threads/primes/loader.lgt deleted file mode 100644 index cf78b1993..000000000 --- a/Logtalk/examples/threads/primes/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(primes)). diff --git a/Logtalk/examples/threads/primes/primes.lgt b/Logtalk/examples/threads/primes/primes.lgt deleted file mode 100644 index 24f4cc4cb..000000000 --- a/Logtalk/examples/threads/primes/primes.lgt +++ /dev/null @@ -1,82 +0,0 @@ - -:- object(primes(_Threads)). - - :- info([ - version is 1.2, - author is 'Paulo Moura', - date is 2007/3/24, - comment is 'Simple example for comparing single and multi-threading calculation of prime numbers.', - parameters is ['Threads'- 'Number of threads to use. Valid values are 1, 2, and 4.']]). - - :- threaded. - - :- public(primes/3). - :- mode(primes(+integer, +integer, -list), one). - :- info(primes/3, [ - comment is 'Returns a list of all prime numbers in the given interval.', - argnames is ['Inf', 'Sup', 'Primes']]). - - - primes(N, M, Primes) :- - parameter(1, Threads), - primes(Threads, N, M, Primes). - - primes(1, N, M, Primes) :- - st_primes(N, M, Primes). - primes(2, N, M, Primes) :- - mt_primes_2(N, M, Primes). - primes(4, N, M, Primes) :- - mt_primes_4(N, M, Primes). - - st_primes(N, M, Primes) :- - M > N, - prime_numbers(N, M, [], Primes). - - mt_primes_2(N, M, Primes) :- - M > N, - N1 is N + (M - N) // 2, - N2 is N1 + 1, - threaded(( - prime_numbers(N2, M, [], Acc), - prime_numbers(N, N1, Acc, Primes))). - - mt_primes_4(N, M, Primes) :- - M > N, - N3 is N + (M - N) // 2, - N4 is N3 + 1, - N1 is N + (N3 - N) // 2, - N2 is N1 + 1, - N5 is N4 + (M - N4) // 2, - N6 is N5 + 1, - threaded(( - prime_numbers(N6, M, [], Acc1), - prime_numbers(N4, N5, Acc1, Acc2), - prime_numbers(N2, N3, Acc2, Acc3), - prime_numbers(N, N1, Acc3, Primes))). - - prime_numbers(N, M, Primes, Primes) :- - N > M, - !. - prime_numbers(N, M, Acc, Primes) :- - ( is_prime(N) -> - Primes = [N| Primes2] - ; Primes = Primes2), - N2 is N + 1, - prime_numbers(N2, M, Acc, Primes2). - - is_prime(2) :- !. - is_prime(Prime):- - Prime > 2, - Prime mod 2 =:= 1, - Sqrt is sqrt(Prime), - is_prime(3, Sqrt, Prime). - - is_prime(N, Sqrt, Prime):- - ( N > Sqrt -> - true - ; Prime mod N > 0, - N2 is N + 2, - is_prime(N2, Sqrt, Prime) - ). - -:- end_object. diff --git a/Logtalk/examples/threads/sorting/NOTES.txt b/Logtalk/examples/threads/sorting/NOTES.txt deleted file mode 100644 index 20a011e6f..000000000 --- a/Logtalk/examples/threads/sorting/NOTES.txt +++ /dev/null @@ -1,36 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains a multi-threading implementation of the merge sort -algorithm. Depending on the size of the lists that are ordered, using -only one thread can be faster. The number of threads to be use in sorting -is set using the msort/1 object parameter. You may need to adjust the -size of the memory areas used by your Prolog compiler, depending on the -size of the lists you want to sort. - -This example uses a simple implementation of the merge sort algorithm, -intended only to illustrate Logtalk multi-threading features. For any -other purpose, you may find the following paper a worthwhile reading: - -@incollection{ apt93modular, - author = "Krzysztof R. Apt and Dino Pedreschi", - title = "Modular Termination Proofs for Logic and Pure Prolog Programs.", - booktitle = "116", - month = "31", - publisher = "Centrum voor Wiskunde en Informatica (CWI)", - address = "ISSN 0169-118X", - pages = "35", - year = "1993", - url = "citeseer.ist.psu.edu/apt93modular.html" } - -You probably want to play with the list sizes in order to find out when the -lists to be sorted are big enough to make the use of multi-threading worth -performance-wise (i.e. to compensate the overhead of thread creation and -management). diff --git a/Logtalk/examples/threads/sorting/SCRIPT.txt b/Logtalk/examples/threads/sorting/SCRIPT.txt deleted file mode 100644 index 38b0ff52e..000000000 --- a/Logtalk/examples/threads/sorting/SCRIPT.txt +++ /dev/null @@ -1,83 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example and the required library files: - -| ?- logtalk_load(sorting(loader)). -... - - -% NOTE: the example queries below use a SWI-Prolog proprietary predicate -% time/1 in order to get accurate goal times. For other Prolog compilers, -% replace the time/1 call by any appropriate timing calls (e.g. cputime/0). - - -% generate a big list of random floats and then merge sort it using a single thread: - -?- generator::list(20000, List), time(msort(1)::msort(List, Sorted)). -% 1,145,746 inferences, 0.40 CPU in 0.43 seconds (93% CPU, 2864365 Lips) - -List = [0.326219, 0.545052, 0.21687, 0.0500493, 0.772745, 0.805005, 0.574483, 0.301708, 0.670021|...], -Sorted = [1.39358e-06, 0.000206126, 0.00026088, 0.000299165, 0.000362691, 0.000397709, 0.000539889, 0.000574419, 0.000578717|...] - -Yes - - -% generate a big list of random floats and then merge sort it using two threads: - -?- generator::list(20000, List), time(msort(2)::msort(List, Sorted)). -% 80,067 inferences, 0.32 CPU in 0.21 seconds (150% CPU, 250209 Lips) - -List = [0.963245, 0.666814, 0.3841, 0.281952, 0.806571, 0.608224, 0.623344, 0.138888, 0.867367|...], -Sorted = [5.89827e-05, 0.00010463, 0.000105771, 0.000171936, 0.00022632, 0.000378509, 0.000392918, 0.00041885, 0.000482844|...] - -Yes - - -% generate a big list of random floats and then merge sort it using four threads: - -?- generator::list(20000, List), time(msort(4)::msort(List, Sorted)). -% 80,079 inferences, 0.32 CPU in 0.16 seconds (204% CPU, 250247 Lips) - -List = [0.0923009, 0.443585, 0.72304, 0.945816, 0.501491, 0.311327, 0.597448, 0.915656, 0.666957|...], -Sorted = [3.65916e-05, 4.06822e-05, 5.07434e-05, 6.09007e-05, 0.000134275, 0.000190491, 0.00024128, 0.000361441, 0.000412926|...] - -Yes - - -% generate a big list of random floats and then quick sort it using a single thread: - -?- generator::list(20000, List), time(qsort(1)::qsort(List, Sorted)). -% 1,145,746 inferences, 0.40 CPU in 0.43 seconds (93% CPU, 2864365 Lips) - -List = [0.326219, 0.545052, 0.21687, 0.0500493, 0.772745, 0.805005, 0.574483, 0.301708, 0.670021|...], -Sorted = [1.39358e-06, 0.000206126, 0.00026088, 0.000299165, 0.000362691, 0.000397709, 0.000539889, 0.000574419, 0.000578717|...] - -Yes - - -% generate a big list of random floats and then quick sort it using two threads: - -?- generator::list(20000, List), time(qsort(2)::qsort(List, Sorted)). -% 80,067 inferences, 0.32 CPU in 0.21 seconds (150% CPU, 250209 Lips) - -List = [0.963245, 0.666814, 0.3841, 0.281952, 0.806571, 0.608224, 0.623344, 0.138888, 0.867367|...], -Sorted = [5.89827e-05, 0.00010463, 0.000105771, 0.000171936, 0.00022632, 0.000378509, 0.000392918, 0.00041885, 0.000482844|...] - -Yes - - -% generate a big list of random floats and then quick sort it using four threads: - -?- generator::list(20000, List), time(qsort(4)::qsort(List, Sorted)). -% 80,079 inferences, 0.32 CPU in 0.16 seconds (204% CPU, 250247 Lips) - -List = [0.0923009, 0.443585, 0.72304, 0.945816, 0.501491, 0.311327, 0.597448, 0.915656, 0.666957|...], -Sorted = [3.65916e-05, 4.06822e-05, 5.07434e-05, 6.09007e-05, 0.000134275, 0.000190491, 0.00024128, 0.000361441, 0.000412926|...] - -Yes diff --git a/Logtalk/examples/threads/sorting/generator.lgt b/Logtalk/examples/threads/sorting/generator.lgt deleted file mode 100644 index bd7679f69..000000000 --- a/Logtalk/examples/threads/sorting/generator.lgt +++ /dev/null @@ -1,19 +0,0 @@ - -:- object(generator). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2007/03/22, - comment is 'Simple object defining a predicate for generating lists of random values.']). - - :- public(list/2). - - list(0, []). - list(N, [R| Rs]) :- - N > 0, - N2 is N - 1, - random::random(R), - list(N2, Rs). - -:- end_object. diff --git a/Logtalk/examples/threads/sorting/loader.lgt b/Logtalk/examples/threads/sorting/loader.lgt deleted file mode 100644 index 3c708e858..000000000 --- a/Logtalk/examples/threads/sorting/loader.lgt +++ /dev/null @@ -1,4 +0,0 @@ - -:- initialization(( - logtalk_load(library(random_loader), [reload(skip)]), % allow for static binding - logtalk_load([generator, qsort, msort]))). diff --git a/Logtalk/examples/threads/sorting/msort.lgt b/Logtalk/examples/threads/sorting/msort.lgt deleted file mode 100644 index fff62ba70..000000000 --- a/Logtalk/examples/threads/sorting/msort.lgt +++ /dev/null @@ -1,57 +0,0 @@ - -:- object(msort(_Threads)). - - :- info([ - version is 1.1, - author is 'Paulo Moura and Paul Crocker', - date is 2007/03/30, - comment is 'Multi-threaded implementation of the merge sort algorithm.', - parameters is ['Threads'- 'Number of threads to use in sorting. Valid values are 1, 2, 4, 8, etc.']]). - - :- threaded. - - :- public(msort/2). - :- mode(msort(+list, -list), one). - :- info(msort/2, [ - comment is 'Sorts a list of terms into ascending order.', - argnames is ['List', 'Sorted']]). - - msort(List, Sorted) :- - parameter(1, Threads), - mt_msort(Threads, List, Sorted). - - mt_msort(1, List, Sorted) :- - st_msort(List, Sorted). - mt_msort(N, List, Sorted) :- - N > 1, - N2 is N//2, - split(List, List1, List2), - threaded(( - mt_msort(N2, List1, Sorted1), - mt_msort(N2, List2, Sorted2) - )), !, % SWI-Prolog needs help with determinism detection - merge(Sorted1, Sorted2, Sorted). - - st_msort([], []). - st_msort([X], [X]). - st_msort([X, Y| Xs], Ys) :- - split([X, Y| Xs], X1s, X2s), - st_msort(X1s, Y1s), - st_msort(X2s, Y2s), - merge(Y1s, Y2s, Ys). - - split([], [], []). - split([X| Xs], [X| Ys], Zs) :- - split(Xs, Zs, Ys). - - merge([X| Xs], [Y| Ys], [X| Zs]) :- - X =< Y, !, - merge(Xs, [Y| Ys], Zs). - merge([X| Xs], [Y| Ys], [Y| Zs]) :- - X > Y, !, - merge([X | Xs], Ys, Zs). - merge([], Xs, Xs) :- !. - merge(Xs, [], Xs). - -:- end_object. - diff --git a/Logtalk/examples/threads/sorting/qsort.lgt b/Logtalk/examples/threads/sorting/qsort.lgt deleted file mode 100644 index 129152456..000000000 --- a/Logtalk/examples/threads/sorting/qsort.lgt +++ /dev/null @@ -1,50 +0,0 @@ - -:- object(qsort(_Threads)). - - :- info([ - version is 1.0, - author is 'Paul Croker and Paulo Moura', - date is 2007/03/29, - comment is 'Multi-threaded version of the quick sort algorithm.', - parameters is ['Threads'- 'Number of threads to use in sorting. Valid values are 1, 2, 4, 8, 16, 32, etc.']]). - - :- threaded. - - :- public(qsort/2). - :- mode(qsort(+list, -list), one). - :- info(qsort/2, [ - comment is 'Sorts a list of terms into ascending order.', - argnames is ['List', 'Sorted']]). - - qsort(List, Sorted) :- - parameter(1, Threads), - qsort(List, [], Sorted, Threads). - - qsort([], Sorted, Sorted, _). - qsort([Pivot| Rest], Acc, Sorted, N) :- - ( N =:= 1 -> - quicksort([Pivot| Rest], Acc, Sorted) - ; N2 is N//2, - partition(Rest, Pivot, Smaller0, Bigger0), - threaded(( - qsort(Smaller0, [Pivot| Bigger], Sorted, N2), - qsort(Bigger0, Acc, Bigger, N2) - )), ! % SWI-Prolog needs help with determinism detection - ). - - partition([], _, [], []). - partition([X| Xs], Pivot, Smalls, Bigs) :- - ( X < Pivot -> - Smalls = [X| Rest], - partition(Xs, Pivot, Rest, Bigs) - ; Bigs = [X| Rest], - partition(Xs, Pivot, Smalls, Rest) - ). - - quicksort([], Sorted, Sorted). - quicksort([Pivot| Rest], Acc, Sorted) :- - partition(Rest, Pivot, Smaller0, Bigger0), - quicksort(Smaller0, [Pivot| Bigger], Sorted), - quicksort(Bigger0, Acc, Bigger). - -:- end_object. diff --git a/Logtalk/examples/threads/sync/NOTES.txt b/Logtalk/examples/threads/sync/NOTES.txt deleted file mode 100644 index c6e51b4c6..000000000 --- a/Logtalk/examples/threads/sync/NOTES.txt +++ /dev/null @@ -1,19 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains a simple multi-threading example illustrating the -use of the "synchronized" predicate directive to cope with methods that -have side-effects. - -The object defined in the example source file, "sync.lgt", defines a -predicate named waste_time/0 that is used to delay the execuion of goals -in order to better illustrate the semantics of the "synchronized" predicate -directive. This predicate uses a counter that you might need to adjust, -depending on your Prolog compiler and computer performance. diff --git a/Logtalk/examples/threads/sync/SCRIPT.txt b/Logtalk/examples/threads/sync/SCRIPT.txt deleted file mode 100644 index 01c921bf1..000000000 --- a/Logtalk/examples/threads/sync/SCRIPT.txt +++ /dev/null @@ -1,57 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the loading the example: - -| ?- logtalk_load(sync(loader)). -... - - -% send three asynchronous messages whose corresponding methods perform output operations: - -| ?- threaded_ignore(nasty1::io(alpha)), threaded_ignore(nasty1::io(digit)), threaded_ignore(nasty1::io(alpha)). - -a0ab1bc2c3ddefef45gg6hh7ii8jkjk9 -llmmnnopopqqrrsstztzyyxxwwuv -uv - -Yes - - -% send three asynchronous messages whose corresponding methods perform database updates -% (this may or may not work, most likely will throw an exception): - -| ?- threaded_ignore(nasty1::update_db(_)), threaded_ignore(nasty1::update_db(_)), threaded_ignore(nasty1::update_db(_)). - -No - - -% the best solution is to declare predicates that need to be thread synchronized as "synchronized", -% as exemplified in object "nasty2": - -| ?- threaded_ignore(nasty2::io(alpha)), threaded_ignore(nasty2::io(digit)), threaded_ignore(nasty2::io(alpha)). - -abcdefghijklmnopqrstzyxwuv -0123456789 -abcdefghijklmnopqrstzyxwuv - -Yes - - -| ?- threaded_call(nasty2::update_db(_)), threaded_call(nasty2::update_db(_)), threaded_call(nasty2::update_db(_)). - -Yes - -| ?- threaded_exit(nasty2::update_db(X)), threaded_exit(nasty2::update_db(Y)), threaded_exit(nasty2::update_db(Z)). - - -X = 1 -Y = 2 -Z = 3 - -Yes diff --git a/Logtalk/examples/threads/sync/loader.lgt b/Logtalk/examples/threads/sync/loader.lgt deleted file mode 100644 index 41d06ddd5..000000000 --- a/Logtalk/examples/threads/sync/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(sync)). diff --git a/Logtalk/examples/threads/sync/sync.lgt b/Logtalk/examples/threads/sync/sync.lgt deleted file mode 100644 index 2b204f427..000000000 --- a/Logtalk/examples/threads/sync/sync.lgt +++ /dev/null @@ -1,121 +0,0 @@ - -:- object(nasty1). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2006/11/26, - comment is 'Simple example for illustrating the problems with lack of thread synchronization when calling methods with side-effects.']). - - :- threaded. - - :- public(update_db/1). - :- mode(update_db(-integer), one). - :- info(update_db/1, [ - comment is 'Perform a database update with a long delay between retracting the old information and asserting the new one.', - argnames is ['New']]). - - :- private(db/1). - :- dynamic(db/1). - - :- public(io/1). - :- mode(io(+atom), one). - :- info(io/1, [ - comment is 'Write some characters to the standard output stream with a long delay between each write operation.', - argnames is ['Chars']]). - - db(0). - - update_db(New) :- - retract(db(Old)), - waste_time, - New is Old + 1, - waste_time, - assertz(db(New)). - - io(alpha) :- - write(a), waste_time, write(b), waste_time, write(c), waste_time, write(d), waste_time, write(e), - write(f), waste_time, write(g), waste_time, write(h), waste_time, write(i), waste_time, write(j), - write(k), waste_time, write(l), waste_time, write(m), waste_time, write(n), waste_time, write(o), - write(p), waste_time, write(q), waste_time, write(r), waste_time, write(s), waste_time, write(t), - write(z), waste_time, write(y), waste_time, write(x), waste_time, write(w), waste_time, write(u), - write(v), nl. - - io(digit) :- - write(0), waste_time, write(1), waste_time, write(2), waste_time, write(3), waste_time, write(4), - write(5), waste_time, write(6), waste_time, write(7), waste_time, write(8), waste_time, write(9), nl. - - waste_time :- - between(1, 10000, _), - fail. - waste_time. - - between(Lower, _, Lower). - between(Lower, Upper, Integer) :- - Lower < Upper, - Next is Lower + 1, - between(Next, Upper, Integer). - -:- end_object. - - -:- object(nasty2). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2006/11/26, - comment is 'Simple example for using the "synchronized" predicate directive for multi-threading methods with side-effects.']). - - :- threaded. - - :- public(update_db/1). - :- synchronized(update_db/1). - :- mode(update_db(-integer), one). - :- info(update_db/1, [ - comment is 'Perform a database update with a long delay between retracting the old information and asserting the new one.', - argnames is ['New']]). - - :- private(db/1). - :- dynamic(db/1). - - :- public(io/1). - :- synchronized(io/1). - :- mode(io(+atom), one). - :- info(io/1, [ - comment is 'Write some characters to the standard output stream with a long delay between each write operation.', - argnames is ['Chars']]). - - db(0). - - update_db(New) :- - retract(db(Old)), - waste_time, - New is Old + 1, - waste_time, - assertz(db(New)). - - io(alpha) :- - write(a), waste_time, write(b), waste_time, write(c), waste_time, write(d), waste_time, write(e), - write(f), waste_time, write(g), waste_time, write(h), waste_time, write(i), waste_time, write(j), - write(k), waste_time, write(l), waste_time, write(m), waste_time, write(n), waste_time, write(o), - write(p), waste_time, write(q), waste_time, write(r), waste_time, write(s), waste_time, write(t), - write(z), waste_time, write(y), waste_time, write(x), waste_time, write(w), waste_time, write(u), - write(v), nl. - - io(digit) :- - write(0), waste_time, write(1), waste_time, write(2), waste_time, write(3), waste_time, write(4), - write(5), waste_time, write(6), waste_time, write(7), waste_time, write(8), waste_time, write(9), nl. - - waste_time :- - between(1, 100000, _), - fail. - waste_time. - - between(Lower, _, Lower). - between(Lower, Upper, Integer) :- - Lower < Upper, - Next is Lower + 1, - between(Next, Upper, Integer). - -:- end_object. diff --git a/Logtalk/examples/threads/tak/NOTES.txt b/Logtalk/examples/threads/tak/NOTES.txt deleted file mode 100644 index 3e5c0aaa5..000000000 --- a/Logtalk/examples/threads/tak/NOTES.txt +++ /dev/null @@ -1,13 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -This folder contains single-threaded and multi-threaded implementations -of the Takeuchi function (recursive arithmetic). The multi-threaded version -uses three threads per recursive call. diff --git a/Logtalk/examples/threads/tak/SCRIPT.txt b/Logtalk/examples/threads/tak/SCRIPT.txt deleted file mode 100644 index 26d38f9bc..000000000 --- a/Logtalk/examples/threads/tak/SCRIPT.txt +++ /dev/null @@ -1,54 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% load the example: - -| ?- logtalk_load(tak(loader)). -... - - -% single-threaded version: - -| ?- time(tak::tak_st(18, 12, 6, R)). - -% 254,474 inferences, 1.44 CPU in 1.47 seconds (98% CPU, 176718 Lips) - -R = 7 - -Yes - - -% multi-threaded version: - -| ?- time(tak::tak_mt(18, 12, 6, R)). - -% 202 inferences, 1.45 CPU in 0.77 seconds (188% CPU, 139 Lips) - -R = 7 - -Yes - - -% single-threaded version: - -| ?- time(tak::tak_st(21, 14, 7, R)). -% 1,583,066 inferences, 12.40 CPU in 12.53 seconds (99% CPU, 127667 Lips) - -R = 14 - -Yes - - -% multi-threaded version: - -| ?- time(tak::tak_mt(21, 14, 7, R)). -% 122 inferences, 11.98 CPU in 7.74 seconds (155% CPU, 10 Lips) - -R = 14 - -Yes diff --git a/Logtalk/examples/threads/tak/loader.lgt b/Logtalk/examples/threads/tak/loader.lgt deleted file mode 100644 index f00fa445f..000000000 --- a/Logtalk/examples/threads/tak/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(tak)). diff --git a/Logtalk/examples/threads/tak/tak.lgt b/Logtalk/examples/threads/tak/tak.lgt deleted file mode 100644 index ea0b821e4..000000000 --- a/Logtalk/examples/threads/tak/tak.lgt +++ /dev/null @@ -1,52 +0,0 @@ - -:- object(tak). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2007/07/15, - comment is 'Takeuchi function (recursive arithmetic).']). - - :- threaded. - - :- public(tak_st/4). - :- mode(tak_st(+integer, +integer, +integer, -integer), one). - :- info(tak_st/4, [ - comment is 'Single-threaded version of Takeuchi function.', - argnames is ['X', 'Y', 'Z', 'R']]). - - :- public(tak_mt/4). - :- mode(tak_mt(+integer, +integer, +integer, -integer), one). - :- info(tak_mt/4, [ - comment is 'Multi-threaded version of Takeuchi function.', - argnames is ['X', 'Y', 'Z', 'R']]). - - tak_st(X, Y, Z, A):- - X =< Y, - Z = A. - tak_st(X, Y, Z, A):- - X > Y, - X1 is X - 1, - tak_st(X1, Y, Z, A1), - Y1 is Y - 1, - tak_st(Y1, Z, X, A2), - Z1 is Z - 1, - tak_st(Z1, X, Y, A3), - tak_st(A1, A2, A3, A). - - tak_mt(X, Y, Z, A):- - X =< Y, - Z = A. - tak_mt(X, Y, Z, A):- - X > Y, - X1 is X - 1, - Y1 is Y - 1, - Z1 is Z - 1, - threaded(( - tak_st(X1, Y, Z, A1), - tak_st(Y1, Z, X, A2), - tak_st(Z1, X, Y, A3) - )), - tak_mt(A1, A2, A3, A). - -:- end_object. diff --git a/Logtalk/examples/viewpoints/NOTES.txt b/Logtalk/examples/viewpoints/NOTES.txt deleted file mode 100644 index 36fbcbc14..000000000 --- a/Logtalk/examples/viewpoints/NOTES.txt +++ /dev/null @@ -1,25 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load this example and for sample queries, please see the SCRIPT file. - -Example adopted from the chapter "Classifying Prototype-Based Programming -Languages" by Christophe Dony, Jacques Malenfant, and Daniel Bardou, found -on the book "Prototype-Based Programming - Concepts, Languages, and -Applications" published by Springer. - - -This prototype programming example illustrates how we can do both property -sharing and value sharing in Logtalk by calling the built-in predicate -modification methods asserta/1, assertz/1, and retract/1 either in the -context of "this" or in the context of "self". - -In this example we have a prototype, joePerson, containing general data on -Joe such as its age, name, or address, and four descendant prototypes or -viewpoints, joeSportsman, joeEmployee, joeChessPlayer, and joeFilmEnthusiast. -Each descendant contains data related to a particular viewpoint about Joe. diff --git a/Logtalk/examples/viewpoints/SCRIPT.txt b/Logtalk/examples/viewpoints/SCRIPT.txt deleted file mode 100644 index 56a452e78..000000000 --- a/Logtalk/examples/viewpoints/SCRIPT.txt +++ /dev/null @@ -1,110 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -% start by loading the example: - -| ?- logtalk_load(viewpoints(loader)). -... - - -% we can start by asking joe its age: - -| ?- joePerson::age(Age). - -Age = 30 -yes - - -% the same question could be made via any of its viewpoints: - -| ?- joeSportsman::age(Age). - -Age = 30 -yes - - -% now let's tell joe to get older: - -| ?- joePerson::getOlder. - -yes - - -% we can verify the effect of the above message from any of the viewpoints: - -| ?- joeChessPlayer::age(Age). - -Age = 31 -yes - - -% because the growOld/0 and the age/1 predicates are implemented using -% property sharing, we can send the getOlder/0 message to any viewpoint: - -| ?- joeEmployee::getOlder. - -yes - - -% we can check this by asking joe its age: - - -| ?- joePerson::age(Age). - -Age = 32 -yes - - -% as you can see, although the modification message have been sent to a -% descendant, its the predicate age/1 in the parent that got updated - - -% to illustrate value sharing we use a couple of predicates, score/1 and -% setScore/0, defined in joePerson: - - -| ?- joePerson::score(Score). - -Score = 0 -yes - - -% initially, score/1 is only defined for joePerson, so every descendant -% or viewpoint will share its value/definition: - -| ?- joeEmployee::score(Score). - -Score = 0 -yes - - -% but if we decide to increment the counter by sending the setScore/0 -% message to a descendant: - -| ?- joeChessPlayer::(setScore(2200), score(Score)). - -Score = 2200 -yes - - -% then the descendant will now have a local definition for counter/1, -% independent of the definition in its parent, joePerson: - -| ?- joePerson::score(Score). - -Score = 0 -yes - - -% the other descendants/viewpoints will continue to share the definition -% in joePerson: - -| ?- joeSportsman::score(Score). - -Score = 0 -yes diff --git a/Logtalk/examples/viewpoints/loader.lgt b/Logtalk/examples/viewpoints/loader.lgt deleted file mode 100644 index 68ebd130d..000000000 --- a/Logtalk/examples/viewpoints/loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load(viewpoints)). diff --git a/Logtalk/examples/viewpoints/viewpoints.lgt b/Logtalk/examples/viewpoints/viewpoints.lgt deleted file mode 100644 index 0b68105fa..000000000 --- a/Logtalk/examples/viewpoints/viewpoints.lgt +++ /dev/null @@ -1,113 +0,0 @@ - -% general information about Joe: - -:- object(joePerson). - - :- public(getOlder/0). - - :- public(address/1). - - :- public(age/1). - :- dynamic(age/1). - - :- public(name/1). - - :- public(phone/1). - - :- public(score/1). - :- dynamic(score/1). - - :- public(setScore/1). - - getOlder :- % this predicate uses property sharing, i.e. - retract(age(Old)), % the property and its value are shared by all - New is Old + 1, % descendant prototypes/viewpoints; changes - asserta(age(New)). % are shared no matter which viewpoint receives - % the getOlder/1 message - address('8 Octave Street'). - - age(30). - - name('John'). - - phone(11-11-11-11). - - score(0). % default value for the score/1 property, - % shared by all descendant prototypes/viewpoints; - setScore(Score) :- % changing the default value results in - ::retractall(score(_)), % in a local value stored in the descendant - ::asserta(score(Score)). % prototype that received the setScore/1 message - -:- end_object. - - -% information on Joe as an employee: - -:- object(joeEmployee, - extends(joePerson)). - - :- public(worksFor/1). - - :- public(salary/1). - :- dynamic(salary/1). - - :- public(giveRaise/1). - - worksFor('ToonTown'). - - salary(1500). - - giveRaise(Raise) :- % another example of property sharing - retract(salary(Old)), - New is Old + Raise, - asserta(salary(New)). - -:- end_object. - - -% information on Joe as an chess player: - -:- object(joeChessPlayer, - extends(joePerson)). - - :- public(category/1). - - category('National Master'). - -:- end_object. - - -% information on Joe as a movies fan: - -:- object(joeFilmEnthusiast, - extends(joePerson)). - - :- public(favActor/1). - :- public(favFilm/1). - :- public(favDirector/1). - - favActor('Fred Filistone'). - - favFilm('The Wizard of Oz'). - - favDirector('Krzystof Kieslowski'). - -:- end_object. - - -% information on Joe as a sportsman: - -:- object(joeSportsman, - extends(joePerson)). - - :- public(sport/1). - :- public(stamina/1). - :- public(weight/1). - - sport(snowboard). - - stamina(30). - - weight(111). - -:- end_object. diff --git a/Logtalk/integration/NOTES.txt b/Logtalk/integration/NOTES.txt deleted file mode 100644 index 29ff3e6b5..000000000 --- a/Logtalk/integration/NOTES.txt +++ /dev/null @@ -1,68 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This directory contains Prolog integration shell scripts and auxiliary -Prolog files. - -On POSIX systems, the Logtalk installers make the following integration -scripts available from the command-line (you may need to adjust your -system path): - - bplgt B-Prolog integration script - ciaolgt Ciao Prolog integration script - cxlgt CxProlog integration script - eclipselgt ECLiPSe integration script - gplgt GNU Prolog integration script - plclgt K-Prolog integration script - qplgt Qu-Prolog integration script - sicstuslgt SICStus Prolog integration script - swilgt SWI-Prolog integration script - xsblgt XSB integration script (single-threaded) - xsbmtlgt XSB integration script (multi-threaded) - yaplgt YAP integration script - -On Windows systems, the Logtalk installer makes the Prolog integration -shortcuts available from the "Start Menu/Programs/Logtalk" menu. - -The first run of the B-Prolog, Ciao, and XSB integration scripts must be -made by an user with administrative rights (on POSIX systems, run them -once as root or using sudo; in Windows systems run them once from an -administrative account). - -The GNU Prolog integration script provides adequate performance for -development. For production environments, improved performance may be -achieved by generating a new GNU-Prolog top-level that includes Logtalk. - -The SWI-Prolog integration script assumes XPCE is installed. If that's -not the case, comment out the loading of the file "xpcehook.pl" on the -"integration/logtalk_swi.pl" file. - -Other Prolog compilers require manual steps for integration with Logtalk. -See the "configs/NOTES.txt" file for details. - -The environment variables LOGTALKHOME and LOGTALKUSER should be defined -in order to run the integration scripts (see the "INSTALL.txt" file for -details on setting the variables). - -Note that the integration scripts and shortcuts may fail if you use non- -standard locations for your Prolog compilers. - -Depending on the size and complexity of your Logtalk applications, you -may need to change the integration scripts in order to allocate more -memory to the back-end Prolog compilers. Please consult the documentation -on the Prolog compilers you intend to use for details. - -All the scripts accept command-line options, which are passed straight to -the back-end Prolog compiler. For example (on a POSIX operating-system, -using SWI-Prolog as the back-end compiler): - - % swilgt -g "write('Hello world!'), nl" - -However, keep in mind that the integration scripts already use the back-end -Prolog command-line option that allows a initialization file to be loaded -in order to bootstrap Logtalk. See the scripts files for details. diff --git a/Logtalk/integration/bplgt.sh b/Logtalk/integration/bplgt.sh deleted file mode 100755 index 7ec4bb3ec..000000000 --- a/Logtalk/integration/bplgt.sh +++ /dev/null @@ -1,60 +0,0 @@ -#/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -if ! [ "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME should be defined first, pointing" - echo "to your Logtalk installation directory!" - echo "Trying the default locations for the Logtalk installation..." - if [ -d "/usr/local/share/logtalk" ]; then - LOGTALKHOME=/usr/local/share/logtalk - echo "... using Logtalk installation found at /usr/local/share/logtalk" - elif [ -d "/usr/share/logtalk" ]; then - LOGTALKHOME=/usr/share/logtalk - echo "... using Logtalk installation found at /usr/share/logtalk" - elif [ -d "/opt/local/share/logtalk" ]; then - LOGTALKHOME=/opt/local/share/logtalk - echo "... using Logtalk installation found at /opt/local/share/logtalk" - elif [ -d "/opt/share/logtalk" ]; then - LOGTALKHOME=/opt/share/logtalk - echo "... using Logtalk installation found at /opt/share/logtalk" - else - echo "... unable to locate Logtalk installation directory!" - echo - exit 1 - fi - echo -elif ! [ -d "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME points to a non-existing directory!" - echo "Its current value is: $LOGTALKHOME" - echo "The variable must be set to your Logtalk installation directory!" - echo - exit 1 -fi -export LOGTALKHOME - -if ! [ "$LOGTALKUSER" ]; then - echo "The environment variable LOGTALKUSER should be defined first, pointing" - echo "to your Logtalk user directory!" - echo "Trying the default location for the Logtalk user directory..." - export LOGTALKUSER=$HOME/logtalk - if [ -d "$LOGTALKUSER" ]; then - echo "... using Logtalk user directory found at $LOGTALKUSER" - else - echo "... Logtalk user directory not found at default location. Creating a" - echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" - cplgtdirs - fi -elif ! [ -d "$LOGTALKUSER" ]; then - echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" - echo "by running the \"cplgtdirs\" shell script:" - cplgtdirs -fi -echo - -exec bp -g "consult('$LOGTALKHOME/integration/logtalk_bp.pl'), \$bp_top_level" "$@" diff --git a/Logtalk/integration/ciaolgt.sh b/Logtalk/integration/ciaolgt.sh deleted file mode 100755 index 2afcac511..000000000 --- a/Logtalk/integration/ciaolgt.sh +++ /dev/null @@ -1,60 +0,0 @@ -#/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -if ! [ "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME should be defined first, pointing" - echo "to your Logtalk installation directory!" - echo "Trying the default locations for the Logtalk installation..." - if [ -d "/usr/local/share/logtalk" ]; then - LOGTALKHOME=/usr/local/share/logtalk - echo "... using Logtalk installation found at /usr/local/share/logtalk" - elif [ -d "/usr/share/logtalk" ]; then - LOGTALKHOME=/usr/share/logtalk - echo "... using Logtalk installation found at /usr/share/logtalk" - elif [ -d "/opt/local/share/logtalk" ]; then - LOGTALKHOME=/opt/local/share/logtalk - echo "... using Logtalk installation found at /opt/local/share/logtalk" - elif [ -d "/opt/share/logtalk" ]; then - LOGTALKHOME=/opt/share/logtalk - echo "... using Logtalk installation found at /opt/share/logtalk" - else - echo "... unable to locate Logtalk installation directory!" - echo - exit 1 - fi - echo -elif ! [ -d "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME points to a non-existing directory!" - echo "Its current value is: $LOGTALKHOME" - echo "The variable must be set to your Logtalk installation directory!" - echo - exit 1 -fi -export LOGTALKHOME - -if ! [ "$LOGTALKUSER" ]; then - echo "The environment variable LOGTALKUSER should be defined first, pointing" - echo "to your Logtalk user directory!" - echo "Trying the default location for the Logtalk user directory..." - export LOGTALKUSER=$HOME/logtalk - if [ -d "$LOGTALKUSER" ]; then - echo "... using Logtalk user directory found at $LOGTALKUSER" - else - echo "... Logtalk user directory not found at default location. Creating a" - echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" - cplgtdirs - fi -elif ! [ -d "$LOGTALKUSER" ]; then - echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" - echo "by running the \"cplgtdirs\" shell script:" - cplgtdirs -fi -echo - -exec ciaosh -l "$LOGTALKHOME/integration/logtalk_ciao.pl" "$@" diff --git a/Logtalk/integration/cxlgt.sh b/Logtalk/integration/cxlgt.sh deleted file mode 100755 index 334523e65..000000000 --- a/Logtalk/integration/cxlgt.sh +++ /dev/null @@ -1,61 +0,0 @@ -#/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -if ! [ "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME should be defined first, pointing" - echo "to your Logtalk installation directory!" - echo "Trying the default locations for the Logtalk installation..." - if [ -d "/usr/local/share/logtalk" ]; then - LOGTALKHOME=/usr/local/share/logtalk - echo "... using Logtalk installation found at /usr/local/share/logtalk" - elif [ -d "/usr/share/logtalk" ]; then - LOGTALKHOME=/usr/share/logtalk - echo "... using Logtalk installation found at /usr/share/logtalk" - elif [ -d "/opt/local/share/logtalk" ]; then - LOGTALKHOME=/opt/local/share/logtalk - echo "... using Logtalk installation found at /opt/local/share/logtalk" - elif [ -d "/opt/share/logtalk" ]; then - LOGTALKHOME=/opt/share/logtalk - echo "... using Logtalk installation found at /opt/share/logtalk" - else - echo "... unable to locate Logtalk installation directory!" - echo - exit 1 - fi - echo -elif ! [ -d "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME points to a non-existing directory!" - echo "Its current value is: $LOGTALKHOME" - echo "The variable must be set to your Logtalk installation directory!" - echo - exit 1 -fi - -export LOGTALKHOME - -if ! [ "$LOGTALKUSER" ]; then - echo "The environment variable LOGTALKUSER should be defined first, pointing" - echo "to your Logtalk user directory!" - echo "Trying the default location for the Logtalk user directory..." - export LOGTALKUSER=$HOME/logtalk - if [ -d "$LOGTALKUSER" ]; then - echo "... using Logtalk user directory found at $LOGTALKUSER" - else - echo "... Logtalk user directory not found at default location. Creating a" - echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" - cplgtdirs - fi -elif ! [ -d "$LOGTALKUSER" ]; then - echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" - echo "by running the \"cplgtdirs\" shell script:" - cplgtdirs -fi -echo - -exec cxprolog --goal "silent_consult('$LOGTALKHOME/integration/logtalk_cx.pl')" "$@" diff --git a/Logtalk/integration/eclipselgt.sh b/Logtalk/integration/eclipselgt.sh deleted file mode 100755 index 99a820117..000000000 --- a/Logtalk/integration/eclipselgt.sh +++ /dev/null @@ -1,60 +0,0 @@ -#/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -if ! [ "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME should be defined first, pointing" - echo "to your Logtalk installation directory!" - echo "Trying the default locations for the Logtalk installation..." - if [ -d "/usr/local/share/logtalk" ]; then - LOGTALKHOME=/usr/local/share/logtalk - echo "... using Logtalk installation found at /usr/local/share/logtalk" - elif [ -d "/usr/share/logtalk" ]; then - LOGTALKHOME=/usr/share/logtalk - echo "... using Logtalk installation found at /usr/share/logtalk" - elif [ -d "/opt/local/share/logtalk" ]; then - LOGTALKHOME=/opt/local/share/logtalk - echo "... using Logtalk installation found at /opt/local/share/logtalk" - elif [ -d "/opt/share/logtalk" ]; then - LOGTALKHOME=/opt/share/logtalk - echo "... using Logtalk installation found at /opt/share/logtalk" - else - echo "... unable to locate Logtalk installation directory!" - echo - exit 1 - fi - echo -elif ! [ -d "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME points to a non-existing directory!" - echo "Its current value is: $LOGTALKHOME" - echo "The variable must be set to your Logtalk installation directory!" - echo - exit 1 -fi -export LOGTALKHOME - -if ! [ "$LOGTALKUSER" ]; then - echo "The environment variable LOGTALKUSER should be defined first, pointing" - echo "to your Logtalk user directory!" - echo "Trying the default location for the Logtalk user directory..." - export LOGTALKUSER=$HOME/logtalk - if [ -d "$LOGTALKUSER" ]; then - echo "... using Logtalk user directory found at $LOGTALKUSER" - else - echo "... Logtalk user directory not found at default location. Creating a" - echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" - cplgtdirs - fi -elif ! [ -d "$LOGTALKUSER" ]; then - echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" - echo "by running the \"cplgtdirs\" shell script:" - cplgtdirs -fi -echo - -exec eclipse -b "$LOGTALKHOME/integration/logtalk_eclipse.pl" "$@" diff --git a/Logtalk/integration/gplgt.sh b/Logtalk/integration/gplgt.sh deleted file mode 100755 index 3dd082302..000000000 --- a/Logtalk/integration/gplgt.sh +++ /dev/null @@ -1,60 +0,0 @@ -#/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -if ! [ "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME should be defined first, pointing" - echo "to your Logtalk installation directory!" - echo "Trying the default locations for the Logtalk installation..." - if [ -d "/usr/local/share/logtalk" ]; then - LOGTALKHOME=/usr/local/share/logtalk - echo "... using Logtalk installation found at /usr/local/share/logtalk" - elif [ -d "/usr/share/logtalk" ]; then - LOGTALKHOME=/usr/share/logtalk - echo "... using Logtalk installation found at /usr/share/logtalk" - elif [ -d "/opt/local/share/logtalk" ]; then - LOGTALKHOME=/opt/local/share/logtalk - echo "... using Logtalk installation found at /opt/local/share/logtalk" - elif [ -d "/opt/share/logtalk" ]; then - LOGTALKHOME=/opt/share/logtalk - echo "... using Logtalk installation found at /opt/share/logtalk" - else - echo "... unable to locate Logtalk installation directory!" - echo - exit 1 - fi - echo -elif ! [ -d "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME points to a non-existing directory!" - echo "Its current value is: $LOGTALKHOME" - echo "The variable must be set to your Logtalk installation directory!" - echo - exit 1 -fi -export LOGTALKHOME - -if ! [ "$LOGTALKUSER" ]; then - echo "The environment variable LOGTALKUSER should be defined first, pointing" - echo "to your Logtalk user directory!" - echo "Trying the default location for the Logtalk user directory..." - export LOGTALKUSER=$HOME/logtalk - if [ -d "$LOGTALKUSER" ]; then - echo "... using Logtalk user directory found at $LOGTALKUSER" - else - echo "... Logtalk user directory not found at default location. Creating a" - echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" - cplgtdirs - fi -elif ! [ -d "$LOGTALKUSER" ]; then - echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" - echo "by running the \"cplgtdirs\" shell script:" - cplgtdirs -fi -echo - -exec gprolog --init-goal "['$LOGTALKUSER/configs/gnu.config','$LOGTALKHOME/integration/logtalk_gp.pl','$LOGTALKUSER/libpaths/libpaths.pl']" "$@" diff --git a/Logtalk/integration/logtalk_bp.pl b/Logtalk/integration/logtalk_bp.pl deleted file mode 100644 index 5cf799e48..000000000 --- a/Logtalk/integration/logtalk_bp.pl +++ /dev/null @@ -1,15 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- set_prolog_flag(redefined, off). -:- cl('$LOGTALKUSER/configs/b.config'). -:- cl('$LOGTALKHOME/compiler/logtalk.pl'). -:- cl('$LOGTALKUSER/libpaths/libpaths.pl'). diff --git a/Logtalk/integration/logtalk_bp_win.pl b/Logtalk/integration/logtalk_bp_win.pl deleted file mode 100644 index 8e02b8cf0..000000000 --- a/Logtalk/integration/logtalk_bp_win.pl +++ /dev/null @@ -1,17 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- set_prolog_flag(redefined, off). -:- cl('$LOGTALKUSER/configs/b.config'). -%:- system('del %LOGTALKUSER%\\configs\\b.config.out'). -:- (expand_environment('$LOGTALKHOME/compiler/logtalk.pl.out', Expanded), exists(Expanded) -> load('$LOGTALKHOME/compiler/logtalk.pl'); cl('$LOGTALKHOME/compiler/logtalk.pl')). -:- cl('$LOGTALKUSER/libpaths/libpaths.pl'). -%:- system('del %LOGTALKUSER%\\libpaths\\libpaths.pl.out'). diff --git a/Logtalk/integration/logtalk_ciao.pl b/Logtalk/integration/logtalk_ciao.pl deleted file mode 100644 index e0b03e5ac..000000000 --- a/Logtalk/integration/logtalk_ciao.pl +++ /dev/null @@ -1,22 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- ensure_loaded('$LOGTALKUSER/configs/ciao_aux.config'). -:- set_prolog_flag(multi_arity_warnings, off). -:- ensure_loaded('$LOGTALKHOME/compiler/logtalk.pl'). -:- ensure_loaded('$LOGTALKUSER/libpaths/libpaths.pl'). -:- op(600, xfy, ::). -:- op(600, fy, ::). -:- op(600, fy, ^^). -:- op(200, fy, +). -:- op(200, fy, ?). -:- op(200, fy, @). -:- op(200, fy, -). diff --git a/Logtalk/integration/logtalk_comp_eclipse.pl b/Logtalk/integration/logtalk_comp_eclipse.pl deleted file mode 100644 index 0766f2460..000000000 --- a/Logtalk/integration/logtalk_comp_eclipse.pl +++ /dev/null @@ -1,15 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- pragma(system). -:- pragma(nodebug). -:- ensure_loaded(library(toplevel)). -:- include('$LOGTALKHOME/compiler/logtalk.pl'). diff --git a/Logtalk/integration/logtalk_comp_swi.pl b/Logtalk/integration/logtalk_comp_swi.pl deleted file mode 100644 index e52fb17a7..000000000 --- a/Logtalk/integration/logtalk_comp_swi.pl +++ /dev/null @@ -1,22 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- set_prolog_flag(iso, true). -:- set_prolog_flag(generate_debug_info, false). -:- system_module. -:- op(600, xfy, ::). -:- op(600, fy, ::). -:- op(600, fy, ^^). -:- op(200, fy, +). -:- op(200, fy, ?). -:- op(200, fy, @). -:- op(200, fy, -). -:- include('../compiler/logtalk.pl'). diff --git a/Logtalk/integration/logtalk_comp_xsbmt.pl b/Logtalk/integration/logtalk_comp_xsbmt.pl deleted file mode 100644 index 2fee6b917..000000000 --- a/Logtalk/integration/logtalk_comp_xsbmt.pl +++ /dev/null @@ -1,71 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- import stat_set_flag/2 from machine. % workaround for compiling/loading source files -:- stat_set_flag(79, 1). % when more than one thread is active - -:- compiler_options([xpp_on]). - -#include ../compiler/logtalk.pl - -% tables of defined events and monitors -:- thread_shared('$lgt_before_'(_, _, _, _, _)). -:- thread_shared('$lgt_after_'(_, _, _, _, _)). - -% tables of loaded entities and respective relationships -:- thread_shared('$lgt_current_protocol_'(_, _, _)). -:- thread_shared('$lgt_current_category_'(_, _, _, _)). -:- thread_shared('$lgt_current_object_'(_, _, _, _, _, _, _, _)). - -:- thread_shared('$lgt_implements_protocol_'(_, _, _)). -:- thread_shared('$lgt_imports_category_'(_, _, _)). -:- thread_shared('$lgt_instantiates_class_'(_, _, _)). -:- thread_shared('$lgt_specializes_class_'(_, _, _)). -:- thread_shared('$lgt_extends_protocol_'(_, _, _)). -:- thread_shared('$lgt_extends_object_'(_, _, _)). - -% table of loaded files -:- thread_shared('$lgt_loaded_file_'(_, _)). - -% debugger status and tables -:- thread_shared('$lgt_debugging_'(_)). - -:- thread_shared('$lgt_dbg_debugging_'). -:- thread_shared('$lgt_dbg_tracing_'). -:- thread_shared('$lgt_dbg_skipping_'). -:- thread_shared('$lgt_dbg_spying_'(_, _)). -:- thread_shared('$lgt_dbg_spying_'(_, _, _, _)). -:- thread_shared('$lgt_dbg_leashing_'(_)). - -% runtime flags -:- thread_shared('$lgt_current_flag_'(_, _)). - -% static binding caches -:- thread_shared('$lgt_static_binding_entity_'(_)). -:- thread_shared('$lgt_obj_static_binding_cache_'(_, _, _, _)). -:- thread_shared('$lgt_ctg_static_binding_cache_'(_, _, _, _, _, _)). - -% lookup caches for messages to an object, messages to self, and super calls -:- thread_shared('$lgt_obj_lookup_cache_'(_, _, _, _)). -:- thread_shared('$lgt_self_lookup_cache_'(_, _, _, _)). -:- thread_shared('$lgt_super_lookup_cache_'(_, _, _, _, _)). - -% lookup cache for asserting and retracting dynamic facts -:- thread_shared('$lgt_db_lookup_cache_'(_, _, _, _, _)). - -% table of library paths -:- thread_shared(logtalk_library_path(_, _)). - -% compiler hook goal: -:- thread_shared('$lgt_hook_goal_'(_, _)). - -% multi-threading tags -:- thread_shared('$lgt_threaded_tag_counter'(_)). diff --git a/Logtalk/integration/logtalk_cx.pl b/Logtalk/integration/logtalk_cx.pl deleted file mode 100644 index 17edcadf3..000000000 --- a/Logtalk/integration/logtalk_cx.pl +++ /dev/null @@ -1,15 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- set_prolog_flag(file_name_variables, true). -:- silent_consult('$LOGTALKUSER/configs/cx.config'). -:- silent_consult('$LOGTALKHOME/compiler/logtalk.pl'). -:- silent_consult('$LOGTALKUSER/libpaths/libpaths.pl'). diff --git a/Logtalk/integration/logtalk_eclipse.pl b/Logtalk/integration/logtalk_eclipse.pl deleted file mode 100644 index e22bbb4fe..000000000 --- a/Logtalk/integration/logtalk_eclipse.pl +++ /dev/null @@ -1,14 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- compile('$LOGTALKUSER/configs/eclipseiso.config'). -:- compile('$LOGTALKHOME/integration/logtalk_comp_eclipse.pl'). -:- compile('$LOGTALKUSER/libpaths/libpaths.pl'). diff --git a/Logtalk/integration/logtalk_gp.pl b/Logtalk/integration/logtalk_gp.pl deleted file mode 100644 index 940dbc6d3..000000000 --- a/Logtalk/integration/logtalk_gp.pl +++ /dev/null @@ -1,13 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- built_in. -:- include('$LOGTALKHOME/compiler/logtalk.pl'). diff --git a/Logtalk/integration/logtalk_plc.pl b/Logtalk/integration/logtalk_plc.pl deleted file mode 100644 index 17318677f..000000000 --- a/Logtalk/integration/logtalk_plc.pl +++ /dev/null @@ -1,14 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- consult('$LOGTALKUSER/configs/k.config'). -:- consult('$LOGTALKHOME/compiler/logtalk.pl'). -:- consult('$LOGTALKUSER/libpaths/libpaths.pl'). diff --git a/Logtalk/integration/logtalk_qp.pl b/Logtalk/integration/logtalk_qp.pl deleted file mode 100644 index f89f388a0..000000000 --- a/Logtalk/integration/logtalk_qp.pl +++ /dev/null @@ -1,19 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- os(system('ln -sf $LOGTALKUSER/configs/qu.config $LOGTALKUSER/configs/qu.pl')), - fcompile('$LOGTALKUSER/configs/qu.pl', [assemble_only(true)]), - load('$LOGTALKUSER/configs/qu.qo'), - os(system('ln -sf $LOGTALKHOME/compiler/logtalk.pl $LOGTALKUSER/.logtalk.pl')), - fcompile('$LOGTALKUSER/.logtalk.pl', [assemble_only(true), object_file('$LOGTALKUSER/.logtalk.qo'), string_table(256)]), - load('$LOGTALKUSER/.logtalk.qo'), - fcompile('$LOGTALKUSER/libpaths/libpaths.pl', [assemble_only(true)]), - load('$LOGTALKUSER/libpaths/libpaths.qo'). diff --git a/Logtalk/integration/logtalk_sicstus3.pl b/Logtalk/integration/logtalk_sicstus3.pl deleted file mode 100644 index 80b70516e..000000000 --- a/Logtalk/integration/logtalk_sicstus3.pl +++ /dev/null @@ -1,14 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- compile('$LOGTALKUSER/configs/sicstus.config'). -:- compile('$LOGTALKHOME/compiler/logtalk.pl'). -:- compile('$LOGTALKUSER/libpaths/libpaths.pl'). diff --git a/Logtalk/integration/logtalk_sicstus4.pl b/Logtalk/integration/logtalk_sicstus4.pl deleted file mode 100644 index cdd8e9cad..000000000 --- a/Logtalk/integration/logtalk_sicstus4.pl +++ /dev/null @@ -1,22 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- compile('$LOGTALKUSER/configs/sicstus4.config'). -:- asserta(( - user:goal_expansion(CallWitArgs, Layout, _, Call, Layout) :- - CallWitArgs =.. [call_with_args| Args], - Call =.. [call| Args])). -:- compile('$LOGTALKHOME/compiler/logtalk.pl'). -:- retract(( - user:goal_expansion(CallWitArgs, Layout, _, Call, Layout) :- - CallWitArgs =.. [call_with_args| Args], - Call =.. [call| Args])). -:- compile('$LOGTALKUSER/libpaths/libpaths.pl'). diff --git a/Logtalk/integration/logtalk_swi.pl b/Logtalk/integration/logtalk_swi.pl deleted file mode 100644 index 09c11172a..000000000 --- a/Logtalk/integration/logtalk_swi.pl +++ /dev/null @@ -1,16 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- consult('$LOGTALKUSER/configs/swi.config'). -:- consult('$LOGTALKHOME/integration/logtalk_comp_swi.pl'). -:- consult('$LOGTALKUSER/libpaths/libpaths.pl'). -:- consult('$LOGTALKUSER/configs/swihook.pl'). -:- consult('$LOGTALKUSER/configs/xpcehook.pl'). diff --git a/Logtalk/integration/logtalk_xsbmt.pl b/Logtalk/integration/logtalk_xsbmt.pl deleted file mode 100644 index 9a13359d7..000000000 --- a/Logtalk/integration/logtalk_xsbmt.pl +++ /dev/null @@ -1,16 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- import expand_atom/2 from standard. - -:- expand_atom('$LOGTALKUSER/configs/xsb.config', Config), reconsult(Config). -:- expand_atom('$LOGTALKHOME/integration/logtalk_comp_xsbmt.pl', Compiler), reconsult(Compiler). -:- expand_atom('$LOGTALKUSER/libpaths/libpaths.pl', Libpaths), reconsult(Libpaths). diff --git a/Logtalk/integration/logtalk_yap.pl b/Logtalk/integration/logtalk_yap.pl deleted file mode 100644 index f03a02a08..000000000 --- a/Logtalk/integration/logtalk_yap.pl +++ /dev/null @@ -1,14 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- reconsult('$LOGTALKUSER/configs/yap.config'). -:- reconsult('$LOGTALKHOME/compiler/logtalk.pl'). -:- reconsult('$LOGTALKUSER/libpaths/libpaths.pl'). diff --git a/Logtalk/integration/plclgt.sh b/Logtalk/integration/plclgt.sh deleted file mode 100755 index 0c36fb0bf..000000000 --- a/Logtalk/integration/plclgt.sh +++ /dev/null @@ -1,60 +0,0 @@ -#/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -if ! [ "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME should be defined first, pointing" - echo "to your Logtalk installation directory!" - echo "Trying the default locations for the Logtalk installation..." - if [ -d "/usr/local/share/logtalk" ]; then - LOGTALKHOME=/usr/local/share/logtalk - echo "... using Logtalk installation found at /usr/local/share/logtalk" - elif [ -d "/usr/share/logtalk" ]; then - LOGTALKHOME=/usr/share/logtalk - echo "... using Logtalk installation found at /usr/share/logtalk" - elif [ -d "/opt/local/share/logtalk" ]; then - LOGTALKHOME=/opt/local/share/logtalk - echo "... using Logtalk installation found at /opt/local/share/logtalk" - elif [ -d "/opt/share/logtalk" ]; then - LOGTALKHOME=/opt/share/logtalk - echo "... using Logtalk installation found at /opt/share/logtalk" - else - echo "... unable to locate Logtalk installation directory!" - echo - exit 1 - fi - echo -elif ! [ -d "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME points to a non-existing directory!" - echo "Its current value is: $LOGTALKHOME" - echo "The variable must be set to your Logtalk installation directory!" - echo - exit 1 -fi -export LOGTALKHOME - -if ! [ "$LOGTALKUSER" ]; then - echo "The environment variable LOGTALKUSER should be defined first, pointing" - echo "to your Logtalk user directory!" - echo "Trying the default location for the Logtalk user directory..." - export LOGTALKUSER=$HOME/logtalk - if [ -d "$LOGTALKUSER" ]; then - echo "... using Logtalk user directory found at $LOGTALKUSER" - else - echo "... Logtalk user directory not found at default location. Creating a" - echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" - cplgtdirs - fi -elif ! [ -d "$LOGTALKUSER" ]; then - echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" - echo "by running the \"cplgtdirs\" shell script:" - cplgtdirs -fi -echo - -exec "$PLC"/plc -h 2048k -l 1024k -g 2048k -e "(consult('$LOGTALKHOME/integration/logtalk_plc.pl'), '\$root')." "$@" diff --git a/Logtalk/integration/qplgt.sh b/Logtalk/integration/qplgt.sh deleted file mode 100755 index 06054a84e..000000000 --- a/Logtalk/integration/qplgt.sh +++ /dev/null @@ -1,60 +0,0 @@ -#/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -if ! [ "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME should be defined first, pointing" - echo "to your Logtalk installation directory!" - echo "Trying the default locations for the Logtalk installation..." - if [ -d "/usr/local/share/logtalk" ]; then - LOGTALKHOME=/usr/local/share/logtalk - echo "... using Logtalk installation found at /usr/local/share/logtalk" - elif [ -d "/usr/share/logtalk" ]; then - LOGTALKHOME=/usr/share/logtalk - echo "... using Logtalk installation found at /usr/share/logtalk" - elif [ -d "/opt/local/share/logtalk" ]; then - LOGTALKHOME=/opt/local/share/logtalk - echo "... using Logtalk installation found at /opt/local/share/logtalk" - elif [ -d "/opt/share/logtalk" ]; then - LOGTALKHOME=/opt/share/logtalk - echo "... using Logtalk installation found at /opt/share/logtalk" - else - echo "... unable to locate Logtalk installation directory!" - echo - exit 1 - fi - echo -elif ! [ -d "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME points to a non-existing directory!" - echo "Its current value is: $LOGTALKHOME" - echo "The variable must be set to your Logtalk installation directory!" - echo - exit 1 -fi -export LOGTALKHOME - -if ! [ "$LOGTALKUSER" ]; then - echo "The environment variable LOGTALKUSER should be defined first, pointing" - echo "to your Logtalk user directory!" - echo "Trying the default location for the Logtalk user directory..." - export LOGTALKUSER=$HOME/logtalk - if [ -d "$LOGTALKUSER" ]; then - echo "... using Logtalk user directory found at $LOGTALKUSER" - else - echo "... Logtalk user directory not found at default location. Creating a" - echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" - cplgtdirs - fi -elif ! [ -d "$LOGTALKUSER" ]; then - echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" - echo "by running the \"cplgtdirs\" shell script:" - cplgtdirs -fi -echo - -exec qp -s 3072 -d 1024 -h 2048 -g "['$LOGTALKHOME/integration/logtalk_qp.pl']." "$@" diff --git a/Logtalk/integration/sicstuslgt.sh b/Logtalk/integration/sicstuslgt.sh deleted file mode 100755 index 42c2a6953..000000000 --- a/Logtalk/integration/sicstuslgt.sh +++ /dev/null @@ -1,64 +0,0 @@ -#/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -if ! [ "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME should be defined first, pointing" - echo "to your Logtalk installation directory!" - echo "Trying the default locations for the Logtalk installation..." - if [ -d "/usr/local/share/logtalk" ]; then - LOGTALKHOME=/usr/local/share/logtalk - echo "... using Logtalk installation found at /usr/local/share/logtalk" - elif [ -d "/usr/share/logtalk" ]; then - LOGTALKHOME=/usr/share/logtalk - echo "... using Logtalk installation found at /usr/share/logtalk" - elif [ -d "/opt/local/share/logtalk" ]; then - LOGTALKHOME=/opt/local/share/logtalk - echo "... using Logtalk installation found at /opt/local/share/logtalk" - elif [ -d "/opt/share/logtalk" ]; then - LOGTALKHOME=/opt/share/logtalk - echo "... using Logtalk installation found at /opt/share/logtalk" - else - echo "... unable to locate Logtalk installation directory!" - echo - exit 1 - fi - echo -elif ! [ -d "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME points to a non-existing directory!" - echo "Its current value is: $LOGTALKHOME" - echo "The variable must be set to your Logtalk installation directory!" - echo - exit 1 -fi -export LOGTALKHOME - -if ! [ "$LOGTALKUSER" ]; then - echo "The environment variable LOGTALKUSER should be defined first, pointing" - echo "to your Logtalk user directory!" - echo "Trying the default location for the Logtalk user directory..." - export LOGTALKUSER=$HOME/logtalk - if [ -d "$LOGTALKUSER" ]; then - echo "... using Logtalk user directory found at $LOGTALKUSER" - else - echo "... Logtalk user directory not found at default location. Creating a" - echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" - cplgtdirs - fi -elif ! [ -d "$LOGTALKUSER" ]; then - echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" - echo "by running the \"cplgtdirs\" shell script:" - cplgtdirs -fi -echo - -if sicstus -f --goal "halt." 2>&1 | grep "SICStus 4" 2>&1 >/dev/null; then - exec sicstus -l "$LOGTALKHOME/integration/logtalk_sicstus4.pl" "$@" -else - exec sicstus -l "$LOGTALKHOME/integration/logtalk_sicstus3.pl" "$@" -fi diff --git a/Logtalk/integration/swilgt.sh b/Logtalk/integration/swilgt.sh deleted file mode 100755 index 01bfd7a98..000000000 --- a/Logtalk/integration/swilgt.sh +++ /dev/null @@ -1,68 +0,0 @@ -#/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -if ! [ "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME should be defined first, pointing" - echo "to your Logtalk installation directory!" - echo "Trying the default locations for the Logtalk installation..." - if [ -d "/usr/local/share/logtalk" ]; then - LOGTALKHOME=/usr/local/share/logtalk - echo "... using Logtalk installation found at /usr/local/share/logtalk" - elif [ -d "/usr/share/logtalk" ]; then - LOGTALKHOME=/usr/share/logtalk - echo "... using Logtalk installation found at /usr/share/logtalk" - elif [ -d "/opt/local/share/logtalk" ]; then - LOGTALKHOME=/opt/local/share/logtalk - echo "... using Logtalk installation found at /opt/local/share/logtalk" - elif [ -d "/opt/share/logtalk" ]; then - LOGTALKHOME=/opt/share/logtalk - echo "... using Logtalk installation found at /opt/share/logtalk" - else - echo "... unable to locate Logtalk installation directory!" - echo - exit 1 - fi - echo -elif ! [ -d "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME points to a non-existing directory!" - echo "Its current value is: $LOGTALKHOME" - echo "The variable must be set to your Logtalk installation directory!" - echo - exit 1 -fi -export LOGTALKHOME - -if ! [ "$LOGTALKUSER" ]; then - echo "The environment variable LOGTALKUSER should be defined first, pointing" - echo "to your Logtalk user directory!" - echo "Trying the default location for the Logtalk user directory..." - export LOGTALKUSER=$HOME/logtalk - if [ -d "$LOGTALKUSER" ]; then - echo "... using Logtalk user directory found at $LOGTALKUSER" - else - echo "... Logtalk user directory not found at default location. Creating a" - echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" - cplgtdirs - fi -elif ! [ -d "$LOGTALKUSER" ]; then - echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" - echo "by running the \"cplgtdirs\" shell script:" - cplgtdirs -fi -echo - -if pl -t halt 2>&1 | grep "SWI-Prolog"; then - exec pl -f "$LOGTALKHOME/integration/logtalk_swi.pl" "$@" -elif swipl -t halt 2>&1 | grep "SWI-Prolog"; then - exec swipl -f "$LOGTALKHOME/integration/logtalk_swi.pl" "$@" -else case $( uname -s ) in - Darwin ) exec swipl -f "$LOGTALKHOME/integration/logtalk_swi.pl" "$@";; - * ) exec pl -f "$LOGTALKHOME/integration/logtalk_swi.pl" "$@";; -esac -fi diff --git a/Logtalk/integration/xsblgt.sh b/Logtalk/integration/xsblgt.sh deleted file mode 100755 index 421de7fc3..000000000 --- a/Logtalk/integration/xsblgt.sh +++ /dev/null @@ -1,60 +0,0 @@ -#/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -if ! [ "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME should be defined first, pointing" - echo "to your Logtalk installation directory!" - echo "Trying the default locations for the Logtalk installation..." - if [ -d "/usr/local/share/logtalk" ]; then - LOGTALKHOME=/usr/local/share/logtalk - echo "... using Logtalk installation found at /usr/local/share/logtalk" - elif [ -d "/usr/share/logtalk" ]; then - LOGTALKHOME=/usr/share/logtalk - echo "... using Logtalk installation found at /usr/share/logtalk" - elif [ -d "/opt/local/share/logtalk" ]; then - LOGTALKHOME=/opt/local/share/logtalk - echo "... using Logtalk installation found at /opt/local/share/logtalk" - elif [ -d "/opt/share/logtalk" ]; then - LOGTALKHOME=/opt/share/logtalk - echo "... using Logtalk installation found at /opt/share/logtalk" - else - echo "... unable to locate Logtalk installation directory!" - echo - exit 1 - fi - echo -elif ! [ -d "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME points to a non-existing directory!" - echo "Its current value is: $LOGTALKHOME" - echo "The variable must be set to your Logtalk installation directory!" - echo - exit 1 -fi -export LOGTALKHOME - -if ! [ "$LOGTALKUSER" ]; then - echo "The environment variable LOGTALKUSER should be defined first, pointing" - echo "to your Logtalk user directory!" - echo "Trying the default location for the Logtalk user directory..." - export LOGTALKUSER=$HOME/logtalk - if [ -d "$LOGTALKUSER" ]; then - echo "... using Logtalk user directory found at $LOGTALKUSER" - else - echo "... Logtalk user directory not found at default location. Creating a" - echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" - cplgtdirs - fi -elif ! [ -d "$LOGTALKUSER" ]; then - echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" - echo "by running the \"cplgtdirs\" shell script:" - cplgtdirs -fi -echo - -exec xsb -l -e "['$LOGTALKUSER/configs/xsb.config', '$LOGTALKHOME/compiler/logtalk.pl', '$LOGTALKUSER/libpaths/libpaths.pl']." "$@" diff --git a/Logtalk/integration/xsbmtlgt.sh b/Logtalk/integration/xsbmtlgt.sh deleted file mode 100755 index 41cbefb02..000000000 --- a/Logtalk/integration/xsbmtlgt.sh +++ /dev/null @@ -1,60 +0,0 @@ -#/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -if ! [ "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME should be defined first, pointing" - echo "to your Logtalk installation directory!" - echo "Trying the default locations for the Logtalk installation..." - if [ -d "/usr/local/share/logtalk" ]; then - LOGTALKHOME=/usr/local/share/logtalk - echo "... using Logtalk installation found at /usr/local/share/logtalk" - elif [ -d "/usr/share/logtalk" ]; then - LOGTALKHOME=/usr/share/logtalk - echo "... using Logtalk installation found at /usr/share/logtalk" - elif [ -d "/opt/local/share/logtalk" ]; then - LOGTALKHOME=/opt/local/share/logtalk - echo "... using Logtalk installation found at /opt/local/share/logtalk" - elif [ -d "/opt/share/logtalk" ]; then - LOGTALKHOME=/opt/share/logtalk - echo "... using Logtalk installation found at /opt/share/logtalk" - else - echo "... unable to locate Logtalk installation directory!" - echo - exit 1 - fi - echo -elif ! [ -d "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME points to a non-existing directory!" - echo "Its current value is: $LOGTALKHOME" - echo "The variable must be set to your Logtalk installation directory!" - echo - exit 1 -fi -export LOGTALKHOME - -if ! [ "$LOGTALKUSER" ]; then - echo "The environment variable LOGTALKUSER should be defined first, pointing" - echo "to your Logtalk user directory!" - echo "Trying the default location for the Logtalk user directory..." - export LOGTALKUSER=$HOME/logtalk - if [ -d "$LOGTALKUSER" ]; then - echo "... using Logtalk user directory found at $LOGTALKUSER" - else - echo "... Logtalk user directory not found at default location. Creating a" - echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" - cplgtdirs - fi -elif ! [ -d "$LOGTALKUSER" ]; then - echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" - echo "by running the \"cplgtdirs\" shell script:" - cplgtdirs -fi -echo - -exec xsb-mt --shared_predicates -l -e "['$LOGTALKHOME/integration/logtalk_xsbmt.pl']." "$@" diff --git a/Logtalk/integration/yaplgt.sh b/Logtalk/integration/yaplgt.sh deleted file mode 100755 index 87ba86419..000000000 --- a/Logtalk/integration/yaplgt.sh +++ /dev/null @@ -1,60 +0,0 @@ -#/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -if ! [ "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME should be defined first, pointing" - echo "to your Logtalk installation directory!" - echo "Trying the default locations for the Logtalk installation..." - if [ -d "/usr/local/share/logtalk" ]; then - LOGTALKHOME=/usr/local/share/logtalk - echo "... using Logtalk installation found at /usr/local/share/logtalk" - elif [ -d "/usr/share/logtalk" ]; then - LOGTALKHOME=/usr/share/logtalk - echo "... using Logtalk installation found at /usr/share/logtalk" - elif [ -d "/opt/local/share/logtalk" ]; then - LOGTALKHOME=/opt/local/share/logtalk - echo "... using Logtalk installation found at /opt/local/share/logtalk" - elif [ -d "/opt/share/logtalk" ]; then - LOGTALKHOME=/opt/share/logtalk - echo "... using Logtalk installation found at /opt/share/logtalk" - else - echo "... unable to locate Logtalk installation directory!" - echo - exit 1 - fi - echo -elif ! [ -d "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME points to a non-existing directory!" - echo "Its current value is: $LOGTALKHOME" - echo "The variable must be set to your Logtalk installation directory!" - echo - exit 1 -fi -export LOGTALKHOME - -if ! [ "$LOGTALKUSER" ]; then - echo "The environment variable LOGTALKUSER should be defined first, pointing" - echo "to your Logtalk user directory!" - echo "Trying the default location for the Logtalk user directory..." - export LOGTALKUSER=$HOME/logtalk - if [ -d "$LOGTALKUSER" ]; then - echo "... using Logtalk user directory found at $LOGTALKUSER" - else - echo "... Logtalk user directory not found at default location. Creating a" - echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" - cplgtdirs - fi -elif ! [ -d "$LOGTALKUSER" ]; then - echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" - echo "by running the \"cplgtdirs\" shell script:" - cplgtdirs -fi -echo - -exec yap -s 49152 -h 16384 -t 1024 -l "$LOGTALKHOME/integration/logtalk_yap.pl" "$@" diff --git a/Logtalk/libpaths/NOTES.txt b/Logtalk/libpaths/NOTES.txt deleted file mode 100644 index 37a966b6f..000000000 --- a/Logtalk/libpaths/NOTES.txt +++ /dev/null @@ -1,61 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - -This folder contains a Prolog file, "libpaths.pl", which, when loaded, -defines the library paths for the Logtalk standard library and for all -the supplied examples. You may customize this file by adding the paths -to your own "libraries" in order to easily load your own source code. - -In order to easily compile and load library and example source files using -the notation (), you will need to load the "libpaths.pl" -into your Prolog compiler after loading the Logtalk compiler/runtime. - -You might need to edit the "libpaths.pl" file in order to adapt it to -reflect your Logtalk installation, Prolog compiler, and operating-system -requirements (for example, some Prolog compilers do not accept or expand -environment variables occurring on paths). - -As defined, the provided "libpaths.pl" file is already compatible with -some of the most popular Prolog compilers, running on MacOS X, Linux, -Windows, Unix, and Unix-like operating-systems. - -The Prolog integration scripts, found on the "integration" directory, -automatically load the copy of the "libpaths.pl" file from the Logtalk -end-user directory created by the "scripts/cplgtdirs.*" scripts. See the -"INSTALL.txt" and "scripts/NOTES.txt" files for more details. Note that -some Prolog compilers do not support the () notation. -See the "configs/NOTES.txt" file for details. - -The somehow contrived code found on the "libpaths.pl" file is needed to -ensure compatibility with both the ISO Prolog standard and with most -Prolog compilers. The code could be greatly simplified by using a multifile -predicate directive for the library path dynamic predicate. Unfortunately, -not all Prolog compilers support multifile predicates. - -Prolog compilers that are expected to be compatible with the provided -"libpaths.pl" file as is, across operating-systems: - - * B-Prolog - * CIAO - * CxProlog - * ECLiPSe - * GNU-Prolog - * K-Prolog - * Qu-Prolog - * SICStus Prolog - * SWI-Prolog - * YAP - * XSB - -Prolog compilers that imply editing the provided "libpaths.pl" file due -to the lack of support for expanding environment variables on paths: - - * Amzi! Prolog - * IF/Prolog - * JIProlog - -Feedback on other Prolog compilers is most appreciated. diff --git a/Logtalk/libpaths/libpaths.pl b/Logtalk/libpaths/libpaths.pl deleted file mode 100644 index aa6feeb99..000000000 --- a/Logtalk/libpaths/libpaths.pl +++ /dev/null @@ -1,75 +0,0 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Logtalk - Open source object-oriented logic programming language -% Release 2.30.7 -% -% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -:- initialization( - (assertz(logtalk_library_path(lgtuser, '$LOGTALKUSER/')), - assertz(logtalk_library_path(contributions, lgtuser('contributions/'))), - assertz(logtalk_library_path(examples, lgtuser('examples/'))), - assertz(logtalk_library_path(library, lgtuser('library/'))), - assertz(logtalk_library_path(aliases, examples('aliases/'))), - assertz(logtalk_library_path(assignvars, examples('assignvars/'))), - assertz(logtalk_library_path(barriers, threads('barriers/'))), - assertz(logtalk_library_path(benchmarks, examples('benchmarks/'))), - assertz(logtalk_library_path(birds, examples('birds/'))), - assertz(logtalk_library_path(birthdays, threads('birthdays/'))), - assertz(logtalk_library_path(blackboard, threads('blackboard/'))), - assertz(logtalk_library_path(bottles, examples('bottles/'))), - assertz(logtalk_library_path(bricks, examples('bricks/'))), - assertz(logtalk_library_path(buffer, threads('buffer/'))), - assertz(logtalk_library_path(classvars, examples('classvars/'))), - assertz(logtalk_library_path(dcgs, examples('dcgs/'))), - assertz(logtalk_library_path(diamonds, examples('diamonds/'))), - assertz(logtalk_library_path(dynpred, examples('dynpred/'))), - assertz(logtalk_library_path(encodings, examples('encodings/'))), - assertz(logtalk_library_path(engines, examples('engines/'))), - assertz(logtalk_library_path(errors, examples('errors/'))), - assertz(logtalk_library_path(expansion, examples('expansion/'))), - assertz(logtalk_library_path(functions, threads('functions/'))), - assertz(logtalk_library_path(hello_world, examples('hello_world/'))), - assertz(logtalk_library_path(hooks, examples('hooks/'))), - assertz(logtalk_library_path(inheritance, examples('inheritance/'))), - assertz(logtalk_library_path(instmethods, examples('instmethods/'))), - assertz(logtalk_library_path(lo_planner, examples('lo/planner/'))), - assertz(logtalk_library_path(lo_travellers, examples('lo/travellers/'))), - assertz(logtalk_library_path(logic, examples('logic/'))), - assertz(logtalk_library_path(lpa_faults, examples('lpa/faults/'))), - assertz(logtalk_library_path(lpa_timetables, examples('lpa/timetables/'))), - assertz(logtalk_library_path(metainterpreters, examples('metainterpreters/'))), - assertz(logtalk_library_path(metapredicates, examples('metapredicates/'))), - assertz(logtalk_library_path(mi, examples('mi/'))), - assertz(logtalk_library_path(miscellaneous, examples('miscellaneous/'))), - assertz(logtalk_library_path(modules, examples('modules/'))), - assertz(logtalk_library_path(msglog, examples('msglog/'))), - assertz(logtalk_library_path(nondet, threads('nondet/'))), - assertz(logtalk_library_path(operators, examples('operators/'))), - assertz(logtalk_library_path(parametric, examples('parametric/'))), - assertz(logtalk_library_path(philosophers, threads('philosophers/'))), - assertz(logtalk_library_path(poem, examples('poem/'))), - assertz(logtalk_library_path(points, examples('points/'))), - assertz(logtalk_library_path(polygons, examples('polygons/'))), - assertz(logtalk_library_path(primes, threads('primes/'))), - assertz(logtalk_library_path(profiling, examples('profiling/'))), - assertz(logtalk_library_path(proxies, examples('proxies/'))), - assertz(logtalk_library_path(puzzles, examples('puzzles/'))), - assertz(logtalk_library_path(reflection, examples('reflection/'))), - assertz(logtalk_library_path(relations, examples('relations/'))), - assertz(logtalk_library_path(roots, examples('roots/'))), - assertz(logtalk_library_path(searching, examples('searching/'))), - assertz(logtalk_library_path(shapes_ch, examples('shapes/ch/'))), - assertz(logtalk_library_path(shapes_ph, examples('shapes/ph/'))), - assertz(logtalk_library_path(sicstus, examples('sicstus/'))), - assertz(logtalk_library_path(sorting, threads('sorting/'))), - assertz(logtalk_library_path(sync, threads('sync/'))), - assertz(logtalk_library_path(symdiff, examples('symdiff/'))), - assertz(logtalk_library_path(tabling, examples('tabling/'))), - assertz(logtalk_library_path(tak, threads('tak/'))), - assertz(logtalk_library_path(testing, examples('testing/'))), - assertz(logtalk_library_path(threads, examples('threads/'))), - assertz(logtalk_library_path(viewpoints, examples('viewpoints/'))))). diff --git a/Logtalk/library/NOTES.txt b/Logtalk/library/NOTES.txt deleted file mode 100644 index 16bc54322..000000000 --- a/Logtalk/library/NOTES.txt +++ /dev/null @@ -1,80 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This folder contains some useful objects, categories, and protocols. - -To load a group of objects, protocols, and categories in this library -either change your Prolog working directory to this folder and then -compile and load the corresponding loader utility file or simply use -the notation library() as argument for the compiling and -loading predicates. For example: - - | ?- logtalk_load(library(random_loader)). - -Currently, there are nine groups of entities defined, each one with its -own loader and notes files: - - dates - dates_loader.lgt - dates.notes - - debugging - debugging_loader.lgt - debugging.notes - - dependents - dependents_loader.lgt - dependents.notes - - events - events_loader.lgt - events.notes - - hierarchies - hierarchies_loader.lgt - hierarchies.notes - - lgtunit - lgtunit.lgt - lgtunit.notes - - metapredicates - metapredicates_loader.lgt - metapredicates.notes - - random - random_loader.lgt - random.notes - - types - types_loader.lgt - types.notes - -There is also a file named all_loader.lgt that will load all entities in the -groups listed above. Simply type the goal: - - | ?- logtalk_load(library(all_loader)). - -Specific notes about each group of objects, categories, and protocols can be -found in the corresponding *.notes files. - -Some of the files contained in this directory represent work in progress and -are not loaded by default by any loader utility file. - -Some of the code in this library is based on public domain Prolog code, in -particular, code adopted from the Edinburgh Prolog library. The definition -of predicate reverse/2 in object list is from Richard O'Keefe and can be found -in its book "The Craft of Prolog". - -By default, compiling any group of entities described above generates a .xml -documenting file for each compiled entity (object, category, or protocol). -See the xml sub-directory for instructions on how to browse the .xml files -for on-line reading or how to convert the files to a print-ready format such -as PDF. - -All source files are formatted using four-space tabs. diff --git a/Logtalk/library/SCRIPT b/Logtalk/library/SCRIPT deleted file mode 100644 index 551319843..000000000 --- a/Logtalk/library/SCRIPT +++ /dev/null @@ -1,32 +0,0 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.27.1 - -Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved. -================================================================= - - -| ?- meta::apply(current_object, [meta]). - -yes - - -| ?- meta::succeeds(integer, [1, 2, 3]). - -yes - - -| ?- meta::map(object_property, [meta, user], Out). - -Out = [static,built_in] ? ; - -Out = [static,static] ? ; - -no - - -| ?- meta::filter(integer, [1, a, X, b(_), 4, 7.8, 'AAA'], Integers). - -Integers = [1,4] - -yes diff --git a/Logtalk/library/SCRIPT.txt b/Logtalk/library/SCRIPT.txt deleted file mode 100644 index b8b21047a..000000000 --- a/Logtalk/library/SCRIPT.txt +++ /dev/null @@ -1,25 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -| ?- meta::succeeds(integer, [1, 2, 3]). - -yes - - -| ?- meta::map(object_property, [meta, user], Out). - -Out = [static,built_in] ? ; -Out = [static,static] ? ; -no - - -| ?- meta::filter(integer, [1, a, X, b(_), 4, 7.8, 'AAA'], Integers). - -Integers = [1,4] - -yes diff --git a/Logtalk/library/after_event_registry.lgt b/Logtalk/library/after_event_registry.lgt deleted file mode 100644 index 09bc6cada..000000000 --- a/Logtalk/library/after_event_registry.lgt +++ /dev/null @@ -1,31 +0,0 @@ - -:- object(after_event_registry, - implements(event_registryp)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'After events registry predicates.']). - - monitors(Monitors) :- - findall(Monitor, current_event(after, _, _, _, Monitor), List), - {sort(List, Monitors)}. - - monitored(Objects) :- - findall(Object, current_event(after, Object, _, _, _), List), - {sort(List, Objects)}. - - monitor(Object, Message, Sender, Monitor) :- - current_event(after, Object, Message, Sender, Monitor). - - set_monitor(Object, Message, Sender, Monitor) :- - define_events(after, Object, Message, Sender, Monitor). - - del_monitors(Object, Message, Sender, Monitor) :- - abolish_events(after, Object, Message, Sender, Monitor). - - del_monitors :- - abolish_events(after, _, _, _, _). - -:- end_object. diff --git a/Logtalk/library/all.notes b/Logtalk/library/all.notes deleted file mode 100644 index ec990a23e..000000000 --- a/Logtalk/library/all.notes +++ /dev/null @@ -1,13 +0,0 @@ - -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -The all_loader.lgt file will load all the entities loaded by the other -loader files: - - | ?- logtalk_load(all_loader). diff --git a/Logtalk/library/all_loader.lgt b/Logtalk/library/all_loader.lgt deleted file mode 100644 index da308caa5..000000000 --- a/Logtalk/library/all_loader.lgt +++ /dev/null @@ -1,12 +0,0 @@ - -:- initialization( - logtalk_load([ - library(dates_loader), - library(events_loader), - library(debugging_loader), - library(dependents_loader), - library(hierarchies_loader), - library(metapredicates_loader), - library(random_loader), - library(types_loader)], - [reload(skip)])). % allow for static binding diff --git a/Logtalk/library/assignvars.lgt b/Logtalk/library/assignvars.lgt deleted file mode 100644 index d6f661d21..000000000 --- a/Logtalk/library/assignvars.lgt +++ /dev/null @@ -1,103 +0,0 @@ - -/* -This file contains an adaptation to Logtalk of code for logical assignment -of Prolog terms developed by Nobukuni Kino. For more information, please -consult the URL http://www.kprolog.com/en/logical_assignment/ - -As a derivative work, this file is licensed under the Open Software License -version 2.1 (http://opensource.org/licenses/osl-2.1.php). -*/ - - -:-op(100, xfx, '<='). -:-op(100, xfx, '=>'). - - -:- category(assignvars). - - :- info([ - version is 1.0, - author is 'Nobukuni Kino and Paulo Moura', - date is 2005/1/7, - comment is 'Assignable variables (supporting logical, backtracable assignement of non-variable terms).']). - - :- public(assignable/1). - :- mode(assignable(-assignvar), one). - :- info(assignable/1, [ - comment is 'Makes Variable an assignable variable. Initial state will be empty.', - argnames is ['Variable'], - exceptions is [ - 'Variable is not a variable' - type_error(variable, 'Variable')]]). - - :- public(assignable/2). - :- mode(assignable(-assignvar, @nonvar), one). - :- info(assignable/2, [ - comment is 'Makes Variable an assignable variable and sets its initial state to Value.', - argnames is ['Variable', 'Value'], - exceptions is [ - 'Variable is not a variable' - type_error(variable, 'Variable'), - 'Value is not instantiated' - instantiation_error]]). - - :- public((<=)/2). - :- mode(<=(?assignvar, @nonvar), one). - :- info((<=)/2, [ - comment is 'Sets the state of the assignable variable Variable to Value (initializing the variable if needed).', - argnames is ['Variable', 'Value'], - exceptions is [ - 'Value is not instantiated' - instantiation_error]]). - - :- public((=>)/2). - :- mode(=>(+assignvar, ?nonvar), zero_or_one). - :- info((=>)/2, [ - comment is 'Unifies Value with the current state of the assignable variable Variable.', - argnames is ['Variable', 'Value'], - exceptions is [ - 'Variable is not instantiated' - instantiation_error]]). - - :-op(100, xfx, <=). - :-op(100, xfx, =>). - - assignable(Assig) :- - nonvar(Assig), - self(Self), - sender(Sender), - throw(error(type_error(variable, Assig), Self::assignable(Assig), Sender)). - assignable([_| _]). - - assignable(Assig, Init) :- - nonvar(Assig), - self(Self), - sender(Sender), - throw(error(type_error(variable, Assig), Self::assignable(Assig, Init), Sender)). - assignable(Assig, Init) :- - var(Init), - self(Self), - sender(Sender), - throw(error(instantiation_error, Self::assignable(Assig, Init), Sender)). - assignable([_, Init| _], Init). - - Assig <= Value :- - var(Value), - self(Self), - sender(Sender), - throw(error(instantiation_error, Self::Assig <= Value, Sender)). - - [_| Tail] <= Value :- - nonvar(Tail) -> - Tail <= Value - ; - Tail = [Value| _]. - - Assig => Value :- - var(Assig), - self(Self), - sender(Sender), - throw(error(instantiation_error, Self::Assig => Value, Sender)). - - [Current| Tail] => Value :- - nonvar(Tail) -> - Tail => Value - ; - Current = Value. - -:- end_category. diff --git a/Logtalk/library/atom.lgt b/Logtalk/library/atom.lgt deleted file mode 100644 index 6526fb4f7..000000000 --- a/Logtalk/library/atom.lgt +++ /dev/null @@ -1,14 +0,0 @@ - -:- object(atom, - extends(atomic)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Atom data type predicates.']). - - valid(Atom) :- - atom(Atom). - -:- end_object. diff --git a/Logtalk/library/atomic.lgt b/Logtalk/library/atomic.lgt deleted file mode 100644 index 25a77811f..000000000 --- a/Logtalk/library/atomic.lgt +++ /dev/null @@ -1,14 +0,0 @@ - -:- object(atomic, - extends(term)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Atomic data type predicates.']). - - valid(Atomic) :- - atomic(Atomic). - -:- end_object. diff --git a/Logtalk/library/attributes.lgt b/Logtalk/library/attributes.lgt deleted file mode 100644 index 90be91e00..000000000 --- a/Logtalk/library/attributes.lgt +++ /dev/null @@ -1,75 +0,0 @@ - -:- category(attributes). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Dynamic attributes dictionary.']). - - :- public(attribute/2). - :- mode(attribute(?nonvar, ?nonvar), zero_or_more). - :- info(attribute/2, - [comment is 'Returns, by backtracking, all pairs of attribute-values.', - argnames is ['Attribute', 'Value']]). - - :- public(attributes/1). - :- mode(attributes(-list), one). - :- info(attributes/1, - [comment is 'List of all pairs of attribute-values.', - argnames is ['Attributes']]). - - :- private(attribute_/2). - :- dynamic(attribute_/2). - :- mode(attribute_(?nonvar, ?nonvar), zero_or_more). - :- info(attribute_/2, - [comment is 'Stores attributes values.', - argnames is ['Attribute', 'Value']]). - - :- public(del_attribute/2). - :- mode(del_attribute(?nonvar, ?nonvar), zero_or_more). - :- info(del_attribute/2, - [comment is 'Deletes a matching attribute-value pair.', - argnames is ['Attribute', 'Value']]). - - :- public(del_attributes/2). - :- mode(del_attributes(@term, @term), one). - :- info(del_attributes/2, - [comment is 'Deletes all matching attribute-value pairs.', - argnames is ['Attribute', 'Value']]). - - :- public(set_attribute/2). - :- mode(set_attribute(+nonvar, +nonvar), one). - :- info(set_attribute/2, - [comment is 'Sets an attribute value.', - argnames is ['Attribute', 'Value']]). - - :- public(set_attributes/1). - :- mode(set_attributes(+list), one). - :- info(set_attributes/1, - [comment is 'Sets a list of attribute-value pairs.', - argnames is ['Attributes']]). - - attribute(Attribute, Value) :- - ::attribute_(Attribute, Value). - - attributes(Attributes) :- - findall(Attribute, ::attribute_(Attribute, _), Attributes). - - del_attribute(Attribute, Value) :- - ::retract(attribute_(Attribute, Value)). - - del_attributes(Attribute, Value) :- - ::retractall(attribute_(Attribute, Value)). - - set_attribute(Attribute, Value) :- - ::retractall(attribute_(Attribute, _)), - ::assertz(attribute_(Attribute, Value)). - - set_attributes([]). - set_attributes([Attribute-Value| Attributes]) :- - ::retractall(attribute_(Attribute, _)), - ::assertz(attribute_(Attribute, Value)), - set_attributes(Attributes). - -:- end_category. diff --git a/Logtalk/library/before_event_registry.lgt b/Logtalk/library/before_event_registry.lgt deleted file mode 100644 index 51b210e45..000000000 --- a/Logtalk/library/before_event_registry.lgt +++ /dev/null @@ -1,31 +0,0 @@ - -:- object(before_event_registry, - implements(event_registryp)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Before events registry predicates.']). - - monitors(Monitors) :- - findall(Monitor, current_event(before, _, _, _, Monitor), List), - {sort(List, Monitors)}. - - monitored(Objects) :- - findall(Object, current_event(before, Object, _, _, _), List), - {sort(List, Objects)}. - - monitor(Object, Message, Sender, Monitor) :- - current_event(before, Object, Message, Sender, Monitor). - - set_monitor(Object, Message, Sender, Monitor) :- - define_events(before, Object, Message, Sender, Monitor). - - del_monitors(Object, Message, Sender, Monitor) :- - abolish_events(before, Object, Message, Sender, Monitor). - - del_monitors :- - abolish_events(before, _, _, _, _). - -:- end_object. diff --git a/Logtalk/library/bintree.lgt b/Logtalk/library/bintree.lgt deleted file mode 100644 index b0d18314f..000000000 --- a/Logtalk/library/bintree.lgt +++ /dev/null @@ -1,114 +0,0 @@ - -:- object(bintree, - implements(dictionaryp), - extends(compound)). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2006/9/17, - comment is 'Dictionary protocol implemented using binary trees.']). - - :- private(map/4). - :- meta_predicate(map(*, *, *, ::)). - :- mode(map(+atom, +tree, -tree, -callable), zero_or_one). - - as_list(Tree, List) :- - as_list(Tree, [], List). - - as_list(t, List, List). - as_list(t(Key, Value, Left, Right), Acc, List) :- - as_list(Right, Acc, Acc2), - as_list(Left, [Key-Value| Acc2], List). - - empty(Tree) :- - Tree == t. - - insert(Key, Value, t, t(Key, Value, t, t)) :- - nonvar(Key). - insert(Key, Value, t(Key1, Value1, Left1, Right1), t(Key1, Value2, Left2, Right2)) :- - compare(Order, Key, Key1), - insert(Order, Key, Value, Key1, Value1, Left1, Right1, Value2, Left2, Right2). - - insert(=, _, Value, _, _, Left, Right, Value, Left, Right). - insert(<, Key, Value, _, Value1, Left1, Right, Value1, Left2, Right) :- - insert(Key, Value, Left1, Left2). - insert(>, Key, Value, _, Value1, Left, Right1, Value1, Left, Right2) :- - insert(Key, Value, Right1, Right2). - - insert_all([], Tree, Tree). - insert_all([Key-Value| Rest], Old, New) :- - insert(Key, Value, Old, Aux), - insert_all(Rest, Aux, New). - - lookup(Key, Value, Tree) :- - ( var(Key) -> - lookup_var(Key, Value, Tree) - ; lookup_nonvar(Key, Value, Tree) - ). - - lookup_nonvar(Key, Value, t(Key1, Value1, Left1, Right1)) :- - compare(Order, Key, Key1), - lookup_nonvar(Order, Key, Value, Value1, Left1, Right1). - - lookup_nonvar(=, _, Value, Value, _, _). - lookup_nonvar(<, Key, Value, _, Left, _) :- - lookup_nonvar(Key, Value, Left). - lookup_nonvar(<, Key, Value, _, _, Right) :- - lookup_nonvar(Key, Value, Right). - - lookup_var(Key, Value, t(_, _, Left, _)) :- - lookup_var(Key, Value, Left). - lookup_var(Key, Value, t(Key, Value,_,_)). - lookup_var(Key, Value, t(_, _, _, Right)) :- - lookup_var(Key, Value, Right). - - keys(Tree, Keys) :- - keys(Tree, [], Keys). - - keys(t, Keys, Keys). - keys(t(Key, _, Left, Right), Acc, Keys) :- - keys(Right, Acc, Acc2), - keys(Left, [Key| Acc2], Keys). - - delete(t, _, _, t). - delete(t(Key1, Value1, Left1, Right1), Key, Value, Out) :- - compare(Order, Key, Key1), - delete(Order, Key1, Value1, Left1, Right1, Key, Value, Out). - - delete(=, Key1, Value1, Left1, Right1, Key1, Value1, Out) :- - join(Left1, Right1, Out). - delete(<, Key1, Value1, Left1, Right1, Key, Value, t(Key1, Value1, Left2, Right1)) :- - delete(Left1, Key, Value, Left2). - delete(>, Key1, Value1, Left1, Right1, Key, Value, t(Key1, Value1, Left1, Right2)) :- - delete(Right1, Key, Value, Right2). - - join(t, Right, Right) :- - !. - join(Left, t, Left) :- - !. - join(t(Key, Value, Left, Right), Tree, t(Key, Value, Left, Right2)) :- - join(Right, Tree, Right2). - - map(Pred, Old, New) :- - map(Pred, Old, New, _). - - map(Pred, t(Key1, Value1, Left1, Right1), t(Key2, Value2, Left2, Right2), Goal) :- - Goal =.. [Pred, Key1-Value1, Key2-Value2], - once(Goal), - map(Pred, Left1, Left2, _), - map(Pred, Right1, Right2, _). - map(_, t, t, _). - - new(t). - - size(Dictionary, Size) :- - size(Dictionary, 0, Size). - - size(t, Size, Size). - size(t(_, _, Left, Right), Acc, Size) :- - size(Left, Acc, Acc2), - Acc3 is Acc2 + 1, - size(Right, Acc3, Size). - -:- end_object. diff --git a/Logtalk/library/callable.lgt b/Logtalk/library/callable.lgt deleted file mode 100644 index 402cf17b8..000000000 --- a/Logtalk/library/callable.lgt +++ /dev/null @@ -1,17 +0,0 @@ - -:- object(callable, - extends(term)). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2007/4/29, - comment is 'Callable term type predicates.']). - - valid(Callable) :- - ( atom(Callable) -> - true - ; compound(Callable) - ). - -:- end_object. diff --git a/Logtalk/library/character.lgt b/Logtalk/library/character.lgt deleted file mode 100644 index 750ebef02..000000000 --- a/Logtalk/library/character.lgt +++ /dev/null @@ -1,102 +0,0 @@ - -:- object(character, - implements(characterp), - extends(atom)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Character predicates.']). - - is_alpha('_'). - is_alpha(Char) :- - is_letter(Char). - - is_letter(Char) :- - is_lower_case(Char). - is_letter(Char) :- - is_upper_case(Char). - - is_alphanumeric(Char) :- - is_alpha(Char). - is_alphanumeric(Char) :- - is_dec_digit(Char). - - is_bin_digit(0). - is_bin_digit(1). - - is_octal_digit(Digit) :- - Digit @>= 0, - Digit @=< 7. - - is_dec_digit(Digit) :- - Digit @>= 0, - Digit @=< 9. - - is_hex_digit(Digit) :- - Digit @>= 0, - Digit @=< 9. - is_hex_digit(Digit) :- - Digit @>= 'A', - Digit @=< 'F'. - is_hex_digit(Digit) :- - Digit @>= a, - Digit @=< f. - - is_lower_case(Char) :- - Char @>= a, - Char @=< z. - - is_upper_case(Char) :- - Char @>= 'A', - Char @=< 'Z'. - - is_vowel(a). - is_vowel(e). - is_vowel(i). - is_vowel(o). - is_vowel(u). - is_vowel('A'). - is_vowel('E'). - is_vowel('I'). - is_vowel('O'). - is_vowel('U'). - - is_layout(' '). - - lower_upper(a, 'A'). - lower_upper(b, 'B'). - lower_upper(c, 'C'). - lower_upper(d, 'D'). - lower_upper(e, 'E'). - lower_upper(f, 'F'). - lower_upper(g, 'G'). - lower_upper(h, 'H'). - lower_upper(i, 'I'). - lower_upper(j, 'J'). - lower_upper(k, 'K'). - lower_upper(l, 'L'). - lower_upper(m, 'M'). - lower_upper(n, 'N'). - lower_upper(o, 'O'). - lower_upper(p, 'P'). - lower_upper(q, 'Q'). - lower_upper(r, 'R'). - lower_upper(s, 'S'). - lower_upper(t, 'T'). - lower_upper(u, 'U'). - lower_upper(v, 'V'). - lower_upper(w, 'W'). - lower_upper(x, 'X'). - lower_upper(y, 'Y'). - lower_upper(z, 'Z'). - lower_upper(Char, Char) :- - \+ (Char @>= a, Char @=< z), - \+ (Char @>= 'A', Char @=< 'Z'). - - valid(Character) :- - atom(Character), - atom_length(Character, 1). - -:- end_object. diff --git a/Logtalk/library/characterp.lgt b/Logtalk/library/characterp.lgt deleted file mode 100644 index 1049fd655..000000000 --- a/Logtalk/library/characterp.lgt +++ /dev/null @@ -1,84 +0,0 @@ - -:- protocol(characterp). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Character protocol.']). - - :- public(is_alphanumeric/1). - :- mode(is_alphanumeric(+char), zero_or_one). - :- info(is_alphanumeric/1, [ - comment is 'True if the argument is an alphanumeric character.', - argnames is ['Term']]). - - :- public(is_alpha/1). - :- mode(is_alpha(+char), zero_or_one). - :- info(is_alpha/1, [ - comment is 'True if the argument is a letter or an underscore.', - argnames is ['Term']]). - - :- public(is_letter/1). - :- mode(is_letter(+char), zero_or_one). - :- info(is_letter/1, [ - comment is 'True if the argument is a letter.', - argnames is ['Term']]). - - :- public(is_bin_digit/1). - :- mode(is_bin_digit(+char), zero_or_one). - :- info(is_bin_digit/1, [ - comment is 'True if the argument is a binary digit.', - argnames is ['Term']]). - - :- public(is_octal_digit/1). - :- mode(is_octal_digit(+char), zero_or_one). - :- info(is_octal_digit/1, [ - comment is 'True if the argument is an octal digit.', - argnames is ['Term']]). - - :- public(is_dec_digit/1). - :- mode(is_dec_digit(+char), zero_or_one). - :- info(is_dec_digit/1, [ - comment is 'True if the argument is a decimal digit.', - argnames is ['Term']]). - - :- public(is_hex_digit/1). - :- mode(is_hex_digit(+char), zero_or_one). - :- info(is_hex_digit/1, [ - comment is 'True if the argument is an hexadecimal digit.', - argnames is ['Term']]). - - :- public(is_lower_case/1). - :- mode(is_lower_case(+char), zero_or_one). - :- info(is_lower_case/1, [ - comment is 'True if the argument is a lower case letter.', - argnames is ['Term']]). - - :- public(is_upper_case/1). - :- mode(is_upper_case(+char), zero_or_one). - :- info(is_upper_case/1, [ - comment is 'True if the argument is a upper case letter.', - argnames is ['Term']]). - - :- public(is_vowel/1). - :- mode(is_vowel(+char), zero_or_one). - :- info(is_vowel/1, [ - comment is 'True if the argument is a vowel.', - argnames is ['Term']]). - - :- public(is_layout/1). - :- mode(is_layout(+char), zero_or_one). - :- info(is_layout/1, [ - comment is 'True if the argument is a layout character.', - argnames is ['Term']]). - - :- public(lower_upper/2). - :- mode(lower_upper(?char, ?char), zero_or_more). - :- mode(lower_upper(+char, ?char), zero_or_one). - :- mode(lower_upper(?char, +char), zero_or_one). - :- info(lower_upper/2, [ - comment is 'Converts between lower and upper case letters.', - argnames is ['Term1', 'Term2']]). - -:- end_protocol. diff --git a/Logtalk/library/class_hierarchy.lgt b/Logtalk/library/class_hierarchy.lgt deleted file mode 100644 index 30b5960f5..000000000 --- a/Logtalk/library/class_hierarchy.lgt +++ /dev/null @@ -1,176 +0,0 @@ - -:- category(class_hierarchy, - implements(class_hierarchyp)). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2006/2/20, - comment is 'Class hierarchy predicates.']). - - class(Class) :- - self(Self), - instantiates_class(Self, Class). - - classes(Classes) :- - self(Self), - findall(Class, instantiates_class(Self, Class), Classes). - - ancestor(Ancestor) :- - self(Self), - ancestor(Self, Ancestor). - - ancestor(Self, Ancestor) :- - instantiates_class(Self, Ancestor). - ancestor(Self, Ancestor) :- - instantiates_class(Self, Class), - superclass(Class, Ancestor). - - ancestors(Ancestors) :- - self(Self), - findall(Ancestor, ancestor(Self, Ancestor), Ancestors). - - instance(Instance) :- - self(Self), - instantiates_class(Instance, Self). - - instances(Instances) :- - self(Self), - findall(Instance, instantiates_class(Instance, Self), Instances). - - subclass(Subclass) :- - self(Self), - specializes_class(Subclass, Self). - - subclasses(Subclasses) :- - self(Self), - findall(Subclass, specializes_class(Subclass, Self), Subclasses). - - superclass(Superclass) :- - self(Self), - superclass(Self, Superclass). - - superclass(Self, Superclass) :- - specializes_class(Self, Superclass). - superclass(Self, Superclass) :- - specializes_class(Self, Class), - superclass(Class, Superclass). - - superclasses(Superclasses) :- - self(Self), - findall(Superclass, specializes_class(Self, Superclass), Superclasses). - - leaf(Leaf) :- - self(Self), - leaf(Self, Leaf). - - leaf(Self, Leaf) :- - instantiates_class(Leaf, Self), - \+ instantiates_class(_, Leaf), - \+ specializes_class(_, Leaf). - leaf(Self, Leaf) :- - specializes_class(Leaf, Self), - \+ instantiates_class(_, Leaf), - \+ specializes_class(_, Leaf). - leaf(Self, Leaf) :- - specializes_class(Subclass, Self), - leaf(Subclass, Leaf). - - leaves(Leaves) :- - self(Self), - ( setof(Leaf, leaf(Self, Leaf), Leaves) -> - true - ; Leaves = [] - ). - - leaf_instance(Leaf) :- - self(Self), - leaf_instance(Self, Leaf). - - leaf_instance(Self, Leaf) :- - instantiates_class(Leaf, Self), - \+ instantiates_class(_, Leaf). - leaf_instance(Self, Leaf) :- - specializes_class(Subclass, Self), - leaf_instance(Subclass, Leaf). - - leaf_instances(Leaves) :- - self(Self), - ( setof(Leaf, leaf_instance(Self, Leaf), Leaves) -> - true - ; Leaves = [] - ). - - leaf_class(Leaf) :- - self(Self), - leaf_class(Self, Leaf). - - leaf_class(Self, Leaf) :- - specializes_class(Leaf, Self), - \+ specializes_class(_, Leaf). - leaf_class(Self, Leaf) :- - specializes_class(Subclass, Self), - leaf_class(Subclass, Leaf). - - leaf_classes(Leaves) :- - self(Self), - ( setof(Leaf, leaf_class(Self, Leaf), Leaves) -> - true - ; Leaves = [] - ). - - descendant(Descendant) :- - self(Self), - descendant(Self, Descendant). - - descendant(Self, Descendant) :- - instantiates_class(Descendant, Self). - descendant(Self, Descendant) :- - specializes_class(Descendant, Self), - \+ instantiates_class(Descendant, Self). - descendant(Self, Descendant) :- - specializes_class(Subclass, Self), - descendant(Subclass, Descendant). - - descendants(Descendants) :- - self(Self), - ( setof(Descendant, descendant(Self, Descendant), Descendants) -> - true - ; Descendants = [] - ). - - descendant_class(Descendant) :- - self(Self), - descendant_class(Self, Descendant). - - descendant_class(Self, Descendant) :- - specializes_class(Descendant, Self). - descendant_class(Self, Descendant) :- - specializes_class(Subclass, Self), - descendant_class(Subclass, Descendant). - - descendant_classes(Descendants) :- - self(Self), - ( setof(Descendant, descendant_class(Self, Descendant), Descendants) -> - true - ; Descendants = [] - ). - - descendant_instance(Descendant) :- - self(Self), - descendant_instance(Self, Descendant). - - descendant_instance(Self, Descendant) :- - instantiates_class(Descendant, Self). - descendant_instance(Self, Descendant) :- - specializes_class(Subclass, Self), - descendant_instance(Subclass, Descendant). - - descendant_instances(Descendants) :- - self(Self), - ( setof(Descendant, descendant_instance(Self, Descendant), Descendants) -> - true - ; Descendants = [] - ). - -:- end_category. diff --git a/Logtalk/library/class_hierarchyp.lgt b/Logtalk/library/class_hierarchyp.lgt deleted file mode 100644 index 350f6d222..000000000 --- a/Logtalk/library/class_hierarchyp.lgt +++ /dev/null @@ -1,107 +0,0 @@ - -:- protocol(class_hierarchyp, - extends(hierarchyp)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Class hierarchy protocol.']). - - :- public(class/1). - :- mode(class(?object), zero_or_more). - :- info(class/1, [ - comment is 'Returns, by backtracking, all object classes.', - argnames is ['Class']]). - - :- public(classes/1). - :- mode(classes(-list), one). - :- info(classes/1, [ - comment is 'List of all object classes.', - argnames is ['Classes']]). - - :- public(instance/1). - :- mode(instance(?object), zero_or_more). - :- info(instance/1, [ - comment is 'Returns, by backtracking, all class instances.', - argnames is ['Instance']]). - - :- public(instances/1). - :- mode(instances(-list), one). - :- info(instances/1, [ - comment is 'List of all class instances.', - argnames is ['Instances']]). - - :- public(subclass/1). - :- mode(subclass(?object), zero_or_more). - :- info(subclass/1, [ - comment is 'Returns, by backtracking, all class subclasses.', - argnames is ['Subclass']]). - - :- public(subclasses/1). - :- mode(subclasses(-list), one). - :- info(subclasses/1, [ - comment is 'List of all class subclasses.', - argnames is ['Subclasses']]). - - :- public(superclass/1). - :- mode(superclass(?object), zero_or_more). - :- info(superclass/1, [ - comment is 'Returns, by backtracking, all class superclasses.', - argnames is ['Superclass']]). - - :- public(superclasses/1). - :- mode(superclasses(-list), one). - :- info(superclasses/1, [ - comment is 'List of all class superclasses.', - argnames is ['Superclasses']]). - - :- public(leaf_instance/1). - :- mode(leaf_instance(?object), zero_or_more). - :- info(leaf_instance/1, [ - comment is 'Returns, by backtracking, all class leaf instances.', - argnames is ['Leaf']]). - - :- public(leaf_instances/1). - :- mode(leaf_instances(-list), one). - :- info(leaf_instances/1, [ - comment is 'List of all class leaf instances.', - argnames is ['Leaves']]). - - :- public(leaf_class/1). - :- mode(leaf_class(?object), zero_or_more). - :- info(leaf_class/1, [ - comment is 'Returns, by backtracking, all class leaf subclasses.', - argnames is ['Leaf']]). - - :- public(leaf_classes/1). - :- mode(leaf_classes(-list), one). - :- info(leaf_classes/1, [ - comment is 'List of all class leaf leaf subclasses.', - argnames is ['Leaves']]). - - :- public(descendant_instance/1). - :- mode(descendant_instance(?object), zero_or_more). - :- info(descendant_instance/1, [ - comment is 'Returns, by backtracking, all class descendant instances.', - argnames is ['Descendant']]). - - :- public(descendant_instances/1). - :- mode(descendant_instances(-list), one). - :- info(descendant_instances/1, [ - comment is 'List of all class descendant instances.', - argnames is ['Descendants']]). - - :- public(descendant_class/1). - :- mode(descendant_class(?object), zero_or_more). - :- info(descendant_class/1, [ - comment is 'Returns, by backtracking, all class descendant subclasses.', - argnames is ['Descendant']]). - - :- public(descendant_classes/1). - :- mode(descendant_classes(-list), one). - :- info(descendant_classes/1, [ - comment is 'List of all class descendant subclasses.', - argnames is ['Descendants']]). - -:- end_protocol. diff --git a/Logtalk/library/comparingp.lgt b/Logtalk/library/comparingp.lgt deleted file mode 100644 index 5de6a21ca..000000000 --- a/Logtalk/library/comparingp.lgt +++ /dev/null @@ -1,46 +0,0 @@ - -:- protocol(comparingp). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Comparing protocol using overloading of standard operators.']). - - :- public((<)/2). - :- mode(<(+term, +term), zero_or_one). - :- info((<)/2, [ - comment is 'True if Term1 is less than Term2.', - argnames is ['Term1', 'Term2']]). - - :- public((=<)/2). - :- mode(=<(+term, +term), zero_or_one). - :- info((=<)/2, [ - comment is 'True if Term1 is less or equal than Term2.', - argnames is ['Term1', 'Term2']]). - - :- public((>)/2). - :- mode(>(+term, +term), zero_or_one). - :- info((>)/2, [ - comment is 'True if Term1 is greater than Term2.', - argnames is ['Term1', 'Term2']]). - - :- public((>=)/2). - :- mode(>=(+term, +term), zero_or_one). - :- info((>=)/2, [ - comment is 'True if Term1 is equal or grater than Term2.', - argnames is ['Term1', 'Term2']]). - - :- public((=:=)/2). - :- mode(=:=(+term, +term), zero_or_one). - :- info((=:=)/2, [ - comment is 'True if Term1 is equal to Term2.', - argnames is ['Term1', 'Term2']]). - - :- public((=\=)/2). - :- mode(=\=(+term, +term), zero_or_one). - :- info((=\=)/2, [ - comment is 'True if Term1 is not equal to Term2.', - argnames is ['Term1', 'Term2']]). - -:- end_protocol. diff --git a/Logtalk/library/compound.lgt b/Logtalk/library/compound.lgt deleted file mode 100644 index d1ebbf503..000000000 --- a/Logtalk/library/compound.lgt +++ /dev/null @@ -1,14 +0,0 @@ - -:- object(compound, - extends(term)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Compound data type.']). - - valid(Compound) :- - compound(Compound). - -:- end_object. diff --git a/Logtalk/library/date.lgt b/Logtalk/library/date.lgt deleted file mode 100644 index 5d15cfa87..000000000 --- a/Logtalk/library/date.lgt +++ /dev/null @@ -1,62 +0,0 @@ - -:- object(date, - implements(datep)). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2006/3/7, - comment is 'Date predicates.']). - - today(Year, Month, Day) :- - {'$lgt_current_date'(Year, Month, Day)}. - - leap_year(Year) :- - ( 0 =:= mod(Year, 4), 0 =\= mod(Year, 100) -> - true - ; 0 =:= mod(Year, 400) - ). - - name_of_day(1, 'Sunday', 'Sun'). - name_of_day(2, 'Monday', 'Mon'). - name_of_day(3, 'Tuesday', 'Tue'). - name_of_day(4, 'Wednesday', 'Wed'). - name_of_day(5, 'Thursday', 'Thu'). - name_of_day(6, 'Friday', 'Fri'). - name_of_day(7, 'Saturday', 'Sat'). - - name_of_month( 1, 'January', 'Jan'). - name_of_month( 2, 'February', 'Feb'). - name_of_month( 3, 'March', 'Mar'). - name_of_month( 4, 'April', 'Apr'). - name_of_month( 5, 'May', 'May'). - name_of_month( 6, 'June', 'Jun'). - name_of_month( 7, 'July', 'Jul'). - name_of_month( 8, 'August', 'Aug'). - name_of_month( 9, 'September', 'Sep'). - name_of_month(10, 'October', 'Oct'). - name_of_month(11, 'November', 'Nov'). - name_of_month(12, 'December', 'Dec'). - - days_in_month( 1, _, 31). - days_in_month( 2, Year, Days) :- - leap_year(Year) -> Days = 29; Days = 28. - days_in_month( 3, _, 31). - days_in_month( 4, _, 30). - days_in_month( 5, _, 31). - days_in_month( 6, _, 30). - days_in_month( 7, _, 31). - days_in_month( 8, _, 31). - days_in_month( 9, _, 30). - days_in_month(10, _, 31). - days_in_month(11, _, 30). - days_in_month(12, _, 31). - - valid(Year, Month, Day) :- - integer(Year), - integer(Month), Month >= 1, Month =< 12, - integer(Day), - days_in_month(Month, Year, Days), - Day >= 1, Day =< Days. - -:- end_object. diff --git a/Logtalk/library/datep.lgt b/Logtalk/library/datep.lgt deleted file mode 100644 index 102f4f9fb..000000000 --- a/Logtalk/library/datep.lgt +++ /dev/null @@ -1,46 +0,0 @@ - -:- protocol(datep). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2005/3/17, - comment is 'Date protocol.']). - - :- public(today/3). - :- mode(today(-integer, -integer, -integer), one). - :- info(today/3, [ - comment is 'Returns current date.', - argnames is ['Year', 'Month', 'Day']]). - - :- public(leap_year/1). - :- mode(leap_year(+integer), zero_or_one). - :- info(leap_year/1, - [comment is 'True if the argument is a leap year.', - argnames is ['Year']]). - - :- public(name_of_day/3). - :- mode(name_of_day(?integer, ?atom, ?atom), zero_or_more). - :- info(name_of_day/3, [ - comment is 'Name and short name of day.', - argnames is ['Index', 'Name', 'Short']]). - - :- public(name_of_month/3). - :- mode(name_of_month(?integer, ?atom, ?atom), zero_or_more). - :- info(name_of_month/3, [ - comment is 'Name and short name of month.', - argnames is ['Index', 'Name', 'Short']]). - - :- public(days_in_month/3). - :- mode(days_in_month(?integer, +integer, ?integer), zero_or_more). - :- info(days_in_month/3, [ - comment is 'Number of days in a month.', - argnames is ['Month', 'Year', 'Days']]). - - :- public(valid/3). - :- mode(valid(@integer, @integer, @integer), zero_or_one). - :- info(valid/3, [ - comment is 'True if the arguments represent a valid date.', - argnames is ['Year', 'Month', 'Day']]). - -:- end_protocol. diff --git a/Logtalk/library/dates.notes b/Logtalk/library/dates.notes deleted file mode 100644 index 1f14ceb0c..000000000 --- a/Logtalk/library/dates.notes +++ /dev/null @@ -1,20 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load all entities in this group load the dates_loader.lgt utility -file: - - | ?- logtalk_load(dates_loader). - -The object date implements some useful calandar date predicates. - -The object time implements some useful time predicates. - -Please note that some of the functionality of these objects depends -on the chosen Prolog support for accessing operating system time and -date values. diff --git a/Logtalk/library/dates_loader.lgt b/Logtalk/library/dates_loader.lgt deleted file mode 100644 index b49078e1b..000000000 --- a/Logtalk/library/dates_loader.lgt +++ /dev/null @@ -1,5 +0,0 @@ - -:- initialization( - logtalk_load( - [datep, date, timep, time], - [reload(skip)])). % allow for static binding diff --git a/Logtalk/library/debugging.notes b/Logtalk/library/debugging.notes deleted file mode 100644 index b9d066931..000000000 --- a/Logtalk/library/debugging.notes +++ /dev/null @@ -1,35 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load all entities in this group load the debugging_loader.lgt utility -file: - - | ?- logtalk_load(debugging_loader). - -You will need to load FIRST the events_loader.lgt file otherwise you will get -a runtime error. - - -The object event_dbg enables you to: - - - spy all or specific messages to an object - - trace an execution - - specify the streams used for debugger input/output - -These capabilities rely on the use of the event-based programming built in -Logtalk. That means that you can only debug public messages sent using the -::/2 operator. - -You can have any number of debuggers active simultaneously, possibly -assigning different input/output streams to each one. - -Input/output is one area where Prologs compilers can differ, sometimes -because of differences in the underlying operating system. Therefore, -it is advisable that you look at the code of class debugger before -trying to use it. The i/o operations are done by the methods output/3, -query_user/1 and execute_option/1. diff --git a/Logtalk/library/debugging_loader.lgt b/Logtalk/library/debugging_loader.lgt deleted file mode 100644 index 189a8b371..000000000 --- a/Logtalk/library/debugging_loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load([event_dbgp, event_dbg], [events(on), reload(skip)])). % allow for static binding diff --git a/Logtalk/library/dependents.notes b/Logtalk/library/dependents.notes deleted file mode 100644 index d3635463f..000000000 --- a/Logtalk/library/dependents.notes +++ /dev/null @@ -1,15 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load all entities in this group load the dependents_loader.lgt -utility file: - - | ?- logtalk_load(dependents_loader). - -The categories "observer" and "subject" implement the Smalltalk -dependent handling mechanism. diff --git a/Logtalk/library/dependents_loader.lgt b/Logtalk/library/dependents_loader.lgt deleted file mode 100644 index 472104bf2..000000000 --- a/Logtalk/library/dependents_loader.lgt +++ /dev/null @@ -1,3 +0,0 @@ - -:- initialization( - logtalk_load([observer, subject], [reload(skip)])). % allow for static binding diff --git a/Logtalk/library/dictionaryp.lgt b/Logtalk/library/dictionaryp.lgt deleted file mode 100644 index 0fa7d5a94..000000000 --- a/Logtalk/library/dictionaryp.lgt +++ /dev/null @@ -1,71 +0,0 @@ - -:- protocol(dictionaryp). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Dictionary protocol.']). - - :- public(as_dictionary/2). - :- mode(as_dictionary(@list, -dictionary), one). - :- info(as_dictionary/2, [ - comment is 'Converts a list of key-value pairs to a dictionary.', - argnames is ['List', 'Dictionary']]). - - :- public(as_list/2). - :- mode(as_list(@dictionary, -list), one). - :- info(as_list/2, [ - comment is 'Converts a dictionary to a list of key-value pairs.', - argnames is ['Dictionary', 'List']]). - - :- public(delete/4). - :- mode(delete(+dictionary, @ground, ?term, -dictionary), zero_or_one). - :- info(delete/4, [ - comment is 'Deletes a matching Key-Value pair from a dictionary, returning the updated dictionary.', - argnames is ['Dictionary_in', 'Key', 'Value', 'Dictionary_out']]). - - :- public(empty/1). - :- mode(empty(@dictionary), zero_or_one). - :- info(empty/1, [ - comment is 'True if the dictionary is empty.', - argnames is ['Dictionary']]). - - :- public(insert/4). - :- mode(insert(+ground, @term, +dictionary, -dictionary), one). - :- info(insert/4, [ - comment is 'Inserts a Key-Value pair into a dictionary, returning the updated dictionary.', - argnames is ['Key', 'Value', 'Dictionary_in', 'Dictionary_out']]). - - :- public(insert_all/3). - :- mode(insert_all(@list, +dictionary, -dictionary), one). - :- info(insert_all/3, [ - comment is 'Inserts a list of Key-Value pairs into a dictionary, returning the updated dictionary.', - argnames is ['List', 'Dictionary_in', 'Dictionary_out']]). - - :- public(lookup/3). - :- mode(lookup(+ground, ?term, @dictionary), zero_or_one). - :- mode(lookup(-ground, ?term, @dictionary), zero_or_more). - :- info(lookup/3, [ - comment is 'Get a matching Key-Value pair from a dictionary.', - argnames is ['Key', 'Value', 'Dictionary']]). - - :- public(keys/2). - :- mode(keys(@dictionary, -list), one). - :- info(keys/2, [ - comment is 'Returns a list with all dictionary keys.', - argnames is ['Dictionary', 'List']]). - - :- public(map/3). - :- mode(map(+functor, +dictionary, -dictionary), zero_or_one). - :- info(map/3, [ - comment is 'Maps a binary predicate over each dictionary key-value pair returning a new pair.', - argnames is ['Functor', 'In', 'Out']]). - - :- public(size/2). - :- mode(size(@dictionary, ?integer), zero_or_one). - :- info(size/2, [ - comment is 'Number of dictionary entries.', - argnames is ['Dictionary', 'Size']]). - -:- end_protocol. diff --git a/Logtalk/library/difflist.lgt b/Logtalk/library/difflist.lgt deleted file mode 100644 index a23725e83..000000000 --- a/Logtalk/library/difflist.lgt +++ /dev/null @@ -1,295 +0,0 @@ - -:- object(difflist, - implements(listp), - extends(compound)). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2004/5/9, - comment is 'Difference list predicates.']). - - :- public(as_list/2). - :- mode(as_list(+list, -list), one). - :- info(as_list/2, - [comment is 'Converts a difference list to a normal list.', - argnames is ['Diffist', 'List']]). - - append(List1-Back1, Back1-Back2, List1-Back2) :- - nonvar(List1), - nonvar(Back1), - !. - append(Prefix, Suffix, List) :- - length(List, Length), - prefix(Prefix, List), - length(Prefix, PLength), - SLength is Length - PLength, - length(Suffix, SLength), - suffix(Suffix, List). - - as_list(List-Back, Out) :- - ( List == Back -> - Out = [] - ; Out = [Head| Tail], - List = [Head| Rest], - as_list(Rest-Back, Tail) - ). - - delete(List-Back, Element, Remaining) :- - ( List == Back -> - unify_with_occurs_check(Remaining, Back-Back) - ; List \== Back, - List = [Head| Tail], - ( Head == Element -> - delete(Tail-Back, Element, Remaining) - ; Remaining = [Head| Tail2], - delete(Tail-Back, Element, Tail2-Back) - ) - ). - - delete_matches(List-Back, Element, Remaining) :- - ( List == Back -> - unify_with_occurs_check(Remaining, Back-Back) - ; List \== Back, - List = [Head| Tail], - ( \+ \+ Head = Element -> - delete_matches(Tail-Back, Element, Remaining) - ; Remaining = [Head| Tail2], - delete_matches(Tail-Back, Element, Tail2-Back) - ) - ). - - empty(List-Back) :- - List == Back. - - flatten(List-Back, Flatted-Back) :- - flatten(List-Back, Back-Back, Flatted-Back). - - flatten(Var, Tail-Back, [Var| Tail]-Back) :- - var(Var), - !. - flatten(List-Back, Flatted, Flatted) :- - List == Back, - !. - flatten(List-Back, Acc, Flatted) :- - !, - List \== Back, - List = [Head| Tail], - flatten(Tail-Back, Acc, Acc2), - flatten(Head, Acc2, Flatted). - flatten(Head, Tail-Back, [Head| Tail]-Back). - - keysort(Difflist, Sorted) :- - as_list(Difflist, List), - {keysort(List, List2)}, - list::as_difflist(List2, Sorted). - - last(List-Back, Last) :- - List \== Back, - List = [Head| Tail], - last(Tail-Back, Head, Last). - - last(List, Last, Last) :- - unify_with_occurs_check(List, Back-Back). - last(List-Back, _, Last) :- - List \== Back, - List = [Head| Tail], - last(Tail-Back, Head, Last). - - length(List, Length) :- - ( integer(Length) -> - Length >= 0, - make_list(Length, List) - ; length(List, 0, Length) - ). - - length(List, Length, Length) :- - unify_with_occurs_check(List, Back-Back). - length(List-Back, Acc, Length) :- - List \== Back, - List = [_| Tail], - Acc2 is Acc + 1, - length(Tail-Back, Acc2, Length). - - make_list(0, List):- - !, - unify_with_occurs_check(List, Back-Back). - make_list(N, List-Back):- - List \== Back, - List = [_| Tail], - M is N-1, - make_list(M, Tail-Back). - - max(List-Back, Max) :- - List \== Back, - List = [Head| Tail], - max(Tail-Back, Head, Max). - - max(List-Back, Max, Max) :- - List == Back, !. - max(List-Back, Aux, Max) :- - List \== Back, - List = [Head| Tail], - ( Aux @< Head -> - max(Tail-Back, Head, Max) - ; max(Tail-Back, Aux, Max) - ). - - member(Element, List-Back) :- - List \== Back, - List = [Element|_]. - member(Element, List-Back) :- - List \== Back, - List = [_| Tail], - member(Element, Tail-Back). - - memberchk(Element, List) :- - once(member(Element, List)). - - nth0(Position, List, Element) :- - nth(Element, List, 0, Position, _). - - nth0(Nth, List, Element, Tail) :- - nth(Element, List, 0, Nth, Tail). - - nth1(Position, List, Element) :- - nth(Element, List, 1, Position, _). - - nth1(Nth, List, Element, Tail) :- - nth(Element, List, 1, Nth, Tail). - - nth(Element, List-Back, Position, Position, Tail-Back) :- - List \== Back, - List = [Element| Tail]. - nth(Element, List-Back, Count, Position, Tail-Back) :- - List \== Back, - List = [_| List2], - Count2 is Count + 1, - nth(Element, List2-Back, Count2, Position, Tail-Back). - - min(List-Back, Min) :- - List \== Back, - List = [Head| Tail], - min(Tail-Back, Head, Min). - - min(List-Back, Min, Min) :- - List == Back, !. - min(List-Back, Aux, Min) :- - List \== Back, - List = [Head| Tail], - (Head @< Aux -> - min(Tail-Back, Head, Min) - ; - min(Tail-Back, Aux, Min)). - - new(List) :- - unify_with_occurs_check(List, Back-Back). - - permutation(List, Permutation) :- - same_length(List, Permutation), - permutation2(List, Permutation). - - permutation2(List1-Back1, List2-Back2) :- - List1 == Back1, - List2 == Back2. - permutation2(List1-Back1, List2-Back2) :- - List2 \== Back2, - List2 = [Head2| Tail2], - select(Head2, List1-Back1, Tail1-Back1), - permutation2(Tail1-Back1, Tail2-Back2). - - prefix(List, _) :- - unify_with_occurs_check(List, Back-Back). - prefix(List-Back, List2-Back2) :- - List \== Back, - List = [Head| Tail], - List2 \== Back2, - List2 = [Head| Tail2], - prefix(Tail-Back, Tail2-Back2). - - reverse(List-Back, Reversed-Back) :- - same_length(List-Back, Reversed-Back), - reverse(List-Back, Back-Back, Reversed-Back). - - reverse(List-Back, Reversed, Reversed) :- - List == Back. - reverse(List-Back, Acc-Back, Reversed) :- - List \== Back, - List = [Head| Tail], - reverse(Tail-Back, [Head| Acc]-Back, Reversed). - - same_length(List1, List2) :- - unify_with_occurs_check(List1, Back1-Back1), - unify_with_occurs_check(List2, Back2-Back2). - same_length(List1-Back1, List2-Back2) :- - List1 \== Back1, - List1 = [_| Tail1], - List2 \== Back2, - List2 = [_| Tail2], - same_length(Tail1-Back1, Tail2-Back2). - - select(Head, List-Back, Tail-Back) :- - List \== Back, - List = [Head| Tail]. - select(Head, List-Back, List2-Back) :- - List \== Back, - List = [Other| Tail], - List2 \== Back, - List2 = [Other| Tail2], - select(Head, Tail-Back, Tail2-Back). - - sort(Difflist, Sorted) :- - as_list(Difflist, List), - {sort(List, List2)}, - list::as_difflist(List2, Sorted). - - sublist(Sublist, List) :- - unify_with_occurs_check(Sublist, List). - sublist(Sublist-Back, List-Back):- - List \== Back, - List = [Head| Tail], - sublist(Tail-Back, Head, Sublist-Back). - - sublist(List, _, Sublist) :- - unify_with_occurs_check(List, Sublist). - sublist(List-Back, _, Sublist-Back):- - List \== Back, - List = [Head| Tail], - sublist(Tail-Back, Head, Sublist-Back). - sublist(List-Back, Element, [Element| Sublist]-Back):- - List \== Back, - List = [Head| Tail], - sublist(Tail-Back, Head, Sublist-Back). - - subtract(List-Back, _, Result) :- - unify_with_occurs_check(Result, Back-Back), - List == Back, !. - subtract(List-Back, Ys, List2-Back) :- - List \== Back, - List = [Head| Tail], - (member(Head, Ys) -> - subtract(Tail-Back, Ys, List2-Back) - ; - List2 = [Head| Tail2], - subtract(Tail-Back, Ys, Tail2-Back)). - - suffix(Suffix, List) :- - unify_with_occurs_check(Suffix, List). - suffix(Suffix-Back, List-Back) :- - List \== Back, - List = [_| Tail], - suffix(Suffix-Back, Tail-Back). - - valid(List) :- - nonvar(List), - valid2(List). - - valid2(List-Back) :- - List == Back, - !. - valid2(List-Back) :- - nonvar(List), - List = [_| Tail], - valid2(Tail-Back). - -:- end_object. diff --git a/Logtalk/library/event_dbg.lgt b/Logtalk/library/event_dbg.lgt deleted file mode 100644 index 49f7c777e..000000000 --- a/Logtalk/library/event_dbg.lgt +++ /dev/null @@ -1,148 +0,0 @@ - -:- object(event_dbg, - implements(event_dbgp, monitoring), - imports(monitor)). - - :- info([ - version is 1.1, - date is 2006/12/15, - author is 'Paulo Moura', - comment is 'Debugging facilities similar to those found in most Prolog compilers.']). - - :- initialization(::init). - - :- protected(port_output/4). - :- mode(port_output(+atom, +object, @callable, +object), one). - :- info(port_output/4, [ - comment is 'Outputs current port information.', - argnames is ['Port', 'Object', 'Message', 'Sender']]). - - :- protected(execute_option/1). - :- mode(execute_option(+atom), one). - :- info(execute_option/1, [ - comment is 'Executes a user option at a debugger port.', - argnames is ['Option']]). - - :- protected(query_user/1). - :- mode(query_user(-atom), one). - :- info(query_user/1, [ - comment is 'Query a user about an option at a debugger port.', - argnames is ['Option']]). - - :- private(stream_/2). - :- dynamic(stream_/2). - :- mode(stream_(?atom, ?stream), zero_or_more). - :- info(stream/2, [ - comment is 'Stores the current debugger input and ouput streams.', - argnames is ['Kind', 'Stream']]). - - stream(Name, Stream) :- - ::stream_(Name, Stream). - - set_stream(Name, Stream) :- - ::retractall(stream_(Name, _)), - ::assertz(stream_(Name, Stream)). - - trace :- - self(Self), - abolish_events(before, _, _, _, Self), - abolish_events(after, _, _, _, Self), - define_events(before, _, _, _, Self), - define_events(after, _, _, _, Self). - - notrace :- - self(Self), - abolish_events(before, _, _, _, Self), - abolish_events(after, _, _, _, Self). - - debugging :- - ::monitor_activated. - - debug :- - ::activate_monitor. - - nodebug :- - ::suspend_monitor. - - port_output(Port, Object, Message, Sender) :- - ::stream(output, Output), - write(Output, Port), - write(Output, ': '), - writeq(Output, Object), - write(Output, ' <- '), - writeq(Output, Message), - write(Output, ' from '), - writeq(Output, Sender), - nl(Output). - - query_user(Option) :- - ::stream(output, Output), - ::stream(input, Input), - repeat, - write(Output, ' >> '), - read(Input, Option), - nl(Output), - ( valid_option(Option) -> - true - ; ::execute_option(h), - fail - ), - !. - - execute_option(c). - execute_option(f) :- - !, fail. - execute_option(n) :- - ::nodebug. - execute_option(b) :- - ::stream(output,Output), - ::stream(input, Input), - repeat, - write(Output, ' :- '), - read(Input, Goal), - writeq(Output, Goal), - nl(Output), - ( once(Goal) -> - write(Output, ' answer: '), - writeq(Output, Goal), nl(Output) - ; write(Output, ' no'), nl(Output) - ), - Goal = true, - !. - execute_option(a) :- - throw(error(logtalk_execution_aborted)). - execute_option(h) :- - ::stream(output, Output), - write(Output, ' Available options are:'), nl(Output), - write(Output, ' c - creep (go on)'), nl(Output), - write(Output, ' f - fail (force failure or backtracking)'), nl(Output), - write(Output, ' n - nodebug (turn off debug)'), nl(Output), - write(Output, ' b - break (submit queries to the interpreter, type true to terminate)'), nl(Output), - write(Output, ' a - abort (return to top level interpreter)'), nl(Output), - write(Output, ' h - help (prints this list of options)'), nl(Output), - nl(Output). - - valid_option(c). - valid_option(f). - valid_option(n). - valid_option(b). - valid_option(a). - - before(Object, Message, Sender) :- - ::port_output(call, Object, Message, Sender), - ::query_user(Option), - ::execute_option(Option). - - after(Object, Message, Sender) :- - ::port_output(exit, Object, Message, Sender), - ::query_user(Option), - ::execute_option(Option). - - init :- - ::reset_monitor, - current_input(Input), - ::set_stream(input, Input), - current_output(Output), - ::set_stream(output, Output). - -:- end_object. diff --git a/Logtalk/library/event_dbgp.lgt b/Logtalk/library/event_dbgp.lgt deleted file mode 100644 index ddba4d123..000000000 --- a/Logtalk/library/event_dbgp.lgt +++ /dev/null @@ -1,52 +0,0 @@ - -:- protocol(event_dbgp). - - :- info([ - version is 1.0, - date is 2000/7/24, - author is 'Paulo Moura', - comment is 'Debugging protocol similar to those found in most Prolog compilers.']). - - :- public(trace/0). - :- mode(trace, one). - :- info(trace/0, [ - comment is 'Starts tracing all message sending events.']). - - :- public(notrace/0). - :- mode(notrace, one). - :- info(notrace/0, [ - comment is 'Stops tracing.']). - - :- public(debug/0). - :- mode(debug, one). - :- info(debug/0, [ - comment is 'Activates spy points and starts debugging.']). - - :- public(nodebug/0). - :- mode(nodebug, one). - :- info(nodebug/0, [ - comment is 'Suspends spy points and stops debugging.']). - - :- public(debugging/0). - :- mode(debugging, zero_or_one). - :- info(debugging/0, [ - comment is 'True if the debugger is active.']). - - :- public(init/0). - :- mode(init, one). - :- info(init/0, [ - comment is 'Initializes debugger, turns debugging off and resets all spy points and streams.']). - - :- public(stream/2). - :- mode(stream(?atom, ?stream), zero_or_more). - :- info(stream/2, [ - comment is 'Current debugger input or ouput streams.', - argnames is ['Kind', 'Stream']]). - - :- public(set_stream/2). - :- mode(set_stream(+atom, +stream), one). - :- info(set_stream/2, [ - comment is 'Sets the debugger input or output stream.', - argnames is ['Kind', 'Stream']]). - -:- end_protocol. diff --git a/Logtalk/library/event_handlersp.lgt b/Logtalk/library/event_handlersp.lgt deleted file mode 100644 index 263786a1f..000000000 --- a/Logtalk/library/event_handlersp.lgt +++ /dev/null @@ -1,22 +0,0 @@ - -:- protocol(event_handlersp). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2003/2/12, - comment is 'Event handlers protocol.']). - - :- public(before/3). - :- mode(before(@object, @nonvar, @object), zero_or_one). - :- info(before/3, [ - comment is 'Before event handler.', - argnames is ['Object', 'Message', 'Sender']]). - - :- public(after/3). - :- mode(after(@object, @nonvar, @object), zero_or_one). - :- info(after/3, [ - comment is 'After event handler.', - argnames is ['Object', 'Message', 'Sender']]). - -:- end_protocol. diff --git a/Logtalk/library/event_registry.lgt b/Logtalk/library/event_registry.lgt deleted file mode 100644 index c93dc026e..000000000 --- a/Logtalk/library/event_registry.lgt +++ /dev/null @@ -1,43 +0,0 @@ - -:- object(event_registry, - implements(event_registryp)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Before and after events registry predicates.']). - - monitors(Monitors) :- - findall( - Monitor, - (current_event(before, _, _, _, Monitor), - current_event(after, _, _, _, Monitor)), - List), - {sort(List, Monitors)}. - - monitored(Objects) :- - findall( - Object, - (current_event(before, Object, _, _, _), - current_event(after, Object, _, _, _)), - List), - {sort(List, Objects)}. - - monitor(Object, Message, Sender, Monitor) :- - current_event(before, Object, Message, Sender, Monitor), - current_event(after, Object, Message, Sender, Monitor). - - set_monitor(Object, Message, Sender, Monitor) :- - define_events(before, Object, Message, Sender, Monitor), - define_events(after, Object, Message, Sender, Monitor). - - del_monitors(Object, Message, Sender, Monitor) :- - abolish_events(before, Object, Message, Sender, Monitor), - abolish_events(after, Object, Message, Sender, Monitor). - - del_monitors :- - abolish_events(before, _, _, _, _), - abolish_events(after, _, _, _, _). - -:- end_object. diff --git a/Logtalk/library/event_registryp.lgt b/Logtalk/library/event_registryp.lgt deleted file mode 100644 index fe65fe336..000000000 --- a/Logtalk/library/event_registryp.lgt +++ /dev/null @@ -1,45 +0,0 @@ - -:- protocol(event_registryp). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Event registry protocol.']). - - :- public(monitors/1). - :- mode(monitors(-list), one). - :- info(monitors/1, [ - comment is 'Returns a list of all current monitors.', - argnames is ['Monitors']]). - - :- public(monitored/1). - :- mode(monitored(-list), one). - :- info(monitored/1, [ - comment is 'Returns a list of all currently monitored objects.', - argnames is ['Objects']]). - - :- public(monitor/4). - :- mode(monitor(?object, ?nonvar, ?object, ?object), zero_or_more). - :- info(monitor/4, [ - comment is 'True if the arguments describe a currently defined monitored event.', - argnames is ['Object', 'Message', 'Sender', 'Monitor']]). - - :- public(set_monitor/4). - :- mode(set_monitor(?object, ?nonvar, ?object, +object), zero_or_one). - :- info(set_monitor/4, [ - comment is 'Sets a monitor for the set of matching events.', - argnames is ['Object', 'Message', 'Sender', 'Monitor']]). - - :- public(del_monitors/4). - :- mode(del_monitors(?object, ?nonvar, ?object, ?object), one). - :- info(del_monitors/4, [ - comment is 'Deletes all matching monitored events.', - argnames is ['Object', 'Message', 'Sender', 'Monitor']]). - - :- public(del_monitors/0). - :- mode(del_monitors, one). - :- info(del_monitors/0, [ - comment is 'Deletes all monitored events.']). - -:- end_protocol. diff --git a/Logtalk/library/events.notes b/Logtalk/library/events.notes deleted file mode 100644 index 01bf4cf31..000000000 --- a/Logtalk/library/events.notes +++ /dev/null @@ -1,24 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load all entities in this library load the events_loader.lgt utility -file: - - | ?- logtalk_load(events_loader). - -The objects event_registry, before_event_registry, and after_event_registry -implement convenient predicates for registering before and after events. - -The protocol event_handlersp declares the two basic event handler predicates -(before/3 and after/3). You will need to refer this protocol in your objects -if you want to use the super control structure (^^/1) with these predicates. - -The monitor object implements more sophisticated event handling predicates. - -Some of the objects assume that the chosen Prolog compiler defines the -usual sort/2 built-in predicate. diff --git a/Logtalk/library/events_loader.lgt b/Logtalk/library/events_loader.lgt deleted file mode 100644 index 926ab4cf1..000000000 --- a/Logtalk/library/events_loader.lgt +++ /dev/null @@ -1,7 +0,0 @@ - -:- initialization( - logtalk_load([ - event_handlersp, - event_registryp, event_registry, - before_event_registry, after_event_registry, - monitorp, monitor], [events(on), reload(skip)])). % allow for static binding diff --git a/Logtalk/library/experimental/NOTES.txt b/Logtalk/library/experimental/NOTES.txt deleted file mode 100644 index 58bcd1038..000000000 --- a/Logtalk/library/experimental/NOTES.txt +++ /dev/null @@ -1,12 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - -This folder contains objects, categories, and protocols whose -implementation is Prolog-compiler dependent. Each sub-folder -contains files specific for a Prolog compiler. All code in this -folder is under development, incomplete, and should be considered -highly experimental. diff --git a/Logtalk/library/experimental/als/system.lgt b/Logtalk/library/experimental/als/system.lgt deleted file mode 100644 index 07f1eb245..000000000 --- a/Logtalk/library/experimental/als/system.lgt +++ /dev/null @@ -1,120 +0,0 @@ - -:- object(system, - implements(systemp)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/6/5, - comment is 'Operating system interface for ALS Prolog.']). - - - make_directory(Directory) :- - {fail}. - - - delete_directory(Directory) :- - {fail}. - - - change_directory(Directory) :- - {change_cwd(Directory)}. - - - working_directory(Directory) :- - {get_cwd(Directory)}. - - - directory_exists(Directory) :- - {fail}. - - - directory_files(Directory, Files) :- - {files(Directory, '*', Files)}. - - - absolute_file_name(File) :- - {is_absolute_path(File)}. - - - absolute_file_name(File, Full) :- - {fail}. - - - file_base_name(File, Base) :- - {path_directory_tail(File, _, Name), - file_extension(Name, Base, _)}. - - - file_name_extension(File, Extension) :- - {path_directory_tail(File, _, Name), - file_extension(Name, _, Extension)}. - - - file_name_directory(File, Directory) :- - {path_directory_tail(File, Directory, _)}. - - - file_exists(File) :- - {exists_file(File)}. - - - file_modification_time(File, Time) :- - {file_status(File, Status), - dmember(mod_time=Time, Status)}. - - - file_size(File, Size) :- - {file_status(File, Status), - dmember(size=Size, Status)}. - - - file_type(File, Type) :- - {file_status(File, Status), - dmember(type=Type, Status)}. - - - file_permission(File, Permission) :- - {file_status(File, Status), - dmember(permissions=Permissions, Status), - member(Permission, Permissions)}. - - - delete_file(File) :- - {remove_file(File)}. - - - rename_file(Old, New) :- - {fail}. - - - symbolic_link(File, Target) :- - {fail}. - - - environment_variable(Variable, Value) :- - {getenv(Variable, Value)}. - - - set_environment_variable(Variable, Value) :- - {fail}. - - - date_time(Year, Month, Day, Hours, Mins, Secs, 0) :- - {datetime(Year/Month/Day, Hours:Mins:Secs)}. - - - convert_time(Time, Year, Month, Day, Hours, Mins, Secs, Milisecs) :- - {fail}. - - - cpu_time(Time) :- - {Time is cputime}. - - - host_name(Name) :- - {fail}. - - -:- end_object. diff --git a/Logtalk/library/experimental/amzi/system.lgt b/Logtalk/library/experimental/amzi/system.lgt deleted file mode 100644 index 5e8fe31f7..000000000 --- a/Logtalk/library/experimental/amzi/system.lgt +++ /dev/null @@ -1,100 +0,0 @@ - -:- use_module(library(system)). - - -:- object(system, - implements(systemp)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/6/5, - comment is 'Operating system interface for Amzi! Prolog.']). - - - make_directory(Directory) :- - {mkdir(Directory)}. - - - delete_directory(Directory) :- - {rmdir(Directory, 0)}. - - - change_directory(Directory) :- - {chdir(Directory)}. - - - working_directory(Directory) :- - {curdir(Directory)}. - - - directory_exists(Directory) :- - {fail}. - - - directory_files(Directory, Files) :- - {directory_files(Directory, Files)}. - - - absolute_file_name(File) :- - {fail}. - - - absolute_file_name(File, Full) :- - {fail}. - - - file_exists(File) :- - {file_exists(File)}. - - - file_modification_time(File, Time) :- - {stat(File, _, _, Time, _, _, _, _, _)}. - - - file_size(File, Size) :- - {stat(File, _, _, _, Size, _, _, _, _)}. - - - file_permission(File, Permission) :- - {stat(File, _, _, _, _, Permission, _, _, _)}. - - - delete_file(File) :- - {delfile(File, 0)}. - - - rename_file(Old, New) :- - {rename(Old, New)}. - - - symbolic_link(File, Target) :- - {fail}. - - - environment_variable(Variable, Value) :- - {get_env_var(Variable, Value)}. - - - set_environment_variable(Variable, Value) :- - {fail}. - - - date_time(Year, Month, Day, Hours, Mins, Secs, 0) :- - {date(Year, Month, Day), time(Hours, Mins, Secs)}. - - - convert_time(Time, Year, Month, Day, Hours, Mins, Secs, Milisecs) :- - {fail}. - - - cpu_time(Time) :- - {Time is cputime}. - - - host_name(Name) :- - {current_host(Name)}. - - -:- end_object. diff --git a/Logtalk/library/experimental/b/system.lgt b/Logtalk/library/experimental/b/system.lgt deleted file mode 100644 index 562063e16..000000000 --- a/Logtalk/library/experimental/b/system.lgt +++ /dev/null @@ -1,101 +0,0 @@ - -:- object(system, - implements(systemp)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/6/5, - comment is 'Operating system interface for B-Prolog.']). - - - make_directory(Directory) :- - {atom_concat('mkdir ', Directory, Command), system(Command)}. - - - delete_directory(Directory) :- - {atom_concat('rmdir ', Directory, Command), system(Command)}. - - - change_directory(Directory) :- - {chdir(Directory)}. - - - working_directory(Directory) :- - {system(pwd, Directory)}. - - - directory_exists(Directory) :- - {fail}. - - - directory_files(Directory, Files) :- - {fail}. - - - absolute_file_name(File) :- - {fail}. - - - absolute_file_name(File, Full) :- - {fail}. - - - file_exists(File) :- - {exists(File)}. - - - file_modification_time(File, Time) :- - {fail}. - - - file_size(File, Size) :- - {fail}. - - - file_type(File, Type) :- - {fail}. - - - file_permission(File, Permission) :- - {fail}. - - - delete_file(File) :- - {atom_concat('rm ', File, Command), system(Command)}. - - - rename_file(Old, New) :- - {atom_concat('mv ', Old, Temp), atom_concat(' ', New, Command), system(Command)}. - - - symbolic_link(File, Target) :- - {fail}. - - - environment_variable(Variable, Value) :- - {environ(Variable, Value)}. - - - set_environment_variable(Variable, Value) :- - {fail}. - - - date_time(Year, Month, Day, Hours, Mins, Secs, 0) :- - {date(Year, Month, Day), time(Hours, Mins, Secs)}. - - - convert_time(Time, Year, Month, Day, Hours, Mins, Secs, Milisecs) :- - {fail}. - - - cpu_time(Time) :- - {cputime(Miliseconds), Time is Miliseconds/1000}. - - - host_name(Name) :- - {fail}. - - -:- end_object. diff --git a/Logtalk/library/experimental/bin/system.lgt b/Logtalk/library/experimental/bin/system.lgt deleted file mode 100644 index a96fe9fd5..000000000 --- a/Logtalk/library/experimental/bin/system.lgt +++ /dev/null @@ -1,107 +0,0 @@ - -:- object(system, - implements(systemp)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/6/5, - comment is 'Operating system interface for Bin Prolog.']). - - - make_directory(Directory) :- - {atom_concat('mkdir ', Directory, Command), unix(Command)}. - - - delete_directory(Directory) :- - {atom_concat('rmdir ', Directory, Command), unix(Command)}. - - - change_directory(Directory) :- - {cd(Directory)}. - - - working_directory(Directory) :- - {pwd(Chars), atom_chars(Directory, Chars)}. - - - directory_exists(Directory) :- - {fail}. - - - directory_files(Directory, Files) :- - {fail}. - - - absolute_file_name(File) :- - {fail}. - - - absolute_file_name(File, Full) :- - {fail}. - - - file_exists(File) :- - {exists_file(File)}. - - - file_modification_time(File, Time) :- - {fail}. - - - file_size(File, Size) :- - {file_size(File, Size)}. - - - file_type(File, Type) :- - {fail}. - - - file_permission(File, read) :- - {unix_access(File, 4)}. - - file_permission(File, write) :- - {unix_access(File, 2)}. - - file_permission(File, execute) :- - {unix_access(File, 1)}. - - - delete_file(File) :- - {atom_concat('rm ', File, Command), unix(Command)}. - - - rename_file(Old, New) :- - {atom_concat('mv ', Old, Temp), atom_concat(' ', New, Command), unix(Command)}. - - - symbolic_link(File, Target) :- - {fail}. - - - environment_variable(Variable, Value) :- - {unix_getenv(Variable, Value)}. - - - set_environment_variable(Variable, Value) :- - {fail}. - - - date_time(Year, Month, Day, Hours, Mins, Secs, Milisecs) :- - {fail}. - - - convert_time(Time, Year, Month, Day, Hours, Mins, Secs, Milisecs) :- - {fail}. - - - cpu_time(Time) :- - {ctime(Miliseconds), Time is Miliseconds/1000}. - - - host_name(Name) :- - {hostname(Name)}. - - -:- end_object. diff --git a/Logtalk/library/experimental/ciao/system.lgt b/Logtalk/library/experimental/ciao/system.lgt deleted file mode 100644 index e7c2ebdf3..000000000 --- a/Logtalk/library/experimental/ciao/system.lgt +++ /dev/null @@ -1,124 +0,0 @@ - -:- use_module(library(system)). -:- use_module(library(filenames)). - - -:- object(system, - implements(systemp)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/6/5, - comment is 'Operating system interface for CIAO.']). - - - make_directory(Directory) :- - {make_directory(Directory)}. - - - delete_directory(Directory) :- - {delete_directory(Directory)}. - - - change_directory(Directory) :- - {cd(Directory)}. - - - working_directory(Directory) :- - {working_directory(Directory, Directory)}. - - - directory_exists(Directory) :- - {fail}. - - - directory_files(Directory, Files) :- - {directory_files(Directory, Files)}. - - - absolute_file_name(File) :- - {absolute_file_name(File, File)}. - - - absolute_file_name(File, Full) :- - {absolute_file_name(File, Full)}. - - - file_base_name(File, Base) :- - {no_path_file_name_(File, Name), - file_name_extension(Name, Base, _)}. - - - file_name_extension(File, Extension) :- - {no_path_file_name_(File, Name), - file_name_extension(Name, _, Extension)}. - - - file_name_directory(File, Directory) :- - {no_path_file_name_(File, Name), - absolute_file_name(File, Full), - atom_concat(Directory, Name, Full)}. - - - file_exists(File) :- - {file_exists(File)}. - - - file_modification_time(File, Time) :- - {modif_time(File, Time)}. - - - file_size(File, Size) :- - {file_property(File, size(Size))}. - - - file_type(File, Type) :- - {file_property(File, type(Type))}. - - - file_permission(File, Permission) :- - {file_exists(File, Permission)}. - - - delete_file(File) :- - {delete_file(File)}. - - - rename_file(Old, New) :- - {rename_file(Old, New)}. - - - symbolic_link(File, Target) :- - {file_property(File, linkto(Target))}. - - - environment_variable(Variable, Value) :- - {getenvstr(Variable, Codes), - atom_codes(Value, Codes)}. - - - set_environment_variable(Variable, Value) :- - {atom_codes(Value, Codes), - setenvstr(Variable, Codes)}. - - - date_time(Year, Month, Day, Hours, Mins, Secs, 0) :- - {datime(datime(Year, Month, Day, Hours, Mins, Secs))}. - - - convert_time(Time, Year, Month, Day, Hours, Mins, Secs, Milisecs) :- - {datime(Time, Year, Month, Day, Hours, Mins, Secs, _, _)}. - - - cpu_time(Time) :- - {statistics(runtime, [Miliseconds| _]), - Time is Miliseconds/1000}. - - - host_name(Name) :- - {current_host(Name)}. - - -:- end_object. diff --git a/Logtalk/library/experimental/eclipse/system.lgt b/Logtalk/library/experimental/eclipse/system.lgt deleted file mode 100644 index af58cc324..000000000 --- a/Logtalk/library/experimental/eclipse/system.lgt +++ /dev/null @@ -1,129 +0,0 @@ - -:- use_module(library(calendar)). - - -:- object(system, - implements(systemp)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/6/5, - comment is 'Operating system interface for ECLiPSe.']). - - - make_directory(Directory) :- - {mkdir(Directory)}. - - - delete_directory(Directory) :- - {delete(Directory)}. - - - change_directory(Directory) :- - {cd(Directory)}. - - - working_directory(Directory) :- - {getcwd(Directory)}. - - - directory_exists(Directory) :- - {fail}. - - - directory_files(Directory, Files) :- - {read_directory(Directory, "*", _, Files)}. - - - absolute_file_name(File) :- - absolute_file_name(File, File). - - - absolute_file_name(File, Full) :- - {Rel == user -> - Abs == user % treat user specially - ; get_flag(prolog_suffix, Sufs), - (existing_file(Rel, Sufs, [], ExtRel) -> true ; ExtRel = Rel), - canonical_path_name(ExtRel, Abs)}. - - - file_base_name(File, Base) :- - {pathname(File, _, Base, _)}. - - - file_name_extension(File, Extension) :- - {pathname(File, _, _, Extension)}. - - - file_name_directory(File, Directory) :- - {pathname(File, Directory, _, _)}. - - - file_exists(File) :- - {exists(File)}. - - - file_modification_time(File, Time) :- - {get_file_info(File, mtime, Time)}. - - - file_size(File, Size) :- - {get_file_info(File, size, Size)}. - - - file_type(File, Type) :- - {get_file_info(File, mode, Mode)}, - Mode /\ 8'170000 =:= Result, - file_mode_type(Result, Type). - - file_mode_type(8'100000, regular) :- !. - file_mode_type(8'040000, directory) :- !. - file_mode_type(8'140000, socket) :- !. - file_mode_type(8'120000, symlink) :- !. - file_mode_type(_, unknown). - - - delete_file(File) :- - {delete(File)}. - - - rename_file(Old, New) :- - {rename(Old, New)}. - - - symbolic_link(File, Target) :- - {fail}. - - - environment_variable(Variable, Value) :- - {getenv(Variable, Value)}. - - - set_environment_variable(Variable, Value) :- - {fail}. - - - date_time(Year, Month, Day, Hours, Mins, Secs, 0) :- - {mjd_now(MJD), - mjd_to_date(MJD, Day/Month/Year), - mjd_to_time(MJD, Hours:Mins:Secs)}. - - - convert_time(Time, Year, Month, Day, Hours, Mins, Secs, _) :- - {unix_to_mjd(Time, MJD), - mjd_to_date(MJD, Day/Month/Year), - mjd_to_time(MJD, Hours:Mins:Secs)}. - - - cpu_time(Time) :- - {cputime(Time)}. - - - host_name(Name) :- - {get_flag(hostname, String), - atom_string(Name, String)}. - - -:- end_object. diff --git a/Logtalk/library/experimental/gprolog/system.lgt b/Logtalk/library/experimental/gprolog/system.lgt deleted file mode 100644 index 9194c6c63..000000000 --- a/Logtalk/library/experimental/gprolog/system.lgt +++ /dev/null @@ -1,115 +0,0 @@ - -:- object(system, - implements(systemp)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/6/5, - comment is 'Operating system interface for GNU Prolog.']). - - - make_directory(Directory) :- - {make_directory(Directory)}. - - - delete_directory(Directory) :- - {delete_directory(Directory)}. - - - change_directory(Directory) :- - {change_directory(Directory)}. - - - working_directory(Directory) :- - {working_directory(Directory)}. - - - directory_exists(Directory) :- - {file_exists(Directory), - file_property(File, type(directory))}. - - - directory_files(Directory, Files) :- - {directory_files(Directory, Files)}. - - - absolute_file_name(File) :- - {absolute_file_name(File, File)}. - - - absolute_file_name(File, Full) :- - {absolute_file_name(File, Full)}. - - - file_base_name(File, Base) :- - {decompose_file_name(File, _, Base, _)}. - - - file_name_extension(File, Extension) :- - {decompose_file_name(File, _, _, Extension)}. - - - file_name_directory(File, Directory) :- - {decompose_file_name(File, Directory, _, _)}. - - - file_exists(File) :- - {file_exists(File)}. - - - file_modification_time(File, Time) :- - {fail}. - - - file_size(File, Size) :- - {file_property(File, size(Size))}. - - - file_type(File, Type) :- - {file_property(File, type(Type))}. - - - file_permission(File, Permission) :- - {file_permission(File, Permission)}. - - - delete_file(File) :- - {delete_file(File)}. - - - rename_file(Old, New) :- - {rename_file(Old, New)}. - - - symbolic_link(File, Target) :- - {file_property(File, real_file_name(Target))}. - - - environment_variable(Variable, Value) :- - {environ(Variable, Value)}. - - - set_environment_variable(Variable, Value) :- - {fail}. - - - date_time(Year, Month, Day, Hours, Mins, Secs, 0) :- - {date_time(dt(Year, Month, Day, Hours, Mins, Secs))}. - - - convert_time(Time, Year, Month, Day, Hours, Mins, Secs, Milisecs) :- - {fail}. - - - cpu_time(Time) :- - {cpu_time(Miliseconds), - Time is Miliseconds/1000}. - - - host_name(Name) :- - {host_name(Name)}. - - -:- end_object. diff --git a/Logtalk/library/experimental/ifprolog/system.lgt b/Logtalk/library/experimental/ifprolog/system.lgt deleted file mode 100644 index 9e40c4da2..000000000 --- a/Logtalk/library/experimental/ifprolog/system.lgt +++ /dev/null @@ -1,109 +0,0 @@ - -:- use_module(library(system)). - - -:- object(system, - implements(systemp)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/6/5, - comment is 'Operating system interface for IF/Prolog.']). - - - make_directory(Directory) :- - {fail}. - - - delete_directory(Directory) :- - {fail}. - - - change_directory(Directory) :- - {chdir(Directory)}. - - - working_directory(Directory) :- - {getcwd(Directory)}. - - - directory_exists(Directory) :- - {fail}. - - - directory_files(Directory, Files) :- - {fail}. - - - absolute_file_name(File) :- - {fail}. - - - absolute_file_name(File, Full) :- - {fail}. - - - file_exists(File) :- - {file_test(File, read)}. - - - file_modification_time(File, Time) :- - {get_file_info(File, mtime, Time)}. - - - file_size(File, Size) :- - {get_file_info(File, size, Size)}. - - - file_type(File, Type) :- - {get_file_info(File, mode, Mode)}, - file_mode_type(Mode, Type). - - file_mode_type(ifreg, regular). - file_mode_type(ifdir, directory). - file_mode_type(iflnk, symlink). - - - file_permission(File, Permission) :- - {file_test(File, Permission)}. - - - delete_file(File) :- - {fail}. - - - rename_file(Old, New) :- - {fail}. - - - symbolic_link(File, Target) :- - {fail}. - - - environment_variable(Variable, Value) :- - {getenv(Variable, Value)}. - - - set_environment_variable(Variable, Value) :- - {fail}. - - - date_time(Year, Month, Day, Hours, Mins, Secs, 0) :- - {localtime(time, Year, Month, Day, _, _, Hours, Min, Secs)}. - - - convert_time(Time, Year, Month, Day, Hours, Mins, Secs, _) :- - {localtime(Time, Year, Month, Day, _, _, Hours, Min, Secs)}. - - - cpu_time(Time) :- - {Time is cputime}. - - - host_name(Name) :- - {current_host(Name)}. - - -:- end_object. diff --git a/Logtalk/library/experimental/k/system.lgt b/Logtalk/library/experimental/k/system.lgt deleted file mode 100644 index ab1ab3bbd..000000000 --- a/Logtalk/library/experimental/k/system.lgt +++ /dev/null @@ -1,105 +0,0 @@ - -:- object(system, - implements(systemp)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/6/5, - comment is 'Operating system interface for K-Prolog.']). - - - make_directory(Directory) :- - {atom_concat('mkdir ', Directory, Command), system(Command)}. - - - delete_directory(Directory) :- - {atom_concat('rmdir ', Directory, Command), system(Command)}. - - - change_directory(Directory) :- - {chdir(Directory)}. - - - working_directory(Directory) :- - {fail}. - - - directory_exists(Directory) :- - {fail}. - - - directory_files(Directory, Files) :- - {dir(Directory, Files, _)}. - - - absolute_file_name(File) :- - {fail}. - - - absolute_file_name(File, Full) :- - {fail}. - - - file_exists(File) :- - {fail}. - - - file_modification_time(File, Time) :- - {fail}. - - - file_size(File, Size) :- - {fail}. - - - file_type(File, Type) :- - {fail}. - - - file_permission(File, Permission) :- - {fail}. - - - delete_file(File) :- - {atom_concat('rm ', File, Command), - system(Command)}. - - - rename_file(Old, New) :- - {atom_concat('mv ', Old, Temp), - atom_concat(Temp, ' ', Temp2), - atom_concat(Temp2, New, Command), - system(Command)}. - - - symbolic_link(File, Target) :- - {fail}. - - - environment_variable(Variable, Value) :- - {getenv(Variable, Value)}. - - - set_environment_variable(Variable, Value) :- - {fail}. - - - date_time(Year, Month, Day, Hours, Mins, Secs, 0) :- - {time(Secs, Mins, Hours, Day, Month, Year, _, _, _)}. - - - convert_time(Time, Year, Month, Day, Hours, Mins, Secs, Milisecs) :- - {fail}. - - - cpu_time(Time) :- - {statistics(_, _, _, _, Time, _, _)}. - - - host_name(Name) :- - {fail}. - - -:- end_object. diff --git a/Logtalk/library/experimental/qp/system.lgt b/Logtalk/library/experimental/qp/system.lgt deleted file mode 100644 index 7bc2a9577..000000000 --- a/Logtalk/library/experimental/qp/system.lgt +++ /dev/null @@ -1,107 +0,0 @@ - -:- object(system, - implements(systemp)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/12/1, - comment is 'Operating system interface for Qu-Prolog.']). - - - make_directory(Directory) :- - {atom_concat('mkdir ', Directory, Command), os(system(Command))}. - - - delete_directory(Directory) :- - {atom_concat('rmdir ', Directory, Command), os(system(Command))}. - - - change_directory(Directory) :- - {chdir(Directory)}. - - - working_directory(Directory) :- - {getcwd(Directory)}. - - - directory_exists(Directory) :- - {fail}. - - - directory_files(Directory, Files) :- - {fail}. - - - absolute_file_name(File) :- - {fail}. - - - absolute_file_name(File, Full) :- - {fail}. - - - file_exists(File) :- - {access(File, 0, 0)}. - - - file_modification_time(File, Time) :- - {fail}. - - - file_size(File, Size) :- - {fail}. - - - file_type(File, Type) :- - {fail}. - - - file_permission(File, read) :- - {access(File, 4, 0)}. - - file_permission(File, write) :- - {access(File, 2, 0)}. - - file_permission(File, execute) :- - {access(File, 1, 0)}. - - - delete_file(File) :- - {atom_concat('rm ', File, Command), os(system(Command))}. - - - rename_file(Old, New) :- - {concat_atom([mv, Old, New], ' ', Command), os(system(Command))}. - - - symbolic_link(File, Target) :- - {fail}. - - - environment_variable(Variable, Value) :- - {fail}. - - - set_environment_variable(Variable, Value) :- - {fail}. - - - date_time(Year, Month, Day, Hours, Mins, Secs, 0) :- - {realtime(RT), localtime(RT, LT), LT = local_time(Year, Month, Day, Hours, Mins, Secs)}. - - - convert_time(Time, Year, Month, Day, Hours, Mins, Secs, _) :- - {localtime(Time, LT), LT = local_time(Year, Month, Day, Hours, Mins, Secs)}. - - - cpu_time(Time) :- - {statistics(runtime, [Start,_]), Time is Start/1000}. - - - host_name(Name) :- - {fail}. - - -:- end_object. diff --git a/Logtalk/library/experimental/quintus/system.lgt b/Logtalk/library/experimental/quintus/system.lgt deleted file mode 100644 index 55e818143..000000000 --- a/Logtalk/library/experimental/quintus/system.lgt +++ /dev/null @@ -1,102 +0,0 @@ - -:- [library(files)]. -:- [library(directory)]. -:- [library(date)]. - - -:- object(system, - implements(systemp)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/6/5, - comment is 'Operating system interface for Quintus Prolog.']). - - - make_directory(Directory) :- - {atom_concat('mkdir ', Directory, Command), unix(Command)}. - - - delete_directory(Directory) :- - {atom_concat('rmdir ', Directory, Command), unix(Command)}. - - - change_directory(Directory) :- - {unix(cd(Directory))}. - - - working_directory(Directory) :- - {absolute_file_name('.', Directory)}. - - - directory_exists(Directory) :- - {fail}. - - - directory_files(Directory, Files) :- - {file_members_of_directory(Directory, '*', Files)}. - - - absolute_file_name(File) :- - {absolute_file_name(File, File)}. - - - absolute_file_name(File, Full) :- - {absolute_file_name(File, Full)}. - - - file_exists(File) :- - {file_exists(File)}. - - - file_modification_time(File, Time) :- - {fail}. - - - file_size(File, Size) :- - {file_property(File, size, Size)}. - - - file_type(File, Type) :- - {file_property(File, type, Type)}. - - - file_permission(File, Permission) :- - {file_exists(File, Permission)}. - - - delete_file(File) :- - {delete_file(File)}. - - - rename_file(Old, New) :- - {rename_file(Old, New)}. - - - environment_variable(Variable, Value) :- - {fail}. - - - set_environment_variable(Variable, Value) :- - {fail}. - - - date_time(Year, Month, Day, Hours, Mins, Secs, 0) :- - {date(date(Day, Month, Year)), time(time(Hours, Mins, Secs))}. - - - convert_time(Time, Year, Month, Day, Hours, Mins, Secs, Milisecs) :- - {fail}. - - - cpu_time(Time) :- - {statistics(runtime, [Miliseconds| _]), Time is Miliseconds/1000}. - - - host_name(Name) :- - {fail}. - - -:- end_object. diff --git a/Logtalk/library/experimental/sicstus/system.lgt b/Logtalk/library/experimental/sicstus/system.lgt deleted file mode 100644 index 6d08cd161..000000000 --- a/Logtalk/library/experimental/sicstus/system.lgt +++ /dev/null @@ -1,100 +0,0 @@ - -:- use_module(library(system)). - - -:- object(system, - implements(systemp)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/6/5, - comment is 'Operating system interface for SICStus Prolog.']). - - - make_directory(Directory) :- - {make_directory(Directory)}. - - - delete_directory(Directory) :- - {delete_file(Directory)}. - - - change_directory(Directory) :- - {working_directory(_, Directory)}. - - - working_directory(Directory) :- - {working_directory(Directory, Directory)}. - - - directory_exists(Directory) :- - {fail}. - - - directory_files(Directory, Files) :- - {directory_files(Directory, Files)}. - - - absolute_file_name(File) :- - {absolute_file_name(File, File)}. - - - absolute_file_name(File, Full) :- - {absolute_file_name(File, Full)}. - - - file_exists(File) :- - {file_exists(File)}. - - - file_modification_time(File, Time) :- - {file_property(File, mod_time(Size))}. - - - file_size(File, Size) :- - {file_property(File, size(Size))}. - - - file_permission(File, Permission) :- - {file_exists(File, Permission)}. - - - delete_file(File) :- - {delete_file(File)}. - - - rename_file(Old, New) :- - {rename_file(Old, New)}. - - - symbolic_link(File, Target) :- - {fail}. - - - environment_variable(Variable, Value) :- - {environ(Variable, Value)}. - - - set_environment_variable(Variable, Value) :- - {fail}. - - - date_time(Year, Month, Day, Hours, Mins, Secs, 0) :- - {datime(datime(Year, Month, Day, Hours, Mins, Secs))}. - - - convert_time(Time, Year, Month, Day, Hours, Mins, Secs, _) :- - {datime(Time, datime(Year, Month, Day, Hours, Mins, Secs))}. - - - cpu_time(Time) :- - {statistics(runtime, [Miliseconds| _]), Time is Miliseconds/1000}. - - - host_name(Name) :- - {host_name(Name)}. - - -:- end_object. diff --git a/Logtalk/library/experimental/swi/system.lgt b/Logtalk/library/experimental/swi/system.lgt deleted file mode 100644 index 5a51de603..000000000 --- a/Logtalk/library/experimental/swi/system.lgt +++ /dev/null @@ -1,120 +0,0 @@ - -:- object(system, - implements(systemp)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/6/5, - comment is 'Operating system interface for SWI-Prolog.']). - - - make_directory(Directory) :- - {make_directory(Directory)}. - - - delete_directory(Directory) :- - {delete_directory(Directory)}. - - - change_directory(Directory) :- - {working_directory(_, Directory)}. - - - working_directory(Directory) :- - {working_directory(Directory, Directory)}. - - - directory_exists(Directory) :- - {exists_directory(Directory)}. - - - directory_files(Directory, Files) :- - {fail}. - - - absolute_file_name(File) :- - {is_absolute_file_name(File)}. - - - absolute_file_name(File, Full) :- - {absolute_file_name(File, Full)}. - - - file_base_name(File, Base) :- - {file_base_name(File, Name), - file_name_extension(Base, _, Name)}. - - - file_name_extension(File, Extension) :- - {file_base_name(File, Name), - file_name_extension(_, Extension, Name)}. - - - file_name_directory(File, Directory) :- - {file_directory_name(File, Directory)}. - - - file_exists(File) :- - {exists_file(File)}. - - - file_modification_time(File, Time) :- - {time_file(File, Time)}. - - - file_size(File, Size) :- - {size_file(File, Size)}. - - - file_type(File, Type) :- - {fail}. - - - file_permission(File, Permission) :- - {access_file(File, Permission)}. - - - delete_file(File) :- - {delete_file(File)}. - - - rename_file(Old, New) :- - {rename_file(Old, New)}. - - - symbolic_link(File, Target) :- - {read_link(File, _, Target)}. - - - environment_variable(Variable, Value) :- - {getenv(Variable, Value)}. - - - set_environment_variable(Variable, Value) :- - {setenv(Variable, Value)}. - - - time_stamp(Time) :- - {get_time(Time)}. - - - date_time(Year, Month, Day, Hours, Mins, Secs, Milisecs) :- - {get_time(Time), - convert_time(Time, Year, Month, Day, Hours, Mins, Secs, Milisecs)}. - - - convert_time(Time, Year, Month, Day, Hours, Mins, Secs, Milisecs) :- - {convert_time(Time, Year, Month, Day, Hours, Mins, Secs, Milisecs)}. - - - cpu_time(Time) :- - {Time is cputime}. - - - host_name(Name) :- - {fail}. - - -:- end_object. diff --git a/Logtalk/library/experimental/xsb/system.lgt b/Logtalk/library/experimental/xsb/system.lgt deleted file mode 100644 index 0c90bc798..000000000 --- a/Logtalk/library/experimental/xsb/system.lgt +++ /dev/null @@ -1,122 +0,0 @@ - -:- import path_sysop/2, path_sysop/3 from file_io. -:- import datime/1 from standard. - - -:- object(system, - implements(systemp)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/6/5, - comment is 'Operating system interface for XSB.']). - - - make_directory(Directory) :- - {path_sysop(mkdir, Directory)}. - - - delete_directory(Directory) :- - {path_sysop(rmdir, Directory)}. - - - change_directory(Directory) :- - {path_sysop(chdir, Directory)}. - - - working_directory(Directory) :- - {path_sysop(cwd, Directory)}. - - - directory_exists(Directory) :- - {path_sysop(isdir, Directory) - path_sysop(exists, Directory)}. - - - directory_files(Directory, Files) :- - {directory(Directory, Files)}. - - - absolute_file_name(File) :- - {path_sysop(isabsolute, File)}. - - - absolute_file_name(File, Full) :- - {path_sysop(expand, File, Full)}. - - - file_base_name(File, Base) :- - {path_sysop(basename, File, Base)}. - - - file_name_extension(File, Extension) :- - {path_sysop(extension, File, Extension)}. - - - file_name_directory(File, Directory) :- - {path_sysop(dirname, File, Directory)}. - - - file_exists(File) :- - {path_sysop(isplain, File) - path_sysop(exists, File)}. - - - file_modification_time(File, Time) :- - {path_sysop(modtime, File, [High, Low]), - Time is Low + High * 2 ** 24}. - - - file_size(File, Size) :- - {path_sysop(size, File, Size)}. - - - file_permission(File, read) :- - {path_sysop(readable, File)}. - - file_permission(File, write) :- - {path_sysop(writable, File)}. - - file_permission(File, execute) :- - {path_sysop(executable, File)}. - - - delete_file(File) :- - {path_sysop(rm, Directory)}. - - - rename_file(Old, New) :- - {path_sysop(rename, Old, New)}. - - - symbolic_link(File, Target) :- - {fail}. - - - environment_variable(Variable, Value) :- - {fail}. - - - set_environment_variable(Variable, Value) :- - {fail}. - - - date_time(Year, Month, Day, Hours, Mins, Secs, 0) :- - {datime(datime(Year, Month, Day, Hours, Mins, Secs))}. - - - convert_time(Time, Year, Month, Day, Hours, Mins, Secs) :- - {fail}. - - - cpu_time(Time) :- - {cputime(Time)}. - - - host_name(Name) :- - {fail}. - - -:- end_object. diff --git a/Logtalk/library/experimental/yap/system.lgt b/Logtalk/library/experimental/yap/system.lgt deleted file mode 100644 index 2be8f3237..000000000 --- a/Logtalk/library/experimental/yap/system.lgt +++ /dev/null @@ -1,104 +0,0 @@ - -:- use_module(library(system)). - - -:- object(system, - implements(systemp)). - - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2004/6/5, - comment is 'Operating system interface for YAP.']). - - - make_directory(Directory) :- - {make_directory(Directory)}. - - - delete_directory(Directory) :- - {delete_file(Directory)}. - - - change_directory(Directory) :- - {cd(Directory)}. - - - working_directory(Directory) :- - {getcwd(Directory)}. - - - directory_exists(Directory) :- - {fail}. - - - directory_files(Directory, Files) :- - {directory_files(Directory, Files)}. - - - absolute_file_name(File) :- - {absolute_file_name(File, File)}. - - - absolute_file_name(File, Full) :- - {absolute_file_name(File, Full)}. - - - file_exists(File) :- - {file_exists(File)}. - - - file_modification_time(File, Time) :- - {file_property(File, mod_time(Time))}. - - - file_size(File, Size) :- - {file_property(File, size(Size))}. - - - file_type(File, Type) :- - {file_property(File, type(Type))}. - - - file_permission(File, Permission) :- - {file_exists(File, Permission)}. - - - delete_file(File) :- - {delete_file(File)}. - - - rename_file(Old, New) :- - {rename(Old, New)}. - - - symbolic_link(File, Target) :- - {fail}. - - - environment_variable(Variable, Value) :- - {environ(Variable, Value)}. - - - set_environment_variable(Variable, Value) :- - {putenv(Variable, Value)}. - - - date_time(Year, Month, Day, Hours, Mins, Secs, 0) :- - {datime(datime(Year, Month, Day, Hours, Mins, Secs))}. - - - convert_time(Time, Year, Month, Day, Hours, Mins, Secs, Milisecs) :- - {fail}. - - - cpu_time(Time) :- - {Time is cputime}. - - - host_name(Name) :- - {host_name(Name)}. - - -:- end_object. diff --git a/Logtalk/library/float.lgt b/Logtalk/library/float.lgt deleted file mode 100644 index 318fdaa5b..000000000 --- a/Logtalk/library/float.lgt +++ /dev/null @@ -1,14 +0,0 @@ - -:- object(float, - extends(number)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Floating point numbers data type predicates.']). - - valid(Float) :- - float(Float). - -:- end_object. diff --git a/Logtalk/library/hierarchies.notes b/Logtalk/library/hierarchies.notes deleted file mode 100644 index 01b395c10..000000000 --- a/Logtalk/library/hierarchies.notes +++ /dev/null @@ -1,15 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load all entities in this group load the hierarchies_loader.lgt -utility file: - - | ?- logtalk_load(hierarchies_loader). - -These objects implement reflection predicates over class and prototype -hierarchies. diff --git a/Logtalk/library/hierarchies_loader.lgt b/Logtalk/library/hierarchies_loader.lgt deleted file mode 100644 index 14ebfe80d..000000000 --- a/Logtalk/library/hierarchies_loader.lgt +++ /dev/null @@ -1,7 +0,0 @@ - -:- initialization( - logtalk_load([ - hierarchyp, - proto_hierarchyp, proto_hierarchy, - class_hierarchyp, class_hierarchy], - [reload(skip)])). % allow for static binding diff --git a/Logtalk/library/hierarchyp.lgt b/Logtalk/library/hierarchyp.lgt deleted file mode 100644 index 009663f47..000000000 --- a/Logtalk/library/hierarchyp.lgt +++ /dev/null @@ -1,46 +0,0 @@ - -:- protocol(hierarchyp). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Common hierarchy protocol for prototype and class hierarchies.']). - - :- public(ancestor/1). - :- mode(ancestor(?object), zero_or_more). - :- info(ancestor/1, [ - comment is 'Returns, by backtracking, all object ancestors.', - argnames is ['Ancestor']]). - - :- public(ancestors/1). - :- mode(ancestors(-list), one). - :- info(ancestors/1, [ - comment is 'List of all object ancestors.', - argnames is ['Ancestors']]). - - :- public(leaf/1). - :- mode(leaf(?object), zero_or_more). - :- info(leaf/1, [ - comment is 'Returns, by backtracking, all object leaves.', - argnames is ['Leaf']]). - - :- public(leaves/1). - :- mode(leaves(-list), one). - :- info(leaves/1, [ - comment is 'List of all object leaves.', - argnames is ['Leaves']]). - - :- public(descendant/1). - :- mode(descendant(?object), zero_or_more). - :- info(descendant/1, [ - comment is 'Returns, by backtracking, all object descendants.', - argnames is ['Descendant']]). - - :- public(descendants/1). - :- mode(descendants(-list), one). - :- info(descendants/1, [ - comment is 'List of all object descendants.', - argnames is ['Descendants']]). - -:- end_protocol. diff --git a/Logtalk/library/integer.lgt b/Logtalk/library/integer.lgt deleted file mode 100644 index 5431caf66..000000000 --- a/Logtalk/library/integer.lgt +++ /dev/null @@ -1,38 +0,0 @@ - -:- object(integer, - extends(number)). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2007/4/20, - comment is 'Integer data type predicates.']). - - :- public(between/3). - :- mode(between(+integer, +integer, +integer), zero_or_one). - :- mode(between(+integer, +integer, -integer), zero_or_more). - :- info(between/3, [ - comment is 'Returns integers in the interval defined by the two first arguments.', - argnames is ['Lower', 'Upper', 'Integer']]). - - between(Lower, Upper, Integer) :- - integer(Lower), - integer(Upper), - ( var(Integer) -> - Lower =< Upper, - generate(Lower, Upper, Integer) - ; integer(Integer), - Lower =< Integer, - Integer =< Upper - ). - - generate(Lower, _, Lower). - generate(Lower, Upper, Integer) :- - Lower < Upper, - Next is Lower + 1, - generate(Next, Upper, Integer). - - valid(Integer) :- - integer(Integer). - -:- end_object. diff --git a/Logtalk/library/lgtunit.lgt b/Logtalk/library/lgtunit.lgt deleted file mode 100644 index e0fbfebc7..000000000 --- a/Logtalk/library/lgtunit.lgt +++ /dev/null @@ -1,140 +0,0 @@ - -:- object(lgtunit). - - :- info([ - version is 0.2, - author is 'Paulo Moura', - date is 2007/08/27, - comment is 'Logtalk unit test framework.']). - - :- public(succeeds/2). - :- mode(succeeds(+atom, @callable), zero_or_more). - :- info(succeeds/2, [ - comment is 'Defines a test goal which is expected to succeed.', - argnames is ['Test', 'Goal']]). - - :- public(fails/2). - :- mode(fails(+atom, @callable), zero_or_more). - :- info(fails/2, [ - comment is 'Defines a test goal which is expected to fail.', - argnames is ['Test', 'Goal']]). - - :- public(throws/3). - :- mode(throws(+atom, @callable, @nonvar), zero_or_more). - :- info(throws/3, [ - comment is 'Defines a test goal which is expected to throw an error.', - argnames is ['Test', 'Goal', 'Error']]). - - :- public(run/2). - :- mode(run(+atom, +atom), zero_or_one). - :- info(run/2, [ - comment is 'Runs the unit tests, writing the results to the specified file. Mode can be either "write" (to create a new file) or "append" (to add results to an existing file).', - argnames is ['File', 'Mode']]). - - :- public(run/0). - :- mode(run, zero_or_one). - :- info(run/0, [ - comment is 'Runs the unit tests, writing the results to the current output stream.']). - - :- protected(setup/0). - :- mode(setup, zero_or_one). - :- info(setup/0, [ - comment is 'Setup environment before running the test. Defaults to the goal true.']). - - :- protected(test/0). - :- mode(test, zero_or_one). - :- info(test/0, [ - comment is 'Executes the tests. By default, starts with the "succeeds" tests, followed by the "fails" tests, and than the "throws" tests.']). - - :- protected(cleanup/0). - :- mode(cleanup, zero_or_one). - :- info(cleanup/0, [ - comment is 'Cleanup environment after running the test. Defaults to the goal true.']). - - % by default, no test setup is needed: - setup. - - % by default, run all "succeeds", "fails", and "throws" tests: - test :- - test_succeeds, - test_fails, - test_throws. - - test_succeeds :- - forall(::succeeds(Test, Goal), test_succeeds(Test, Goal)). - - test_succeeds(Test, Goal) :- - ( catch({Goal}, _, fail) -> - passed_test(Test, Goal) - ; failed_test(Test, Goal) - ). - - test_fails :- - forall(::fails(Test, Goal), test_fail(Test, Goal)). - - test_fail(Test, Goal) :- - ( catch(\+ {Goal}, _, fail) -> - passed_test(Test, Goal) - ; failed_test(Test, Goal) - ). - - test_throws :- - forall(::throws(Test, Goal, Error), test_throws(Test, Goal, Error)). - - test_throws(Test, Goal, Error) :- - ( catch({Goal}, Ball, ((Ball = Error -> passed_test(Test, Goal); failed_test(Test, Goal)), Flag = error)) -> - ( var(Flag) -> - failed_test(Test, Goal) - ; true - ) - ; failed_test(Test, Goal) - ). - - passed_test(Test, _Goal) :- - self(Self), - write('= passed test '), writeq(Test), write(' in object '), writeq(Self), nl. - - failed_test(Test, _Goal) :- - self(Self), - write('= failed test '), writeq(Test), write(' in object '), writeq(Self), nl. - - % by default, no test cleanup is needed: - cleanup. - - run(File, Mode) :- - open(File, Mode, Stream), - current_output(Output), - set_output(Stream), - ::run, - set_output(Output), - close(Stream). - - run :- - self(Self), - write('% running tests from object '), writeq(Self), nl, - ( catch(::setup, Error, (broken(setup, Error), fail)) -> - ( catch(::test, Error, (broken(test, Error), Flag = error)) -> - do_cleanup, - ( var(Flag) -> - write('% completed tests from object '), writeq(Self), nl - ; write('% test run failed'), nl - ) - ; do_cleanup, - write('! test run failed for object '), writeq(Self), nl, - write('% test run failed'), nl - ) - ; write('! test setup failed for object '), writeq(Self), nl - ). - - do_cleanup :- - self(Self), - ( catch(::cleanup, Error, (broken(cleanup, Error), fail)) -> - true - ; write('! test cleanup failed for object '), writeq(Self), nl - ). - - broken(Step, Error) :- - self(Self), - write('! broken '), write(Step), write(' for object '), writeq(Self), write(': '), write(Error), nl. - -:- end_object. diff --git a/Logtalk/library/lgtunit.notes b/Logtalk/library/lgtunit.notes deleted file mode 100644 index d214528c3..000000000 --- a/Logtalk/library/lgtunit.notes +++ /dev/null @@ -1,15 +0,0 @@ - -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -The "lgtunit.lgt" file contains a preliminary framework for defining -and running unit tests in Logtalk. - -The unit tests framework is inspired on the works of Joachim Schimpf -(ECLiPSe library "test_util") and Jan Wielemaker (SWI-Prolog "plunit" -package). diff --git a/Logtalk/library/list.lgt b/Logtalk/library/list.lgt deleted file mode 100644 index e93b0c1d8..000000000 --- a/Logtalk/library/list.lgt +++ /dev/null @@ -1,213 +0,0 @@ - -:- object(list, - implements(listp), - extends(compound)). - - :- info([ - version is 1.3, - author is 'Paulo Moura', - date is 2006/12/21, - comment is 'List predicates.']). - - :- public(as_difflist/2). - :- mode(as_difflist(+list, -list), one). - :- info(as_difflist/2, - [comment is 'Converts a list to a difference list.', - argnames is ['List', 'Diffist']]). - - - append([], List, List). - append([Head| Tail], List, [Head| Tail2]) :- - append(Tail, List, Tail2). - - - as_difflist([], Back-Back). - as_difflist([Head| Tail], [Head| Tail2]-Back) :- - as_difflist(Tail, Tail2-Back). - - - delete([], _, []). - delete([Head| Tail], Element, Remaining) :- - ( Head == Element -> - delete(Tail, Element, Remaining) - ; Remaining = [Head| Tail2], - delete(Tail, Element, Tail2) - ). - - delete_matches([], _, []). - delete_matches([Head| Tail], Element, Remaining) :- - ( \+ \+ Head = Element -> - delete_matches(Tail, Element, Remaining) - ; Remaining = [Head| Tail2], - delete_matches(Tail, Element, Tail2) - ). - - empty(List) :- - List == []. - - flatten(List, Flatted) :- - flatten(List, [], Flatted). - - flatten(Var, Tail, [Var| Tail]) :- - var(Var), - !. - flatten([], Flatted, Flatted) :- - !. - flatten([Head| Tail], List, Flatted) :- - !, - flatten(Tail, List, Aux), - flatten(Head, Aux, Flatted). - flatten(Head, Tail, [Head| Tail]). - - keysort(List, Sorted) :- - {keysort(List, Sorted)}. - - last([Head| Tail], Last) :- - last(Tail, Head, Last). - - last([], Last, Last). - last([Head| Tail], _, Last) :- - last(Tail, Head, Last). - - length(List, Length) :- - ( integer(Length) -> - Length >= 0, - make_list(Length, List) - ; length(List, 0, Length) - ). - - make_list(0, []):- - !. - make_list(N, [_| Tail]):- - M is N-1, - make_list(M, Tail). - - length([], Length, Length). - length([_| Tail], Acc, Length) :- - Acc2 is Acc + 1, - length(Tail, Acc2, Length). - - max([N| Ns], Max) :- - max(Ns, N, Max). - - max([], Max, Max). - max([N| Ns], Aux, Max) :- - ( N @> Aux -> - max(Ns, N, Max) - ; max(Ns, Aux, Max) - ). - - member(Element, [Element| _]). - member(Element, [_| List]) :- - member(Element, List). - - - memberchk(Element, [Element| _]) :- - !. - memberchk(Element, [_| List]) :- - memberchk(Element, List). - - min([N| Ns], Min) :- - min(Ns, N, Min). - - min([], Min, Min). - min([N| Ns], Aux, Min) :- - ( N @< Aux -> - min(Ns, N, Min) - ; min(Ns, Aux, Min) - ). - - new([]). - - nextto(X, Y, [X, Y| _]). - nextto(X, Y, [_| Tail]) :- - nextto(X, Y, Tail). - - nth0(Nth, List, Element) :- - nth(Element, List, 0, Nth, _). - - nth0(Nth, List, Element, Tail) :- - nth(Element, List, 0, Nth, Tail). - - nth1(Nth, List, Element) :- - nth(Element, List, 1, Nth, _). - - nth1(Nth, List, Element, Tail) :- - nth(Element, List, 1, Nth, Tail). - - nth(Element, List, Acc, Nth, Tail) :- - ( integer(Nth), - Nth >= Acc, - nth_aux(NthElement, List, Acc, Nth, Tail) -> - Element = NthElement - ; var(Nth), - nth_aux(Element, List, Acc, Nth, Tail) - ). - - nth_aux(Head, [Head| Tail], Position, Position, Tail). - nth_aux(Head, [_| List], Count, Position, Tail) :- - Count2 is Count + 1, - nth_aux(Head, List, Count2, Position, Tail). - - permutation(List, Permutation) :- - same_length(List, Permutation), - permutation2(List, Permutation). - - permutation2([], []). - permutation2(List, [Head| Tail]) :- - select(Head, List, Remaining), - permutation2(Remaining, Tail). - - prefix([], _). - prefix([Element| Tail], [Element| Tail2]) :- - prefix(Tail, Tail2). - - reverse(List, Reversed) :- - reverse(List, [], Reversed, Reversed). - - reverse([], Reversed, Reversed, []). - reverse([Head| Tail], List, Reversed, [_| Bound]) :- - reverse(Tail, [Head| List], Reversed, Bound). - - same_length([], []). - same_length([_| Tail1], [_| Tail2]) :- - same_length(Tail1, Tail2). - - select(Head, [Head| Tail], Tail). - select(Head, [Head2| Tail], [Head2| Tail2]) :- - select(Head, Tail, Tail2). - - sort(List, Sorted) :- - {sort(List, Sorted)}. - - sublist(List, List). - sublist(Sublist, [Head| Tail]):- - sublist(Tail, Head, Sublist). - - sublist(Sublist, _, Sublist). - sublist([Head| Tail], _, Sublist):- - sublist(Tail, Head, Sublist). - sublist([Head| Tail], Element, [Element| Sublist]):- - sublist(Tail, Head, Sublist). - - subtract([], _, []). - subtract([Head| Tail], List, Rest) :- - ( ::memberchk(Head, List) -> - subtract(Tail, List, Rest) - ; Rest = [Head| Tail2], - subtract(Tail, List, Tail2) - ). - - suffix(List, List). - suffix(List, [_| Tail]) :- - suffix(List, Tail). - - valid(List) :- - nonvar(List), - \+ \+ valid2(List). - - valid2([]). - valid2([_| List]) :- - valid2(List). - -:- end_object. diff --git a/Logtalk/library/list1.lgt b/Logtalk/library/list1.lgt deleted file mode 100644 index 3f949b7a8..000000000 --- a/Logtalk/library/list1.lgt +++ /dev/null @@ -1,21 +0,0 @@ - -:- object(list(_Type), - extends(list)). - - :- info([ - version is 1.01, - author is 'Paulo Moura', - date is 2006/4/25, - comment is 'List predicates with elements constrained to a single type.']). - - valid(List) :- - nonvar(List), - parameter(1, Type), - \+ \+ valid(List, Type). - - valid([], _). - valid([Value| List], Type) :- - Type::valid(Value), - valid(List, Type). - -:- end_object. diff --git a/Logtalk/library/listing.lgt b/Logtalk/library/listing.lgt deleted file mode 100644 index 2d55be120..000000000 --- a/Logtalk/library/listing.lgt +++ /dev/null @@ -1,128 +0,0 @@ - -:- category(listing). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2007/2/8, - comment is 'Listing predicates.']). - - :- public(listing/0). - :- mode(listing, one). - :- info(listing/0, [ - comment is 'Lists all clauses of all dynamic predicates to the current output stream.']). - - :- public(listing/1). - :- mode(listing(+predicate_indicator), one). - :- info(listing/1, [ - comment is 'Lists all clauses of a dynamic predicate to the current output stream.', - argnames is ['Predicate']]). - - :- public(portray_clause/1). - :- mode(portray_clause(+clause), one). - :- info(portray_clause/1, [ - comment is 'Pretty prints a clause to the current output stream.', - argnames is ['Clause']]). - - :- protected(portray_body/1). - :- mode(portray_body(+callable), one). - :- info(portray_body/1, [ - comment is 'Pretty prints a clause body to the current output stream.', - argnames is ['Body']]). - - :- protected(spaces/1). - :- mode(spaces(+integer), one). - :- info(spaces/1, [ - comment is 'Prints N spaces to the current output stream.', - argnames is ['N']]). - - listing :- - ::current_predicate(Functor/Arity), - functor(Head, Functor, Arity), - ::predicate_property(Head, (dynamic)), - nl, - listing_properties(Head, Functor, Arity), - listing_clauses(Head, Functor, Arity), - fail. - listing. - - listing(Functor/Arity) :- - atom(Functor), - integer(Arity), - ::current_predicate(Functor/Arity), - functor(Head, Functor, Arity), - ::predicate_property(Head, (dynamic)), !, - listing_properties(Head, Functor, Arity), - listing_clauses(Head, Functor, Arity). - - listing_properties(Head, Functor, Arity) :- - ::predicate_property(Head, public), - write(':- public('), writeq(Functor/Arity), write(').'), - fail. - listing_properties(Head, Functor, Arity) :- - ::predicate_property(Head, protected), - write(':- protected('), writeq(Functor/Arity), write(').'), - fail. - listing_properties(Head, Functor, Arity) :- - ::predicate_property(Head, private), - write(':- private('), writeq(Functor/Arity), write(').'), - fail. - listing_properties(Head, _, _) :- - ::predicate_property(Head, declared_in(DclEntity)), - write(' % '), writeq(declared_in(DclEntity)), nl, - fail. - listing_properties(Head, Functor, Arity) :- - ::predicate_property(Head, (dynamic)), - write(':- dynamic('), writeq(Functor/Arity), write(').'), - fail. - listing_properties(Head, _, _) :- - ( ::clause(Head, _) -> - nl - ; write(' % no local clauses found'), nl - ), - fail. - listing_properties(Head, _, _) :- - ::predicate_property(Head, meta_predicate(Mode)), - write(':- meta_predicate('), writeq(Mode), write(').'), nl, - fail. - listing_properties(Head, Functor, Arity) :- - ::predicate_property(Head, synchronized), - write(':- synchronized('), writeq(Functor/Arity), write(').'), nl, - fail. - listing_properties(Head, Functor, Arity) :- - ::predicate_property(Head, alias(OFunctor/OArity)), - write(':- alias('), writeq(OFunctor/OArity), write(', '), writeq(Functor/Arity), write(').'), nl, - fail. - listing_properties(Head, _, _) :- - ::predicate_property(Head, non_terminal(NonTerminal//NTArity)) -> - write('% clauses resulting from the expansion of the non-terminal '), writeq(NonTerminal//NTArity), nl, - fail. - listing_properties(_, _, _). - - listing_clauses(Head, _, _) :- - ::clause(Head, Body), - ::portray_clause((Head :- Body)), - fail. - listing_clauses(_). - - portray_clause((Head :- true)) :- - !, - numbervars(Head, 0, _), - write_term(Head, [numbervars(true), quoted(true)]), write('.'), nl. - portray_clause((Head :- Body)) :- - numbervars((Head:-Body), 0, _), - write_term(Head, [numbervars(true), quoted(true)]), write(' :-'), nl, - ::portray_body(Body), - write('.'), nl. - - portray_body(Body) :- - spaces(4), write_term(Body, [numbervars(true), quoted(true)]). - - spaces(0) :- - !. - spaces(N) :- - put_char(' '), - N2 is N - 1, - spaces(N2). - -:- end_category. diff --git a/Logtalk/library/listp.lgt b/Logtalk/library/listp.lgt deleted file mode 100644 index 32ad4ecc7..000000000 --- a/Logtalk/library/listp.lgt +++ /dev/null @@ -1,171 +0,0 @@ - -:- protocol(listp). - - :- info([ - version is 1.2, - author is 'Paulo Moura', - date is 2004/5/9, - comment is 'List protocol.']). - - :- public(append/3). - :- mode(append(?list, ?list, ?list), zero_or_more). - :- info(append/3, [ - comment is 'Appends two lists.', - argnames is ['List1', 'List2', 'List']]). - - :- public(delete/3). - :- mode(delete(@list, @term, ?list), one). - :- info(delete/3, - [comment is 'Deletes from a list all ocurrences of an element returning the list of remaining elements.', - argnames is ['List', 'Element', 'Remaining']]). - - :- public(delete_matches/3). - :- mode(delete_matches(@list, @term, ?list), one). - :- info(delete_matches/3, - [comment is 'Deletes all matching elements from a list, returning the list of remaining elements.', - argnames is ['List', 'Element', 'Remaining']]). - - :- public(empty/1). - :- mode(empty(@list), zero_or_one). - :- info(empty/1, - [comment is 'True if the argument is an empty list.', - argnames is ['List']]). - - :- public(flatten/2). - :- mode(flatten(+list, -list), one). - :- info(flatten/2, - [comment is 'Flattens a list of lists into a list.', - argnames is ['List', 'Flatted']]). - - :- public(keysort/2). - :- mode(keysort(+list, -list), one). - :- info(keysort/2, - [comment is 'Sorts a list of key-value pairs in ascending order.', - argnames is ['List', 'Sorted']]). - - :- public(last/2). - :- mode(last(?list, ?term), zero_or_more). - :- info(last/2, - [comment is 'List last element (if it exists).', - argnames is ['List', 'Last']]). - - :- public(length/2). - :- mode(length(?list, ?integer), zero_or_more). - :- info(length/2, - [comment is 'List length.', - argnames is ['List', 'Length']]). - - :- public(max/2). - :- mode(max(+list, -term), zero_or_one). - :- info(max/2, - [comment is 'Determines the list maximum value using standard order. Fails if the list is empty.', - argnames is ['List', 'Maximum']]). - - :- public(member/2). - :- mode(member(?term, ?list), zero_or_more). - :- info(member/2, - [comment is 'Element is a list member.', - argnames is ['Element', 'List']]). - - :- public(memberchk/2). - :- mode(memberchk(?term, ?list), zero_or_one). - :- info(memberchk/2, - [comment is 'Checks if a term is a member of a list.', - argnames is ['Element', 'List']]). - - :- public(min/2). - :- mode(min(+list, -term), zero_or_one). - :- info(min/2, - [comment is 'Determines the minimum value in a list using standard order. Fails if the list is empty.', - argnames is ['List', 'Minimum']]). - - :- public(nextto/3). - :- mode(nextto(?term, ?term, ?list), zero_or_more). - :- info(nextto/3, [ - comment is 'X and Y are consecutive elements in List.', - argnames is ['X', 'Y', 'List']]). - - :- public(nth0/3). - :- mode(nth0(?integer, ?list, ?term), zero_or_more). - :- info(nth0/3, [ - comment is 'Nth element of a list (counting from zero).', - argnames is ['Nth', 'List', 'Element']]). - - :- public(nth0/4). - :- mode(nth0(?integer, ?list, ?term, ?list), zero_or_more). - :- info(nth0/4, [ - comment is 'Nth element of a list (counting from zero).', - argnames is ['Nth', 'List', 'Element', 'Residue']]). - - :- public(nth1/3). - :- mode(nth1(?integer, ?list, ?term), zero_or_more). - :- info(nth1/3, [ - comment is 'Nth element of a list (counting from one).', - argnames is ['Nth', 'List', 'Element']]). - - :- public(nth1/4). - :- mode(nth1(?integer, ?list, ?term, ?list), zero_or_more). - :- info(nth1/4, [ - comment is 'Nth element of a list (counting from zero).', - argnames is ['Nth', 'List', 'Element', 'Residue']]). - - :- public(permutation/2). - :- mode(permutation(?list, ?list), zero_or_more). - :- info(permutation/2, - [comment is 'The two lists are a permutation of the same list.', - argnames is ['List', 'Permutation']]). - - :- public(prefix/2). - :- mode(prefix(?list, +list), zero_or_more). - :- info(prefix/2, - [comment is 'Prefix is a prefix of List.', - argnames is ['Prefix', 'List']]). - - :- public(reverse/2). - :- mode(reverse(+list, ?list), zero_or_one). - :- mode(reverse(?list, +list), zero_or_one). - :- mode(reverse(-list, -list), one_or_more). - :- info(reverse/2, - [comment is 'Reverses a list.', - argnames is ['List', 'Reversed']]). - - :- public(same_length/2). - :- mode(same_length(+list, ?list), zero_or_one). - :- mode(same_length(?list, +list), zero_or_one). - :- mode(same_length(-list, -list), one_or_more). - :- info(same_length/2, - [comment is 'The two lists have the same length.', - argnames is ['List1', 'List2']]). - - :- public(select/3). - :- mode(select(?term, +list, ?list), zero_or_more). - :- mode(select(?term, ?list, +list), zero_or_more). - :- info(select/3, - [comment is 'Selects an element from a list, returning the list of remaining elements.', - argnames is ['Element', 'List', 'Remaining']]). - - :- public(sort/2). - :- mode(sort(+list, -list), one). - :- info(sort/2, - [comment is 'Sorts a list in ascending order.', - argnames is ['List', 'Sorted']]). - - :- public(sublist/2). - :- mode(sublist(?list, +list), zero_or_more). - :- info(sublist/2, - [comment is 'The first list is a sublist of the second.', - argnames is ['Sublist', 'List']]). - - :- public(subtract/3). - :- mode(subtract(+list, +list, -list), one). - :- info(subtract/3, - [comment is 'Removes all elements in the second list from the first list, returning the list of remaining elements.', - argnames is ['List', 'Elements', 'Remaining']]). - - :- public(suffix/2). - :- mode(suffix(?list, +list), zero_or_more). - :- info(suffix/2, - [comment is 'Suffix is a suffix of List.', - argnames is ['Suffix', 'List']]). - -:- end_protocol. diff --git a/Logtalk/library/loop.lgt b/Logtalk/library/loop.lgt deleted file mode 100644 index 978d81de9..000000000 --- a/Logtalk/library/loop.lgt +++ /dev/null @@ -1,60 +0,0 @@ - -:- object(loop, - implements(loopp)). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2006/9/17, - comment is 'Loop control structures predicates.']). - - :- meta_predicate(whiledo(::, ::)). - whiledo(Condition, Action) :- - ( call(Condition) -> - \+ \+ call(Action), - whiledo(Condition, Action) - ; true - ). - - :- meta_predicate(dowhile(::, ::)). - dowhile(Action, Condition) :- - \+ \+ call(Action), - whiledo(Condition, Action). - - :- meta_predicate(forto(*, *, ::)). - forto(First, Last, Call) :- - ( First =< Last -> - \+ \+ call(Call), - Next is First + 1, - forto(Next, Last, Call) - ; true - ). - - :- meta_predicate(forto(*, *, *, ::)). - forto(Count, First, Last, Call) :- - ( First =< Last -> - \+ \+ (Count = First, call(Call)), - Next is First + 1, - forto(Count, Next, Last, Call) - ; true - ). - - :- meta_predicate(fordownto(*, *, ::)). - fordownto(First, Last, Call) :- - ( First >= Last -> - \+ \+ call(Call), - Next is First - 1, - fordownto(Next, Last, Call) - ; true - ). - - :- meta_predicate(fordownto(*, *, *, ::)). - fordownto(Count, First, Last, Call) :- - ( First >= Last -> - \+ \+ (Count = First, call(Call)), - Next is First - 1, - fordownto(Count, Next, Last, Call) - ; true - ). - -:- end_object. diff --git a/Logtalk/library/loopp.lgt b/Logtalk/library/loopp.lgt deleted file mode 100644 index 1f629a4ee..000000000 --- a/Logtalk/library/loopp.lgt +++ /dev/null @@ -1,52 +0,0 @@ - -:- protocol(loopp). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2006/9/17, - comment is 'Loop control structures protocol.']). - - :- public(dowhile/2). - :- meta_predicate(dowhile(::, ::)). - :- mode(dowhile(+callable, @callable), zero_or_one). - :- info(dowhile/2, [ - comment is 'Do Action while Condition is true.', - argnames is ['Action', 'Condition']]). - - :- public(forto/3). - :- meta_predicate(forto(*, *, ::)). - :- mode(forto(+integer, +integer, @callable), zero_or_one). - :- info(forto/3, [ - comment is 'Counting from First to Last do Call.', - argnames is ['First', 'Last', 'Call']]). - - :- public(forto/4). - :- meta_predicate(forto(*, *, *, ::)). - :- mode(forto(-integer, +integer, +integer, @callable), zero_or_one). - :- info(forto/4, [ - comment is 'Do Call counting from First to Last and instantiating Count to each sucessive value.', - argnames is ['Count', 'First', 'Last', 'Call']]). - - :- public(fordownto/3). - :- meta_predicate(fordownto(*, *, ::)). - :- mode(fordownto(+integer, +integer, @callable), zero_or_one). - :- info(fordownto/3, [ - comment is 'Counting from First to Last do Call.', - argnames is ['First', 'Last', 'Call']]). - - :- public(fordownto/4). - :- meta_predicate(fordownto(*, *, *, ::)). - :- mode(fordownto(-integer, +integer, +integer, @callable), zero_or_one). - :- info(fordownto/4, [ - comment is 'Do Call counting from First to Last and instantiating Count to each sucessive value.', - argnames is ['Count', 'First', 'Last', 'Call']]). - - :- public(whiledo/2). - :- meta_predicate(whiledo(::, ::)). - :- mode(whiledo(+callable, @callable), zero_or_one). - :- info(whiledo/2, [ - comment is 'While Condition is true do Action.', - argnames is ['Condition', 'Action']]). - -:- end_protocol. diff --git a/Logtalk/library/meta.lgt b/Logtalk/library/meta.lgt deleted file mode 100644 index 5e7c54ff2..000000000 --- a/Logtalk/library/meta.lgt +++ /dev/null @@ -1,44 +0,0 @@ - -:- object(meta, - implements(metap)). - - :- info([ - version is 2.0, - date is 2006/9/17, - author is 'Paulo Moura', - comment is 'Some useful meta-predicates.']). - - callable(Term) :- - nonvar(Term), - functor(Term, Functor, _), - atom(Functor). - - :- meta_predicate(filter(1, *, *)). - filter(_, [], []) :- !. - filter(Closure, [Arg| Args], List) :- - ( call(Closure, Arg) -> - List = [Arg| Args2] - ; List = Args2 - ), - filter(Closure, Args, Args2). - - :- meta_predicate(ignore(::)). - ignore(Goal) :- - ( call(Goal) -> - true - ; true - ). - - :- meta_predicate(map(2, *, *)). - map(_, [], []). - map(Closure, [Old| Olds], [New| News]) :- - call(Closure, Old, New), - map(Closure, Olds, News). - - :- meta_predicate(succeeds(1, *)). - succeeds(_, []). - succeeds(Closure, [Head| Tail]) :- - call(Closure, Head), - succeeds(Closure, Tail). - -:- end_object. diff --git a/Logtalk/library/metap.lgt b/Logtalk/library/metap.lgt deleted file mode 100644 index 465fe7225..000000000 --- a/Logtalk/library/metap.lgt +++ /dev/null @@ -1,44 +0,0 @@ - -:- protocol(metap). - - :- info([ - version is 3.0, - date is 2006/9/17, - author is 'Paulo Moura', - comment is 'Useful meta-predicates protocol.']). - - :- public(callable/1). - :- mode(callable(@term), zero_or_one). - :- info(callable/1, [ - comment is 'True if the argument can be called as a goal.', - argnames is ['Term']]). - - :- public(filter/3). - :- meta_predicate(filter(1, *, *)). - :- mode(filter(+callable, +list, -list), one). - :- info(filter/3, [ - comment is 'Returns a list of all list elements that satisfy a predicate.', - argnames is ['Predicate', 'In', 'Out']]). - - :- public(ignore/1). - :- meta_predicate(ignore(::)). - :- mode(ignore(@callable), one). - :- info(ignore/1, [ - comment is 'Calls Goal once but always succeeds, even if Goal fails.', - argnames is ['Goal']]). - - :- public(map/3). - :- meta_predicate(map(2, *, *)). - :- mode(map(+callable, ?list, ?list), zero_or_more). - :- info(map/3, [ - comment is 'Maps a predicate over a list of elements.', - argnames is ['Predicate', 'In', 'Out']]). - - :- public(succeeds/2). - :- meta_predicate(succeeds(1, *)). - :- mode(succeeds(+callable, +list), zero_or_more). - :- info(succeeds/2, [ - comment is 'True if the predicate succeeds for each list element.', - argnames is ['Predicate', 'List']]). - -:- end_protocol. diff --git a/Logtalk/library/metapredicates.notes b/Logtalk/library/metapredicates.notes deleted file mode 100644 index 4b3321583..000000000 --- a/Logtalk/library/metapredicates.notes +++ /dev/null @@ -1,18 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load all entities in this group load the metapredicates_loader.lgt -utility file: - - | ?- logtalk_load(metapredicates_loader). - -The object loop implements several kinds of loops typical of imperative -languages. - -The object meta implements common Prolog metapredicates like apply/2 -and map/3. diff --git a/Logtalk/library/metapredicates_loader.lgt b/Logtalk/library/metapredicates_loader.lgt deleted file mode 100644 index 9082a6e81..000000000 --- a/Logtalk/library/metapredicates_loader.lgt +++ /dev/null @@ -1,5 +0,0 @@ - -:- initialization( - logtalk_load( - [metap, meta, loopp, loop], - [reload(skip)])). % allow for static binding diff --git a/Logtalk/library/monitor.lgt b/Logtalk/library/monitor.lgt deleted file mode 100644 index dceabb086..000000000 --- a/Logtalk/library/monitor.lgt +++ /dev/null @@ -1,52 +0,0 @@ - -:- category(monitor, - implements(monitorp)). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2004/3/31, - comment is 'Monitor predicates.']). - - :- private(spy_point_/4). - :- dynamic(spy_point_/4). - :- mode(spy_point_(?event, ?object, ?callable, ?object), zero_or_more). - :- info(spy_point_/4, [ - comment is 'Stores current spy points.', - argnames is ['Event', 'Object', 'Message', 'Sender']]). - - monitor_activated :- - self(Self), - once(current_event(_, _, _, _, Self)). - - activate_monitor :- - self(Self), - abolish_events(before, _, _, _, Self), - abolish_events(after, _, _, _, Self), - forall( - ::spy_point_(Event, Object, Message, Sender), - define_events(Event, Object, Message, Sender, Self)). - - suspend_monitor :- - self(Self), - abolish_events(before, _, _, _, Self), - abolish_events(after, _, _, _, Self). - - reset_monitor :- - self(Self), - abolish_events(before, _, _, _, Self), - abolish_events(after, _, _, _, Self), - ::retractall(spy_point_(_, _, _, _)). - - spy_point(Event, Object, Message, Sender) :- - ::spy_point_(Event, Object, Message, Sender). - - set_spy_point(Event, Object, Message, Sender) :- - ::retractall(spy_point_(Event, Object, Message, Sender)), - once((var(Event); Event = before; Event = after)), - ::assertz(spy_point_(Event, Object, Message, Sender)). - - del_spy_points(Event, Object, Message, Sender) :- - ::retractall(spy_point_(Event, Object, Message, Sender)). - -:- end_category. diff --git a/Logtalk/library/monitorp.lgt b/Logtalk/library/monitorp.lgt deleted file mode 100644 index 34b895315..000000000 --- a/Logtalk/library/monitorp.lgt +++ /dev/null @@ -1,48 +0,0 @@ - -:- protocol(monitorp). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Monitor protocol.']). - - :- public(monitor_activated/0). - :- mode(monitor_activated, zero_or_one). - :- info(monitor_activated/0, [ - comment is 'True if monitor is currently active.']). - - :- public(activate_monitor/0). - :- mode(activate_monitor, one). - :- info(activate_monitor/0, [ - comment is 'Activates all spy points and start monitoring.']). - - :- public(suspend_monitor/0). - :- mode(suspend_monitor, one). - :- info(suspend_monitor/0, [ - comment is 'Suspends monitoring, deactivating all spy points.']). - - :- public(reset_monitor/0). - :- mode(reset_monitor, one). - :- info(reset_monitor/0, [ - comment is 'Resets monitor, deactivating and deleting all spy points.']). - - :- public(spy_point/4). - :- mode(spy_point(?event, ?object, ?callable, ?object), zero_or_more). - :- info(spy_point/4, [ - comment is 'Current spy point.', - argnames is ['Event', 'Object', 'Message', 'Sender']]). - - :- public(set_spy_point/4). - :- mode(set_spy_point(?event, ?object, ?callable, ?object), one). - :- info(set_spy_point/4, [ - comment is 'Sets a spy point.', - argnames is ['Event', 'Object', 'Message', 'Sender']]). - - :- public(del_spy_points/4). - :- mode(del_spy_points(@event, @object, @callable, @object), one). - :- info(del_spy_points/4, [ - comment is 'Deletes all matching spy points.', - argnames is ['Event', 'Object', 'Message', 'Sender']]). - -:- end_protocol. diff --git a/Logtalk/library/natural.lgt b/Logtalk/library/natural.lgt deleted file mode 100644 index d87ef1148..000000000 --- a/Logtalk/library/natural.lgt +++ /dev/null @@ -1,20 +0,0 @@ - -:- object(natural, - extends(integer)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Natural numbers data type predicates.']). - - between(Lower, Upper, Integer) :- - integer(Lower), - Lower > 0, - ^^between(Lower, Upper, Integer). - - valid(Natural) :- - integer(Natural), - Natural > 0. - -:- end_object. diff --git a/Logtalk/library/number.lgt b/Logtalk/library/number.lgt deleted file mode 100644 index 267d4011d..000000000 --- a/Logtalk/library/number.lgt +++ /dev/null @@ -1,14 +0,0 @@ - -:- object(number, - extends(atomic)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Number data type predicates.']). - - valid(Number) :- - number(Number). - -:- end_object. diff --git a/Logtalk/library/numberlist.lgt b/Logtalk/library/numberlist.lgt deleted file mode 100644 index 3ed4a9788..000000000 --- a/Logtalk/library/numberlist.lgt +++ /dev/null @@ -1,68 +0,0 @@ - -:- object(numberlist, - implements(numberlistp), - extends(list)). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2007/4/20, - comment is 'List of numbers predicates.']). - - average([], 0.0). - average([N| Ns], Average) :- - average(Ns, 1, N, Average). - - average([], Length, Sum, Average) :- - Average is Sum / Length. - average([N| Ns], Lacc, Sacc, Average) :- - Lacc2 is Lacc + 1, - Sacc2 is Sacc + N, - average(Ns, Lacc2, Sacc2, Average). - - min([N| Ns], Min) :- - min(Ns, N, Min). - - min([], Min, Min). - min([N| Ns], Aux, Min) :- - ( N < Aux -> - min(Ns, N, Min) - ; min(Ns, Aux, Min) - ). - - max([N| Ns], Max) :- - max(Ns, N, Max). - - max([], Max, Max). - max([N| Ns], Aux, Max) :- - ( N > Aux -> - max(Ns, N, Max) - ; max(Ns, Aux, Max) - ). - - product(List, Product) :- - product(List, 1, Product). - - product([], Product, Product). - product([N| Ns], Acc, Product) :- - Acc2 is Acc * N, - product(Ns, Acc2, Product). - - sum(List, Sum) :- - sum(List, 0, Sum). - - sum([], Sum, Sum). - sum([N| Ns], Acc, Sum) :- - Acc2 is Acc + N, - sum(Ns, Acc2, Sum). - - valid(List) :- - nonvar(List), - \+ \+ valid2(List). - - valid2([]). - valid2([Head| Tail]) :- - number(Head), - valid2(Tail). - -:- end_object. diff --git a/Logtalk/library/numberlistp.lgt b/Logtalk/library/numberlistp.lgt deleted file mode 100644 index b5216975c..000000000 --- a/Logtalk/library/numberlistp.lgt +++ /dev/null @@ -1,28 +0,0 @@ - -:- protocol(numberlistp). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2007/4/20, - comment is 'List of numbers protocol.']). - - :- public(product/2). - :- mode(product(+list(number), ?number), zero_or_one). - :- info(product/2, - [comment is 'Calculates the product of all list values.', - argnames is ['List', 'Product']]). - - :- public(sum/2). - :- mode(sum(+list(number), ?number), zero_or_one). - :- info(sum/2, - [comment is 'Calculates the sum of all list values.', - argnames is ['List', 'Sum']]). - - :- public(average/2). - :- mode(average(+list(number), ?float), zero_or_one). - :- info(average/2, - [comment is 'Calculates the average of a list of values.', - argnames is ['List', 'Average']]). - -:- end_protocol. diff --git a/Logtalk/library/observer.lgt b/Logtalk/library/observer.lgt deleted file mode 100644 index 689e044b1..000000000 --- a/Logtalk/library/observer.lgt +++ /dev/null @@ -1,18 +0,0 @@ - -:- category(observer). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 03/02/09, - comment is 'Smalltalk dependent protocol.']). - - :- public(update/1). - :- mode(update(?nonvar), zero_or_one). - :- info(update/1, - [comment is 'Called when an observed object is updated.', - argnames is ['Change']]). - - update(_). - -:- end_category. diff --git a/Logtalk/library/proto_hierarchy.lgt b/Logtalk/library/proto_hierarchy.lgt deleted file mode 100644 index d5da9c7b2..000000000 --- a/Logtalk/library/proto_hierarchy.lgt +++ /dev/null @@ -1,79 +0,0 @@ - -:- category(proto_hierarchy, - implements(proto_hierarchyp)). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2006/2/20, - comment is 'Prototype hierarchy predicates.']). - - parent(Parent) :- - self(Self), - extends_object(Self, Parent). - - parents(Parents) :- - self(Self), - findall(Parent, extends_object(Self, Parent), Parents). - - ancestor(Ancestor) :- - self(Self), - ancestor(Self, Ancestor). - - ancestor(Self, Ancestor) :- - extends_object(Self, Ancestor). - ancestor(Self, Ancestor) :- - extends_object(Self, Parent), - ancestor(Parent, Ancestor). - - ancestors(Ancestors) :- - self(Self), - findall(Ancestor, ancestor(Self, Ancestor), Ancestors). - - extension(Prototype) :- - self(Self), - extends_object(Prototype, Self). - - extensions(Prototypes) :- - self(Self), - findall(Prototype, extends_object(Prototype, Self), Prototypes). - - leaf(Leaf) :- - self(Self), - leaf(Self, Leaf). - - leaf(Self, Leaf) :- - extends_object(Leaf, Self), - \+ extends_object(_, Leaf). - leaf(Self, Leaf) :- - extends_object(Object, Self), - leaf(Object, Leaf). - - leaves(Leaves) :- - self(Self), - ( setof(Leaf, leaf(Self, Leaf), Leaves) -> - true - ; Leaves = [] - ). - - descendant(Descendant) :- - self(Self), - descendant(Self, Descendant). - - descendant(Self, Descendant) :- - extends_object(Descendant, Self). - descendant(Self, Descendant) :- - extends_object(Descendant, Self), - \+ extends_object(Descendant, Self). - descendant(Self, Descendant) :- - extends_object(Subclass, Self), - descendant(Subclass, Descendant). - - descendants(Descendants) :- - self(Self), - ( setof(Descendant, descendant(Self, Descendant), Descendants) -> - true - ; Descendants = [] - ). - -:- end_category. diff --git a/Logtalk/library/proto_hierarchyp.lgt b/Logtalk/library/proto_hierarchyp.lgt deleted file mode 100644 index 13bd27089..000000000 --- a/Logtalk/library/proto_hierarchyp.lgt +++ /dev/null @@ -1,35 +0,0 @@ - -:- protocol(proto_hierarchyp, - extends(hierarchyp)). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2006/2/20, - comment is 'Prototype hierarchy protocol.']). - - :- public(parent/1). - :- mode(parent(?object), zero_or_more). - :- info(parent/1, [ - comment is 'Returns, by backtracking, all object parents.', - argnames is ['Parent']]). - - :- public(parents/1). - :- mode(parents(-list), one). - :- info(parents/1, [ - comment is 'List of all object parents.', - argnames is ['Parents']]). - - :- public(extension/1). - :- mode(extension(?object), zero_or_more). - :- info(extension/1, [ - comment is 'Returns, by backtracking, all object direct descendants.', - argnames is ['Extension']]). - - :- public(extensions/1). - :- mode(extensions(-list), one). - :- info(extensions/1, [ - comment is 'List of all object direct descendants.', - argnames is ['Extensions']]). - -:- end_protocol. diff --git a/Logtalk/library/queue.lgt b/Logtalk/library/queue.lgt deleted file mode 100644 index 4e4d8805a..000000000 --- a/Logtalk/library/queue.lgt +++ /dev/null @@ -1,69 +0,0 @@ - -:- object(queue, - implements(queuep), - extends(compound)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Queue predicates implemented using difference lists.']). - - as_list(Queue-Back, List) :- - Queue == Back -> - List = [] - ; - List = [Head| Tail], - Queue = [Head| Rest], - as_list(Rest-Back, Tail). - - empty(Front-Back) :- - Front == Back. - - head(Front-Back, Head) :- - Front \== Back, - Front = [Head| _]. - - join(Element, Front-[Element| Back], Front-Back). - - join_all([], Queue, Queue). - join_all([Head| Tail], Queue1, Queue3) :- - join(Head, Queue1, Queue2), - join_all(Tail, Queue2, Queue3). - - jump(Element, Front-Back, [Element| Front]-Back). - - jump_all([], Queue, Queue). - jump_all([Head| Tail], Queue1, Queue3) :- - jump(Head, Queue1, Queue2), - jump_all(Tail, Queue2, Queue3). - - length(Front-Back, Length) :- - length(Front, Back, 0, N), - Length = N. - - length(Front, Back, N, N) :- - Front == Back, !. - length([_|Front], Back, K, N) :- - L is K+1, - length(Front, Back, L, N). - - new(Back-Back). - - serve(OldFront-Back, Head, NewFront-Back) :- - OldFront \== Back, - OldFront = [Head| NewFront]. - - valid(Queue) :- - nonvar(Queue), - valid2(Queue). - - valid2(Queue-Back) :- - Queue == Back, - !. - valid2(Queue-Back) :- - nonvar(Queue), - Queue = [_| Tail], - valid2(Tail-Back). - -:- end_object. diff --git a/Logtalk/library/queuep.lgt b/Logtalk/library/queuep.lgt deleted file mode 100644 index 10f33c4df..000000000 --- a/Logtalk/library/queuep.lgt +++ /dev/null @@ -1,64 +0,0 @@ - -:- protocol(queuep). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Queue protocol.']). - - :- public(empty/1). - :- mode(empty(@queue), zero_or_one). - :- info(empty/1, [ - comment is 'True if the queue is empty.', - argnames is ['Queue']]). - - :- public(head/2). - :- mode(head(+queue, ?term), zero_or_one). - :- info(head/2, [ - comment is 'Unifies Head with the first element of the queue.', - argnames is ['Queue', 'Head']]). - - :- public(join/3). - :- mode(join(@term, +queue, -queue), zero_or_one). - :- info(join/3, [ - comment is 'Adds the new element at the end of the queue.', - argnames is ['Element', 'Queue_in', 'Queue_out']]). - - :- public(join_all/3). - :- mode(join_all(+list, +queue, -queue), zero_or_one). - :- info(join_all/3, [ - comment is 'Adds the new elements at the end of the queue. The elements are added in the same order that they appear in the list.', - argnames is ['List', 'Queue_in', 'Queue_out']]). - - :- public(jump/3). - :- mode(jump(@term, +queue, -queue), zero_or_one). - :- info(jump/3, [ - comment is 'Adds the new element at the front of the queue.', - argnames is ['Element', 'Queue_in', 'Queue_out']]). - - :- public(jump_all/3). - :- mode(jump_all(+list, +queue, -queue), zero_or_one). - :- info(jump_all/3, [ - comment is 'Adds the new elements at the front of the queue. The elements are added in the same order that they appear in the list.', - argnames is ['Element', 'Queue_in', 'Queue_out']]). - - :- public(length/2). - :- mode(length(+queue, ?integer), zero_or_one). - :- info(length/2, - [comment is 'Queue length.', - argnames is ['Queue', 'Length']]). - - :- public(serve/3). - :- mode(serve(+queue, ?term, -queue), zero_or_one). - :- info(serve/3, [ - comment is 'Removes the first element of the queue for service.', - argnames is ['Queue_in', 'Head', 'Queue_out']]). - - :- public(as_list/2). - :- mode(as_list(+queue, -list), one). - :- info(as_list/2, - [comment is 'Converts a queue to a list.', - argnames is ['Queue', 'List']]). - -:- end_protocol. diff --git a/Logtalk/library/random.lgt b/Logtalk/library/random.lgt deleted file mode 100644 index fe70a4533..000000000 --- a/Logtalk/library/random.lgt +++ /dev/null @@ -1,147 +0,0 @@ - -:- object(random, - implements(randomp)). - - :- info([ - version is 1.4, - author is 'Paulo Moura', - date is 2007/10/13, - comment is 'Random number generator predicates.']). - - :- synchronized([random/1, randseq/4, randset/4, reset_seed/0, set_seed/1]). - - :- initialization(::reset_seed). - - :- private(seed_/3). - :- dynamic(seed_/3). - :- mode(seed_(-integer, -integer, -integer), one). - :- info(seed_/3, [ - comment is 'Stores the current random generator seed values.', - argnames is ['S0', 'S1', 'S2']]). - - random(Random) :- - ::retract(seed_(A0, A1, A2)), - random(A0, A1, A2, B0, B1, B2, Random), - ::asserta(seed_(B0, B1, B2)). - - random(A0, A1, A2, B0, B1, B2, Random) :- - B0 is (A0*171) mod 30269, - B1 is (A1*172) mod 30307, - B2 is (A2*170) mod 30323, - Float is A0/30269 + A1/30307 + A2/30323, - Random is Float - truncate(Float). - - random(Lower, Upper, Random) :- - integer(Lower), - integer(Upper), - Upper >= Lower, - !, - random(Float), - Random is truncate((Float * (Upper-Lower)+Lower)). - - random(Lower, Upper, Random) :- - float(Lower), - float(Upper), - Upper >= Lower, - random(Float), - Random is Float * (Upper-Lower)+Lower. - - randseq(Length, Lower, Upper, Sequence) :- - integer(Length), - Length >= 0, - integer(Lower), - integer(Upper), - Upper >= Lower, - !, - ::retract(seed_(A0, A1, A2)), - randseq(Length, Lower, Upper, (A0, A1, A2), (B0, B1, B2), List), - ::asserta(seed_(B0, B1, B2)), - map_truncate(List, Sequence). - - randseq(Length, Lower, Upper, Sequence) :- - integer(Length), - Length >= 0, - float(Lower), - float(Upper), - Upper >= Lower, - ::retract(seed_(A0, A1, A2)), - randseq(Length, Lower, Upper, (A0, A1, A2), (B0, B1, B2), Sequence), - ::asserta(seed_(B0, B1, B2)). - - randseq(0, _, _, Seed, Seed, []) :- - !. - randseq(N, Lower, Upper, (A0, A1, A2), (C0, C1, C2), [Random| List]) :- - N2 is N - 1, - random(A0, A1, A2, B0, B1, B2, R), - Random is R * (Upper-Lower)+Lower, - randseq(N2, Lower, Upper, (B0, B1, B2), (C0, C1, C2), List). - - map_truncate([], []). - map_truncate([Float| Floats], [Integer| Integers]) :- - Integer is truncate(Float), - map_truncate(Floats, Integers). - - randset(Length, Lower, Upper, Set) :- - integer(Length), - Length >= 0, - integer(Lower), - integer(Upper), - Upper >= Lower, - Length =< Upper - Lower, - !, - ::retract(seed_(A0, A1, A2)), - randset(Length, Lower, Upper, (A0, A1, A2), (B0, B1, B2), [], Set), - ::asserta(seed_(B0, B1, B2)). - randset(Length, Lower, Upper, Set) :- - integer(Length), - Length >= 0, - float(Lower), - float(Upper), - Upper >= Lower, - ::retract(seed_(A0, A1, A2)), - randset(Length, Lower, Upper, (A0, A1, A2), (B0, B1, B2), [], Set), - ::asserta(seed_(B0, B1, B2)). - - randset(0, _, _, Seed, Seed, List, List) :- - !. - randset(N, Lower, Upper, (A0, A1, A2), (C0, C1, C2), Acc, List) :- - N2 is N - 1, - random(A0, A1, A2, B0, B1, B2, Float), - Float2 is Float * (Upper-Lower)+Lower, - ( integer(Lower) -> - Random is truncate(Float2) - ; Random is Float2 - ), - ( not_member(Acc, Random) -> - add_ordered(Acc, Random, Acc2), - randset(N2, Lower, Upper, (B0, B1, B2), (C0, C1, C2), Acc2, List) - ; randset(N, Lower, Upper, (B0, B1, B2), (C0, C1, C2), Acc, List) - ). - - not_member([], _). - not_member([H| T], R) :- - H =\= R, - not_member(T, R). - - add_ordered([], R, [R]). - add_ordered([H| T], R, L) :- - ( H > R -> - L = [R, H| T] - ; L = [H| T2], - add_ordered(T, R, T2) - ). - - reset_seed :- - ::retractall(seed_(_, _, _)), - ::asserta(seed_(3172, 9814, 20125)). - - set_seed(Seed) :- - integer(Seed), - Seed > 0, - ::retractall(seed_(_, _, _)), - S0 is Seed mod 30269, - S1 is Seed mod 30307, - S2 is Seed mod 30323, - ::asserta(seed_(S0, S1, S2)). - -:- end_object. diff --git a/Logtalk/library/random.notes b/Logtalk/library/random.notes deleted file mode 100644 index 014665d50..000000000 --- a/Logtalk/library/random.notes +++ /dev/null @@ -1,19 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load all entities in this library load the random_loader.lgt utility -file: - - | ?- logtalk_load(random_loader). - -The object random implements a basic random number generators. - -If you need more than one random number generator, just define or -create new objects as extensions of the object random. Be sure to -initialize the seeds of the new random generator objects by using the -message reset_seed/0. diff --git a/Logtalk/library/random_loader.lgt b/Logtalk/library/random_loader.lgt deleted file mode 100644 index de69e24ea..000000000 --- a/Logtalk/library/random_loader.lgt +++ /dev/null @@ -1,5 +0,0 @@ - -:- initialization( - logtalk_load( - [randomp, random], - [reload(skip)])). % allow for static binding diff --git a/Logtalk/library/randomp.lgt b/Logtalk/library/randomp.lgt deleted file mode 100644 index 34443739c..000000000 --- a/Logtalk/library/randomp.lgt +++ /dev/null @@ -1,48 +0,0 @@ - -:- protocol(randomp). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Random number generator protocol.']). - - :- public(random/1). - :- mode(random(-float), one). - :- info(random/1, [ - comment is 'Returns a new random float value in the interval [0.0, 1.0[.', - argnames is ['Random']]). - - :- public(random/3). - :- mode(random(+integer, +integer, -integer), zero_or_one). - :- mode(random(+float, +float, -float), zero_or_one). - :- info(random/3, [ - comment is 'Returns a new random value in the interval [Lower, Upper[.', - argnames is ['Lower', 'Upper', 'Random']]). - - :- public(randseq/4). - :- mode(randseq(+integer, +integer, +integer, -list), zero_or_one). - :- mode(randseq(+integer, +float, +float, -list), zero_or_one). - :- info(randseq/4, [ - comment is 'Returns a list of Length random values in the interval [Lower, Upper[.', - argnames is ['Length', 'Lower', 'Upper', 'List']]). - - :- public(randset/4). - :- mode(randset(+integer, +integer, +integer, -list), zero_or_one). - :- mode(randset(+integer, +float, +float, -list), zero_or_one). - :- info(randset/4, [ - comment is 'Returns an ordered set of Length random values in the interval [Lower, Upper[.', - argnames is ['Length', 'Lower', 'Upper', 'Set']]). - - :- public(reset_seed/0). - :- mode(reset_seed, one). - :- info(reset_seed/0, [ - comment is 'Resets the random seed to its default value.']). - - :- public(set_seed/1). - :- mode(set_seed(+integer), zero_or_one). - :- info(set_seed/1, [ - comment is 'Sets the random seed to the given value.', - argnames is ['Seed']]). - -:- end_protocol. diff --git a/Logtalk/library/set.lgt b/Logtalk/library/set.lgt deleted file mode 100644 index 0b1a4002f..000000000 --- a/Logtalk/library/set.lgt +++ /dev/null @@ -1,193 +0,0 @@ - -:- object(set, - implements(setp), - extends(compound)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Set predicates implemented using ordered lists. Uses ==/2 for element comparison and standard term ordering.']). - - delete([], _, []). - delete([Head| Tail], Element, Remaining) :- - compare(Order, Head, Element), - delete(Order, Head, Tail, Element, Remaining). - - delete(=, _, Tail, _, Tail). - delete(<, Head, Tail, Element, [Head| Tail2]) :- - delete(Tail, Element, Tail2). - delete(>, _, Tail, _, Tail). - - disjoint([], _) :- !. - disjoint(_, []) :- !. - disjoint([Head1| Tail1], [Head2| Tail2]) :- - compare(Order, Head1, Head2), - disjoint(Order, Head1, Tail1, Head2, Tail2). - - disjoint(<, _, Tail1, Head2, Tail2) :- - disjoint(Tail1, [Head2| Tail2]). - disjoint(>, Head1, Tail1, _, Tail2) :- - disjoint([Head1| Tail1], Tail2). - - equal(Set1, Set2) :- - Set1 == Set2. - - empty(Set) :- - Set == []. - - insert([], Element, [Element]). - insert([Head| Tail], Element, Set) :- - compare(Order, Head, Element), - insert(Order, Head, Tail, Element, Set). - - insert(<, Head, Tail, Element, [Head| Set]) :- - insert(Tail, Element, Set). - insert(=, Head, Tail, _, [Head| Tail]). - insert(>, Head, Tail, Element, [Element, Head| Tail]). - - insert_all([], Set, Set). - insert_all([Head| Tail], Set1, Set3) :- - insert(Set1, Head, Set2), - insert_all(Tail, Set2, Set3). - - intersect([Head1| Tail1], [Head2| Tail2]) :- - compare(Order, Head1, Head2), - intersect(Order, Head1, Tail1, Head2, Tail2). - - intersect(=, _, _, _, _). - intersect(<, _, Tail1, Head2, Tail2) :- - intersect(Tail1, [Head2| Tail2]). - intersect(>, Head1, Tail1, _, Tail2) :- - intersect([Head1| Tail1], Tail2). - - intersection(_, [], []) :- !. - intersection([], _, []) :- !. - - intersection([Head1| Tail1], [Head2| Tail2], Intersection) :- - compare(Order, Head1, Head2), - intersection(Order, Head1, Tail1, Head2, Tail2, Intersection). - - intersection(=, Head, Tail1, _, Tail2, [Head| Intersection]) :- - intersection(Tail1, Tail2, Intersection). - intersection(<, _, Tail1, Head2, Tail2, Intersection) :- - intersection(Tail1, [Head2| Tail2], Intersection). - intersection(>, Head1, Tail1, _, Tail2, Intersection) :- - intersection([Head1|Tail1], Tail2, Intersection). - - length(Set, Length) :- - length(Set, 0, Length). - - length([], Length, Length). - length([_| Set], Acc, Length) :- - Acc2 is Acc + 1, - length(Set, Acc2, Length). - - member(Element, Set) :- - ( var(Element) -> - member_var(Element, Set) - ; member_nonvar(Element, Set) - ). - - member_var(Element, [Element| _]). - member_var(Element, [_| Set]) :- - member_var(Element, Set). - - member_nonvar(Element, [Head| Tail]):- - compare(Order, Element, Head), - member_nonvar(Order, Element, Tail). - - member_nonvar(=, _, _). - member_nonvar(>, Element, [Head| Tail]) :- - compare(Order, Element, Head), - member_nonvar(Order, Element, Tail). - - new([]). - - powerset(Set, PowerSet):- - reverse(Set, RSet), - powerset_1(RSet, [[]], PowerSet). - - powerset_1([], PowerSet, PowerSet). - powerset_1([X| Xs], Yss0, Yss):- - powerset_2(Yss0, X, Yss1), - powerset_1(Xs, Yss1, Yss). - - powerset_2([], _, []). - powerset_2([Zs| Zss], X, [Zs, [X| Zs]| Yss]):- - powerset_2(Zss, X, Yss). - - reverse(List, Reversed) :- - reverse(List, [], Reversed). - - reverse([], Reversed, Reversed). - reverse([Head| Tail], List, Reversed) :- - reverse(Tail, [Head| List], Reversed). - - select(Head, [Head| Tail], Tail). - select(Head, [Head2| Tail], [Head2| Tail2]) :- - select(Head, Tail, Tail2). - - subset([], _) :- !. - subset([Head1| Tail1], [Head2| Tail2]) :- - compare(Order, Head1, Head2), - subset(Order, Head1, Tail1, Head2, Tail2). - - subset(=, _, Tail1, _, Tail2) :- - subset(Tail1, Tail2). - subset(>, Head1, Tail1, _, Tail2) :- - subset([Head1| Tail1], Tail2). - - subtract(Set, [], Set) :- !. - subtract([], _, []) :- !. - - subtract([Head1| Tail1], [Head2| Tail2], Difference) :- - compare(Order, Head1, Head2), - subtract(Order, Head1, Tail1, Head2, Tail2, Difference). - - subtract(=, _, Tail1, _, Tail2, Difference) :- - subtract(Tail1, Tail2, Difference). - subtract(<, Head1, Tail1, Head2, Tail2, [Head1| Difference]) :- - subtract(Tail1, [Head2| Tail2], Difference). - subtract(>, Head1, Tail1, _, Tail2, Difference) :- - subtract([Head1| Tail1], Tail2, Difference). - - symdiff(Set, [], Set) :- !. - symdiff([], Set, Set) :- !. - symdiff([Head1| Tail1], [Head2| Tail2], Difference) :- - compare(Order, Head1, Head2), - symdiff(Order, Head1, Tail1, Head2, Tail2, Difference). - - symdiff(=, _, Tail1, _, Tail2, Difference) :- - symdiff(Tail1, Tail2, Difference). - symdiff(<, Head1, Tail1, Head2, Tail2, [Head1| Difference]) :- - symdiff(Tail1, [Head2| Tail2], Difference). - symdiff(>, Head1, Tail1, Head2, Tail2, [Head2| Difference]) :- - symdiff([Head1| Tail1], Tail2, Difference). - - union(Set, [], Set) :- !. - union([], Set, Set) :- !. - union([Head1| Tail1], [Head2| Tail2], Union) :- - compare(Order, Head1, Head2), - union(Order, Head1, Tail1, Head2, Tail2, Union). - - union(=, Head, Tail1, _, Tail2, [Head| Union]) :- - union(Tail1, Tail2, Union). - union(<, Head1, Tail1, Head2, Tail2, [Head1| Union]) :- - union(Tail1, [Head2| Tail2], Union). - union(>, Head1, Tail1, Head2, Tail2, [Head2| Union]) :- - union([Head1| Tail1], Tail2, Union). - - valid(Set) :- - nonvar(Set), - valid2(Set). - - valid2([]) :- - !. - valid2([_]) :- - !. - valid2([Element1, Element2| Set]) :- - Element1 @< Element2, - valid2([Element2| Set]). - -:- end_object. diff --git a/Logtalk/library/set1.lgt b/Logtalk/library/set1.lgt deleted file mode 100644 index 8d820093d..000000000 --- a/Logtalk/library/set1.lgt +++ /dev/null @@ -1,27 +0,0 @@ - -:- object(set(_Type), - extends(set)). - - :- info([ - version is 1.01, - author is 'Paulo Moura', - date is 2006/4/25, - comment is 'Set predicates with elements constrained to a single type.']). - - valid(Set) :- - nonvar(Set), - parameter(1, Type), - \+ \+ valid(Set, Type). - - valid([], _) :- - !. - valid([Element], Type) :- - !, - Type::valid(Element). - valid([Element1, Element2| Set], Type) :- - Element1 @< Element2, - Type::valid(Element1), - Type::valid(Element2), - valid([Element2| Set], Type). - -:- end_object. diff --git a/Logtalk/library/setp.lgt b/Logtalk/library/setp.lgt deleted file mode 100644 index 76fe30caa..000000000 --- a/Logtalk/library/setp.lgt +++ /dev/null @@ -1,107 +0,0 @@ - -:- protocol(setp). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Set protocol.']). - - :- public(delete/3). - :- mode(delete(+set, @term, ?set), one). - :- info(delete/3, - [comment is 'Deletes an element from a set returning the set of remaining elements.', - argnames is ['Set', 'Element', 'Remaining']]). - - :- public(disjoint/2). - :- mode(disjoint(+set, +set), zero_or_one). - :- info(disjoint/2, [ - comment is 'True if the two sets have no element in common.', - argnames is ['Set1', 'Set2']]). - - :- public(equal/2). - :- mode(equal(+set, +set), zero_or_one). - :- info(equal/2, [ - comment is 'True if the two sets are equal.', - argnames is ['Set1', 'Set2']]). - - :- public(empty/1). - :- mode(empty(+set), zero_or_one). - :- info(empty/1, [ - comment is 'True if the set is empty.', - argnames is ['Set']]). - - :- public(insert/3). - :- mode(insert(+set, +term, ?set), one). - :- info(insert/3, [ - comment is 'Inserts an element in a set, returning the resulting set.', - argnames is ['In', 'Element', 'Out']]). - - :- public(insert_all/3). - :- mode(insert_all(+list, +set, ?set), one). - :- info(insert_all/3, [ - comment is 'Inserts a list of elemnts in a set, returning the resulting set.', - argnames is ['List', 'In', 'Out']]). - - :- public(intersect/2). - :- mode(intersect(+set, +set), zero_or_one). - :- info(intersect/2, [ - comment is 'True if the two sets have at least one element in common.', - argnames is ['Set1', 'Set2']]). - - :- public(intersection/3). - :- mode(intersection(+set, +set, ?set), zero_or_one). - :- info(intersection/3, [ - comment is 'Returns the intersection of Set1 and Set2.', - argnames is ['Set1', 'Set2', 'Intersection']]). - - :- public(length/2). - :- mode(length(+set, ?integer), zero_or_one). - :- info(length/2, - [comment is 'Number of set elements.', - argnames is ['Set', 'Length']]). - - :- public(member/2). - :- mode(member(+term, +set), zero_or_one). - :- mode(member(-term, +set), zero_or_more). - :- info(member/2, - [comment is 'Element is a member of set Set.', - argnames is ['Element', 'Set']]). - - :- public(powerset/2). - :- mode(powerset(+set, -list), one). - :- info(powerset/2, - [comment is 'Returns the power set of a set, represented as a list of sets.', - argnames is ['Set', 'Powerset']]). - - :- public(select/3). - :- mode(select(?term, +set, ?set), zero_or_more). - :- info(select/3, - [comment is 'Selects an element from a set, returning the set of remaining elements.', - argnames is ['Element', 'Set', 'Remaining']]). - - :- public(subset/2). - :- mode(subset(+set, +set), zero_or_one). - :- info(subset/2, [ - comment is 'True if Subset is a subset of Set.', - argnames is ['Subset', 'Set']]). - - :- public(subtract/3). - :- mode(subtract(+set, +set, ?set), zero_or_one). - :- info(subtract/3, [ - comment is 'True when Difference contains all and only the elements of Set1 which are not also in Set2.', - argnames is ['Set1', 'Set2', 'Difference']]). - - :- public(symdiff/3). - :- mode(symdiff(+set, +set, ?set), zero_or_one). - :- info(symdiff/3, [ - comment is 'True if Difference is the symmetric difference of Set1 and Set2.', - argnames is ['Set1', 'Set2', 'Difference']]). - - :- public(union/3). - :- mode(union(+set, +set, ?set), zero_or_one). - :- info(union/3, [ - comment is 'True if Union is the union of Set1 and Set2.', - argnames is ['Set1', 'Set2', 'Union']]). - -:- end_protocol. diff --git a/Logtalk/library/subject.lgt b/Logtalk/library/subject.lgt deleted file mode 100644 index 3d2a4eccb..000000000 --- a/Logtalk/library/subject.lgt +++ /dev/null @@ -1,65 +0,0 @@ - -:- category(subject). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 03/02/09, - comment is 'Smalltalk dependent handling predicates.']). - - :- public(changed/0). - :- mode(changed, one). - :- info(changed/0, - [comment is 'Receiver changed in some way. Notify all dependents.']). - - :- public(changed/1). - :- mode(changed(?nonvar), one). - :- info(changed/1, - [comment is 'Receiver changed as specified in the argument. Notify all dependents.', - argnames is ['Change']]). - - :- public(dependents/1). - :- mode(dependents(-list), one). - :- info(dependents/1, - [comment is 'Returns a list of all dependent objects.', - argnames is ['Dependents']]). - - :- private(dependent_/1). - :- dynamic(dependent_/1). - :- mode(dependent_(?object), zero_or_more). - :- info(dependent_/1, - [comment is 'Dependent object table.', - argnames is ['Dependent']]). - - :- public(addDependent/1). - :- mode(addDependent(@object), one). - :- info(addDependent/1, - [comment is 'Adds a new dependent object.', - argnames is ['Dependent']]). - - :- public(removeDependent/1). - :- mode(removeDependent(?object), zero_or_more). - :- info(removeDependent/1, - [comment is 'Removes a dependent object.', - argnames is ['Dependent']]). - - changed :- - self(Self), - forall(::dependent_(Dependent), Dependent::update(Self)). - - changed(Change) :- - forall(::dependent_(Dependent), Dependent::update(Change)). - - dependents(Dependents) :- - findall(Dependent, ::dependent_(Dependent), Dependents). - - addDependent(Dependent) :- - ::dependent_(Dependent) -> - true - ; - ::asserta(dependent_(Dependent)). - - removeDependent(Dependent) :- - ::retract(dependent_(Dependent)). - -:- end_category. diff --git a/Logtalk/library/systemp.lgt b/Logtalk/library/systemp.lgt deleted file mode 100644 index 8547fae1d..000000000 --- a/Logtalk/library/systemp.lgt +++ /dev/null @@ -1,369 +0,0 @@ - -:- protocol(systemp). - - :- info([ - version is 1.10, - author is 'Portable Operating-System Interface (POSI) initiative', - date is 2006/1/21, - comment is 'Portable operating system access protocol.', - remarks is [ - 'File names overview:' - 'The main idea is that file names should be operating-system independent. As such, predicates are needed to convert between portable file names and operating-system specific file names. The solution chosen is to use URL syntax for portable file names.', - 'Local and remote file names:' - 'A (portable) file name may point to either a local file or a remote file.', - 'URL file names:' - 'These are file names which start with an access protocol (e.g. {http, https, ftp, gopher, file}://).', - 'Absolute file names:' - 'These are file names that always point to a local file. They always start with a slash character (/).', - 'Relative file names:' - 'These are file names that always point to a local file. A file name is a relative file name if it does not start with a slash character or a file access protocol (including the :// characters).', - 'Canonical file names' - 'These are file names where any environment variables was been expanded and where the sequences for current (.) and parent (..) directories have been resolved.', - 'Time stamps:' - 'Time stamps are used for representing current, system time and in file properties to represent creation, modification, and access times. Time stamps are system-dependent terms but that can be compared (e.g. when testing which of two given files is older).']]). - - :- public(make_directory/1). - :- mode(make_directory(+atom), one). - :- info(make_directory/1, [ - comment is 'Makes a new directory. Argument is first expanded to a canonical file name.', - argnames is ['Directory'], - exceptions is [ - 'Directory is not instantiated' - instantiation_error, - 'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory'), - 'No permission for making a new directory' - permission_error(write, 'Directory')]]). - - :- public(delete_directory/1). - :- mode(delete_directory(+atom), one). - :- info(delete_directory/1, [ - comment is 'Deletes an empty directory.', - argnames is ['Directory'], - exceptions is [ - 'Directory is not instantiated' - instantiation_error, - 'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory'), - 'Directory does not exists' - existence_error(directory, 'Directory'), - 'No permission for deleting the directory' - permission_error(write, 'Directory'), - 'Directory is not empty' - permission_error(write, 'Directory')]]). - - :- public(change_directory/1). - :- mode(change_directory(+atom), one). - :- info(change_directory/1, [ - comment is 'Changes current working directory.', - argnames is ['Directory'], - exceptions is [ - 'Directory is not instantiated' - instantiation_error, - 'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory'), - 'No permission for accessing the directory' - permission_error(read, 'Directory'), - 'Directory does not exists' - existence_error(directory, 'Directory')]]). - - :- public(working_directory/1). - :- mode(working_directory(?atom), zero_or_one). - :- info(working_directory/1, [ - comment is 'Current working directory (as an absolute file name).', - argnames is ['Directory'], - exceptions is [ - 'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory')]]). - - :- public(directory_exists/1). - :- mode(directory_exists(+atom), zero_or_one). - :- info(directory_exists/1, [ - comment is 'True if the specified directory exists (irrespective of directory permissions).', - argnames is ['Directory'], - exceptions is [ - 'Directory is not instantiated' - instantiation_error, - 'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory')]]). - - :- public(directory_files/3). - :- mode(directory_files(+atom, +atom, -list), one). - :- info(directory_files/3, [ - comment is 'List of all directory files that matches a regular expression (returns an empty list when no file matches; may be used to find hidden files given an appropriate filter).', - argnames is ['Directory', 'Filter', 'Files'], - exceptions is [ - 'Directory is not instantiated' - instantiation_error, - 'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory'), - 'No read permission for the directory' - permission_error(read, 'Directory'), - 'Directory does not exists' - existence_error(directory, 'Directory'), - 'Filter is not instantiated' - instantiation_error, - 'Filter is neither a variable nor a valid regular expression' - type_error(regular_expression, 'Filter')]]). - - :- public(directory_files/2). - :- mode(directory_files(+atom, -list), one). - :- info(directory_files/2, [ - comment is 'List of all directory files (returns an empty list when the directory is empty; hidden files are not retrieved).', - argnames is ['Directory', 'Files'], - exceptions is [ - 'Directory is not instantiated' - instantiation_error, - 'Directory is neither a variable nor a valid file name' - type_error(file_name, 'Directory'), - 'No read permission for the directory' - permission_error(read, 'Directory'), - 'Directory does not exists' - existence_error(directory, 'Directory')]]). - - :- public(delete_file/1). - :- mode(delete_file(+atom), one). - :- info(delete_file/1, [ - comment is 'Deletes a file.', - argnames is ['File'], - exceptions is [ - 'File is not instantiated' - instantiation_error, - 'File is neither a variable nor a valid file name' - type_error(file_name, 'File'), - 'File does not exists' - existence_error(file, 'File'), - 'No write permission to the file' - permission_error(write, 'File')]]). - - :- public(delete_files/1). - :- mode(delete_files(+atom), one). - :- info(delete_files/1, [ - comment is 'Deletes a set of matching files.', - argnames is ['Filter'], - exceptions is [ - 'Filter is not instantiated' - instantiation_error, - 'Filter is neither a variable nor a valid regular expression' - type_error(regular_expression, 'Filter'), - 'No permission to delete some of the matching files' - permission_error(write, 'File')]]). - - :- public(rename_file/2). - :- mode(rename_file(+atom, +atom), zero_or_one). - :- info(rename_file/2, [ - comment is 'Renames a file (or a directory).', - argnames is ['Old', 'New'], - exceptions is [ - 'Old is not instantiated' - instantiation_error, - 'New is not instantiated' - instantiation_error, - 'Old is neither a variable nor a valid file name' - type_error(file_name, 'Old'), - 'New is neither a variable nor a valid file name' - type_error(file_name, 'New'), - 'File Old does not exists' - existence_error(file, 'Old'), - 'No write permission to the file' - permission_error(write, 'Old')]]). - - :- public(copy_file/2). - :- mode(copy_file(+atom, +atom), one). - :- info(copy_file/2, [ - comment is 'Makes a copy of a file.', - argnames is ['Original', 'Copy'], - exceptions is [ - 'Original is not instantiated' - instantiation_error, - 'Copy is not instantiated' - instantiation_error, - 'Original is neither a variable nor a valid file name' - type_error(file_name, 'Original'), - 'Copy is neither a variable nor a valid file name' - type_error(file_name, 'Copy'), - 'File Original does not exists' - existence_error(file, 'Original'), - 'No read permission to the original file' - permission_error(read, 'Original'), - 'No write permission to the file copy' - permission_error(write, 'Copy')]]). - - :- public(make_symlink/2). - :- mode(make_symlink(+atom, +atom), one). - :- info(make_symlink/2, [ - comment is 'Makes a symbolic link.', - argnames is ['Symlink', 'Target'], - exceptions is [ - 'Symlink is not instantiated' - instantiation_error, - 'Target is not instantiated' - instantiation_error, - 'Symlink is neither a variable nor a valid file name' - type_error(file_name, 'Symlink'), - 'Target is neither a variable nor a valid file name' - type_error(file_name, 'Target'), - 'No permission for creating the symbolic link' - permission_error(write, 'Symlink')]]). - - :- public(file_exists/1). - :- mode(file_exists(+atom), zero_or_one). - :- info(file_exists/1, [ - comment is 'True if the specified file exists (irrespective of type and file permissions).', - argnames is ['File'], - exceptions is [ - 'File is not instantiated' - instantiation_error, - 'File is neither a variable nor a valid file name' - type_error(file_name, 'File')]]). - - :- public(file_property/2). - :- mode(file_property(+atom, +compound), zero_or_one). - :- mode(file_property(+atom, -compound), one_or_more). - :- info(file_property/2, [ - comment is 'File properties.', - argnames is ['File', 'Property'], - exceptions is [ - 'File is not instantiated' - instantiation_error, - 'File is neither a variable nor a valid file name' - type_error(file_name, 'File'), - 'File does not exists' - existence_error(file, 'File'), - 'No read permission to the file' - permission_error(read, 'File'), - 'Property is neither a variable nor a valid file property' - type_error(file_property, 'Property')], - examples is [ - 'Querying file size:' - file_property(foo, size(Bytes)) - {Bytes = 32568}, - 'Querying file type:' - file_property(foo, type(Type)) - {Type = regular}, - 'Querying file creation date:' - file_property(foo, creation_time(Time)) - {Time = 137692}, - 'Querying file last access date:' - file_property(foo, access_time(Time)) - {Time = 811042}, - 'Querying file modification date:' - file_property(foo, modification_time(Time)) - {Time = 811042}, - 'Querying file permissions:' - file_property(foo, permission(Permission)) - {Permission = read} - ]]). - - :- public(current_environment_variable/1). - :- mode(current_environment_variable(?atom), zero_or_more). - :- info(current_environment_variable/1, [ - comment is 'Argument is a currently defined environment variable . Fails if the variable does not exists.', - argnames is ['Variable'], - exceptions is [ - 'Variable is neither a variable nor an atom' - type_error(atom, 'Variable')]]). - - :- public(delete_environment_variable/1). - :- mode(delete_environment_variable(+atom), one). - :- info(delete_environment_variable/1, [ - comment is 'Deletes an environment variable.', - argnames is ['Variable'], - exceptions is [ - 'Variable is not instantiated' - instantiation_error, - 'Variable is neither a variable nor an atom' - type_error(atom, 'Variable'), - 'Variable is not a currently defined environment variable' - existence_error(environment_variable, 'Variable')]]). - - :- public(get_environment_variable/2). - :- mode(get_environment_variable(+atom, ?atom), zero_or_one). - :- info(get_environment_variable/2, [ - comment is 'Gets environment variable value.', - argnames is ['Variable', 'Value'], - exceptions is [ - 'Variable is not instantiated' - instantiation_error, - 'Variable is neither a variable nor an atom' - type_error(atom, 'Variable'), - 'Value is neither a variable nor an atom' - type_error(atom, 'Value'), - 'Variable is not a currently defined environment variable' - existence_error(environment_variable, 'Variable')]]). - - :- public(set_environment_variable/2). - :- mode(set_environment_variable(+atom, +atom), one). - :- info(set_environment_variable/2, [ - comment is 'Sets environment variable value.', - argnames is ['Variable', 'Value'], - exceptions is [ - 'Variable is not instantiated' - instantiation_error, - 'Value is not instantiated' - instantiation_error, - 'Variable is neither a variable nor an atom' - type_error(atom, 'Variable'), - 'Value is neither a variable nor an atom' - type_error(atom, 'Value')]]). - - :- public(time_stamp/1). - :- mode(time_stamp(-number), one). - :- info(time_stamp/1, [ - comment is 'Returns a system-dependent time stamp (which can be used for sorting).', - argnames is ['Time']]). - - :- public(local_time/1). - :- mode(local_time(?time(?integer, ?integer, ?integer, ?integer, ?integer, ?integer, ?integer)), zero_or_one). - :- info(local_time/1, [ - comment is 'Local time (respecting time zone and daylight savings settings).', - argnames is ['time(Year, Month, Day, Hours, Mins, Secs, Microsecs)']]). - - :- public(utc_time/1). - :- mode(utc_time(?time(?integer, ?integer, ?integer, ?integer, ?integer, ?integer, ?integer)), zero_or_one). - :- info(utc_time/1, [ - comment is 'Universal Coordinated Time (UTC).', - argnames is ['time(Year, Month, Day, Hours, Mins, Secs, Microsecs)']]). - - :- public(convert_time/2). - :- mode(convert_time(+number, ?time(?integer, ?integer, ?integer, ?integer, ?integer, ?integer, ?integer)), zero_or_one). - :- mode(convert_time(?number, +time(+integer, +integer, +integer, +integer, +integer, +integer, +integer)), zero_or_one). - :- info(convert_time/2, [ - comment is 'Converts between system-dependent time stamps and calendar local date and time.', - argnames is ['Time', 'time(Year, Month, Day, Hours, Mins, Secs, Microsecs)'], - exceptions is [ - 'Neither argument is instantiated' - instantiation_error, - 'Time stamp is neither a variable nor a valid time stamp' - type_error(time_stamp, 'Time'), - 'Time structure is neither a variable nor a valid time structure' - type_error(time_structure, 'time(Year, Month, Day, Hours, Mins, Secs, Microsecs)')]]). - - :- public(cpu_time/1). - :- mode(cpu_time(-number), one). - :- info(cpu_time/1, [ - comment is 'System cpu time in seconds.', - argnames is ['Time']]). - - :- public(host_name/1). - :- mode(host_name(-atom), one). - :- info(host_name/1, [ - comment is 'Host name (default is localhost).', - argnames is ['Name']]). - - :- public(portable_os_file_name/2). - :- mode(portable_os_file_name(+atom, -atom), one). - :- mode(portable_os_file_name(-atom, +atom), one). - :- info(portable_os_file_name/2, [ - comment is 'Converts between portable and operating-system dependent file names.', - argnames is ['Canonical', 'OS']]). - - :- public(portable_file_name/3). - :- mode(portable_file_name(+atom, -atom, -atom), one). - :- mode(portable_file_name(-atom, +atom, -atom), one). - :- mode(portable_file_name(-atom, -atom, +atom), one). - :- info(portable_file_name/3, [ - comment is 'Converts between relative, absolute, and URL portable file names.', - argnames is ['Relative', 'Absolute', 'URL'], - exceptions is [ - 'None of the arguments is instantiated' - instantiation_error, - 'Relative is neither a variable nor a relative file name' - type_error(relative_file_name, 'Relative'), - 'Absolute is neither a variable nor a absolute file name' - type_error(absolute_file_name, 'Absolute'), - 'URL is neither a variable nor a file name URL' - type_error(url_file_name, 'URL')]]). - - :- public(relative_file_name/1). - :- mode(relative_file_name(+atom), zero_or_one). - :- info(relative_file_name/1, [ - comment is 'True when the argument is a valid, relative file name. Argument is expanded to a canonical file name before testing.', - argnames is ['File'], - exceptions is [ - 'File is not instantiated' - instantiation_error, - 'File is neither a variable nor a valid file name' - type_error(file_name, 'File')]]). - - :- public(absolute_file_name/1). - :- mode(absolute_file_name(+atom), zero_or_one). - :- info(absolute_file_name/1, [ - comment is 'True if the argument is a valid, absolute file name. Argument is expanded to a canonical file name before testing.', - argnames is ['File'], - exceptions is [ - 'File is not instantiated' - instantiation_error, - 'File is neither a variable nor a valid file name' - type_error(file_name, 'File')]]). - - :- public(url_file_name/1). - :- mode(url_file_name(+atom), zero_or_one). - :- info(url_file_name/1, [ - comment is 'True when the argument is a valid, URL file name. Argument is expanded to a canonical file name before testing.', - argnames is ['File'], - exceptions is [ - 'File is not instantiated' - instantiation_error, - 'File is neither a variable nor a valid file name' - type_error(file_name, 'File')]]). - - :- public(absolute_file_name/2). - :- mode(absolute_file_name(+atom, ?atom), zero_or_one). - :- info(absolute_file_name/2, [ - comment is 'Expands a file name into a canonical absolute file name.', - argnames is ['File', 'Absolute'], - exceptions is [ - 'File is not instantiated' - instantiation_error, - 'File is neither a variable nor a valid file name' - type_error(file_name, 'File'), - 'Absolute is neither a variable nor a valid file name' - type_error(file_name, 'Absolute')]]). - - :- public(url_file_name/2). - :- mode(url_file_name(+atom, ?atom), zero_or_one). - :- info(url_file_name/2, [ - comment is 'Expands a file name into a canonical URL file name.', - argnames is ['File', 'URL'], - exceptions is [ - 'File is not instantiated' - instantiation_error, - 'File is neither a variable nor a valid file name' - type_error(file_name, 'File'), - 'URL is neither a variable nor a valid file name URL' - type_error(file_name, 'URL')]]). - - :- public(file_name_part/2). - :- mode(file_name_part(+atom, ?compound), zero_or_more). - :- info(file_name_part/2, [ - comment is 'File name parts. The file name is expanded to a canonical file name before decomposing in parts.', - argnames is ['File', 'Part'], - exceptions is [ - 'File is not instantiated' - instantiation_error, - 'File is neither a variable nor a valid file name' - type_error(file_name, 'File'), - 'File does not exists' - existence_error(file, 'File'), - 'Part is neither a variable nor a file name part' - type_error(file_name_part, 'Port')], - examples is [ - 'Querying file access protocol:' - file_name_part(foo, protocol(Protocol)) - {Protocol = file}, - 'Querying file host location:' - file_name_part('http://www.prolog-standard.org:8080/index.html', host(Host)) - {Host = 'www.prolog-standard.org'}, - 'Querying file port:' - file_name_part('http://www.prolog-standard.org:8080/index.html', port(Port)) - {Port = 8080}, - 'Querying file port:' - file_name_part(foo, port(Port)) - {no}, - 'Querying file username:' - file_name_part('http://user@www.prolog-standard.org/', user(Username)) - {Username = user}, - 'Querying file password:' - file_name_part('http://user:password@www.prolog-standard.org/', password(Password)) - {Password = password}, - 'Querying file base name:' - file_name_part('/usr/local/foo.pl', base(Basename)) - {Basename = 'foo.pl'}, - 'Querying file path:' - file_name_part('/usr/local/foo.pl', path(Path)) - {Path = '/usr/local/'}, - 'Querying file extension:' - file_name_part('foo.pl', extension(Extension)) - {Extension = '.pl'}, - 'Querying file extension:' - file_name_part('foo.', extension(Extension)) - {Extension = '.'}, - 'Querying file extension:' - file_name_part(foo, extension(Extension)) - {Extension = ''}, - 'Querying file search pairs:' - file_name_part('http://user@www.prolog-standard.org/updates.cgi?date=today', search(Pairs)) - {Pairs = [date=today]}, - 'Querying file fragment:' - file_name_part('http://user@www.prolog-standard.org/updates.html#latest', fragment(Fragment)) - {Fragment = latest} - ]]). - - :- public(file_name_parts/2). - :- mode(file_name_parts(+atom, -list(compound)), one). - :- mode(file_name_parts(-atom, +list(compound)), zero_or_one). - :- info(file_name_parts/2, [ - comment is 'Converts between a file name and its constituent parts (represented as a list of compound terms). The file name (when instantiated) is expanded to a canonical file name before decomposing in parts.', - argnames is ['File', 'Parts'], - exceptions is [ - 'None of the arguments are instantiated' - instantiation_error, - 'File is neither a variable nor a valid file name' - type_error(file_name, 'File'), - 'Parts is neither a variable nor a list' - type_error(list(compound), 'Parts')], - examples is [ - 'Decomposing a file name:' - file_name_parts('http://www.prolog-standard.org:8080/index.html', Parts) - {Parts = [protocol(http), host('www.prolog-standard.org'), port(8080), path('/'), base(index), extension('.html')]}]]). - -:- end_protocol. diff --git a/Logtalk/library/term.lgt b/Logtalk/library/term.lgt deleted file mode 100644 index a75a3accf..000000000 --- a/Logtalk/library/term.lgt +++ /dev/null @@ -1,140 +0,0 @@ - -:- object(term, - implements(termp)). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2007/4/3, - comment is 'Prolog term utility predicates.']). - - depth(Term, Depth) :- - depth(Term, 0, 0, Depth). - - depth(Var, Acc, MaxSoFar, Depth) :- - var(Var), - !, - ( Acc > MaxSoFar -> - Depth = Acc - ; Depth = MaxSoFar - ). - depth(Atomic, Acc, MaxSoFar, Depth) :- - atomic(Atomic), - !, - ( Acc > MaxSoFar -> - Depth = Acc - ; Depth = MaxSoFar - ). - depth([Arg| Args], Acc, MaxSoFar, Depth) :- - !, - depth(Arg, Acc, MaxSoFar, ArgDepth), - depth(Args, Acc, ArgDepth, Depth). - depth(Term, Acc, MaxSoFar, Depth) :- - Acc2 is Acc + 1, - Term =.. [_| Args], - depth(Args, Acc2, MaxSoFar, Depth). - - ground(Term) :- - nonvar(Term), - functor(Term, _, Arity), - ground(Arity, Term). - - ground(0, _) :- - !. - ground(N, Term) :- - N > 0, - arg(N, Term, Arg), - ground(Arg), - N2 is N - 1, - ground(N2, Term). - - occurs(Var, Term) :- - ( var(Term) -> - Var == Term - ; functor(Term, _, Arity), - occurs(Arity, Var, Term) - ). - - occurs(N, Var, Term) :- - compound(Term), - arg(N, Term, Arg), - occurs(Var, Arg), - !. - occurs(N, Var, Term) :- - N > 1, - N2 is N - 1, - occurs(N2, Var, Term). - - subsumes(General, Specific) :- - vars(Specific, Vars), - subsumes(General, Specific, Vars). - - subsumes(General, Specific, Vars) :- - var(General), - !, - ( var_member_chk(General, Vars) -> - General == Specific - ; General = Specific - ). - - subsumes(General, Specific, Vars) :- - nonvar(Specific), - functor(General, Functor, Arity), - functor(Specific, Functor, Arity), - subsumes(Arity, General, Specific, Vars). - - subsumes(0, _, _, _) :- - !. - subsumes(N, General, Specific, Vars) :- - arg(N, General, GenArg), - arg(N, Specific, SpeArg), - subsumes(GenArg, SpeArg, Vars), - M is N-1, !, - subsumes(M, General, Specific, Vars). - - var_member_chk(Var, [Head| Tail]) :- - ( Var == Head -> - true - ; var_member_chk(Var, Tail) - ). - - subterm(Term, Term). - subterm(Sub, Term) :- - nonvar(Term), - functor(Term, _, N), - subterm(N, Sub, Term). - - subterm(N, Sub, Term) :- - compound(Term), - arg(N, Term, Arg), - subterm(Sub, Arg). - subterm(N, Sub, Term) :- - N > 1, - M is N-1, - subterm(M, Sub, Term). - - valid(_). - - variant(Term1, Term2) :- - \+ \+ subsumes(Term1, Term2), - \+ \+ subsumes(Term2, Term1). - - vars(Term, Vars) :- - vars(Term, [], Vars). - - vars(Term, Acc, Vars) :- - ( var(Term) -> - ( var_member_chk(Term, Acc) -> - Vars = Acc - ; Vars = [Term| Acc] - ) - ; Term =.. [_| Args], - var_list(Args, Acc, Vars) - ). - - var_list([], Vars, Vars). - var_list([Term| Terms], Acc, Vars) :- - vars(Term, Acc, Acc2), - var_list(Terms, Acc2, Vars). - -:- end_object. diff --git a/Logtalk/library/term_expansionp.lgt b/Logtalk/library/term_expansionp.lgt deleted file mode 100644 index 33110da59..000000000 --- a/Logtalk/library/term_expansionp.lgt +++ /dev/null @@ -1,16 +0,0 @@ - -:- protocol(term_expansionp). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2006/2/5, - comment is 'Term expansion protocol.']). - - :- public(term_expansion/2). - :- mode(term_expansion(?term, ?term), zero_or_more). - :- info(term_expansion/2, - [comment is 'Expands a term into a new term.', - argnames is ['Term', 'Expansion']]). - -:- end_protocol. diff --git a/Logtalk/library/termp.lgt b/Logtalk/library/termp.lgt deleted file mode 100644 index 191297963..000000000 --- a/Logtalk/library/termp.lgt +++ /dev/null @@ -1,64 +0,0 @@ - -:- protocol(termp). - - :- info([ - version is 1.1, - author is 'Paulo Moura', - date is 2007/4/3, - comment is 'Prolog term utility predicates protocol.']). - - :- public(depth/2). - :- mode(depth(@term, ?integer), zero_or_one). - :- info(depth/2, [ - comment is 'True if the depth of Term is Depth. The depth of atomic terms is zero; the depth of a compound term is one plus the maximium depth of its sub-terms.', - argnames is ['Term', 'Depth']]). - - :- public(ground/1). - :- mode(ground(@term), zero_or_one). - :- info(ground/1, [ - comment is 'True if the argument is ground.', - argnames is ['Term']]). - - :- public(new/1). - :- mode(new(-nonvar), zero_or_one). - :- info(new/1, [ - comment is 'Creates a new term instance (if meaningful).', - argnames is ['Term']]). - - :- public(occurs/2). - :- mode(occurs(@var, @term), zero_or_one). - :- info(occurs/2, [ - comment is 'True if the variable occurs in the term.', - argnames is ['Variable', 'Term']]). - - :- public(subsumes/2). - :- mode(subsumes(@term, @term), zero_or_one). - :- info(subsumes/2, [ - comment is 'The first term subsumes the second term.', - argnames is ['General', 'Specific']]). - - :- public(subterm/2). - :- mode(subterm(?term, +term), zero_or_more). - :- info(subterm/2, [ - comment is 'The first term is a subterm of the second term.', - argnames is ['Subterm', 'Term']]). - - :- public(valid/1). - :- mode(valid(@nonvar), zero_or_one). - :- info(valid/1, [ - comment is 'Term is valid.', - argnames is ['Term']]). - - :- public(variant/2). - :- mode(variant(@term, @term), zero_or_one). - :- info(variant/2, [ - comment is 'Each term is a variant of the other (i.e. they are structurally equivalent).', - argnames is ['Term1', 'Term2']]). - - :- public(vars/2). - :- mode(vars(@term, -list), one). - :- info(vars/2, [ - comment is 'Returns a list of all term variables.', - argnames is ['Term', 'List']]). - -:- end_protocol. diff --git a/Logtalk/library/time.lgt b/Logtalk/library/time.lgt deleted file mode 100644 index 265de01fc..000000000 --- a/Logtalk/library/time.lgt +++ /dev/null @@ -1,22 +0,0 @@ - -:- object(time, - implements(timep)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Time predicates.']). - - now(Hours, Mins, Secs) :- - {'$lgt_current_time'(Hours, Mins, Secs)}. - - cpu_time(Seconds) :- - {'$lgt_cpu_time'(Seconds)}. - - valid(Hours, Mins, Secs) :- - integer(Hours), Hours >= 0, - integer(Mins), Mins >= 0, Mins =< 59, - integer(Secs), Secs >= 0, Secs =< 59. - -:- end_object. diff --git a/Logtalk/library/timep.lgt b/Logtalk/library/timep.lgt deleted file mode 100644 index ea345e498..000000000 --- a/Logtalk/library/timep.lgt +++ /dev/null @@ -1,28 +0,0 @@ - -:- protocol(timep). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Time protocol.']). - - :- public(now/3). - :- mode(now(-integer, -integer, -integer), one). - :- info(now/3, [ - comment is 'Returns current time.', - argnames is ['Hours', 'Mins', 'Secs']]). - - :- public(cpu_time/1). - :- mode(cpu_time(-number), one). - :- info(cpu_time/1, - [comment is 'Returns the current cpu time.', - argnames is ['Time']]). - - :- public(valid/3). - :- mode(valid(+integer, +integer, +integer), zero_or_one). - :- info(valid/3, [ - comment is 'True if the arguments represent a valid time value.', - argnames is ['Hours', 'Mins', 'Secs']]). - -:- end_protocol. diff --git a/Logtalk/library/types.notes b/Logtalk/library/types.notes deleted file mode 100644 index 347c65528..000000000 --- a/Logtalk/library/types.notes +++ /dev/null @@ -1,16 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -To load all entities in this group load the types_loader.lgt utility -file: - - | ?- logtalk_load(types_loader). - -These objects implement predicates over common Prolog terms and -structures such as lists, difference lists, binary trees, queues, -dictionaries, and sets. diff --git a/Logtalk/library/types_loader.lgt b/Logtalk/library/types_loader.lgt deleted file mode 100644 index 644c984ae..000000000 --- a/Logtalk/library/types_loader.lgt +++ /dev/null @@ -1,17 +0,0 @@ - -:- initialization( - logtalk_load([ - termp, term, - atomic, - atom, callable, - characterp, character, - number, float, integer, natural, - compound, - listp, list, list1, - difflist, - numberlistp, numberlist, varlist, - queuep, queue, - dictionaryp, bintree, - setp, set, set1, - comparingp], - [reload(skip)])). % allow for static binding diff --git a/Logtalk/library/varlist.lgt b/Logtalk/library/varlist.lgt deleted file mode 100644 index 6c9b0bc11..000000000 --- a/Logtalk/library/varlist.lgt +++ /dev/null @@ -1,37 +0,0 @@ - -:- object(varlist, - extends(list)). - - :- info([ - version is 1.0, - author is 'Paulo Moura', - date is 2000/7/24, - comment is 'List of variables predicates.']). - - member(Element, [Head| _]) :- - Element == Head. - member(Element, [_| Tail]) :- - member(Element, Tail). - - - memberchk(Element, [Head| Tail]) :- - ( Element == Head -> - true - ; memberchk(Element, Tail) - ). - - prefix([], _). - prefix([Head1| Tail1], [Head2| Tail2]) :- - Head1 == Head2, - prefix(Tail1, Tail2). - - valid(List) :- - nonvar(List), - \+ \+ valid2(List). - - valid2([]). - valid2([Head| Tail]) :- - var(Head), - valid2(Tail). - -:- end_object. diff --git a/Logtalk/manuals/NOTES.txt b/Logtalk/manuals/NOTES.txt deleted file mode 100644 index 9f3450ac9..000000000 --- a/Logtalk/manuals/NOTES.txt +++ /dev/null @@ -1,34 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - -To consult the Logtalk documentation open the file "index.html" with a -web browser. - -All manual pages conform to the XHTML 1.1 W3C Standard. You may change -the appearance of the pages by changing the included "screen.css" -CSS file. Needless to say, the manual pages look better in recent web -browser releases that support both the XHTML 1.1 and CSS 2 web standards. - -The "print.css" CSS file can be used with CSSToXSLFO (version 1.5 or -later) to generate PDF files with page numbers suitable for printing. -For informations on how to use CSSToXSLFO, please see the following -URL: - - http://www.re.be/css2xslfo/ - -Two scripts are provided to convert the XHTML manual pages to PDF files: - - userman/userman.sh - Bourne-compatible shell script for POSIX systems that generates - a PDF version of the User Manual - - refman/refman.sh - Bourne-compatible shell script for POSIX systems that generates - a PDF version of the Reference Manual - -You may edit the scripts in order to change the default XSLT and/or XSL-FO -processors. diff --git a/Logtalk/manuals/bibliography.html b/Logtalk/manuals/bibliography.html deleted file mode 100644 index 0b792d9bb..000000000 --- a/Logtalk/manuals/bibliography.html +++ /dev/null @@ -1,352 +0,0 @@ - - - - - - - - Logtalk: Bibliography - - - - - - - - -

Bibliography

- - -
-
[Alexiev 93]
-
Mutable Object State for Object-Oriented Logic Programming: A Survey
-
Alexiev, V.
-
Technical Report TR 93-15, Department of Computing Science, University of Alberta, Canada
-
- -
-
[Belli et al. 92]
-
Object-oriented programming in Prolog: rationale and a case study
-
Belli, F., Jack, O., Naish, L.
-
Technical Report 92/2, Department of Electrical and Electronics Engineering, University of Paderborn, Germany
-
URL: http://www.cs.mu.oz.au/~lee/papers/oolp/
-
- -
-
[Block 89]
-
An Extended Frame Language
-
Block, F. P., Chan, N. C.
-
Proceedings OOPLSLA 89(10):151-157, ACM
-
- -
-
[Bobrow et al. 88]
-
Common Lisp Object System Specification
-
Bobrow, D. G., Michiel, L. G., Gabriel, R. P., Keene, S. E., Kiczales, G., Moon, D. A.
-
ACM SIGPLAN Notices(23)
-
- -
-
[Bratko 90]
-
Prolog Programming for Artificial Intelligence
-
Bratko, I.
-
Addison Wesley, 2º edition, 1990
-
- -
-
[Champaux 92]
-
A comparative Study of Object-Oriented Analysis Methods
-
Champaux, D., Faure, P.
-
Journal of Object-Oriented Programming, Vol. 5, N.1, 1992
-
- -
-
[Clocksin 87]
-
Programming in Prolog
-
Clocksin, W.F., Mellish, C.S.
-
Springer-Verlag, New York, 1987
-
- -
-
[Cointe 87]
-
Metaclasses are First Class: the ObjVlisp Model
-
Cointe, P.
-
Proceedings OOPLSLA 87(10):156-167, ACM
-
- -
-
[Cordes 91]
-
The Literate Programming Paradigm
-
Cordes, D., Brown, M.
-
IEEE Computer, June 1991:52-61
-
- -
-
[Covington 94]
-
ISO Prolog: A Summary of the Draft Proposed Standard
-
Covington, M. A.
-
URL: ftp://ai.uga.edu/pub/prolog.standard/
-
- -
-
[Cox 86]
-
Object-Oriented Programming: An Evolutionary Approach
-
Cox, Brad J.
-
Addison-Wesley Publishing Company, Don Mills, Ontario
-
- -
-
[Davison 89]
-
Polka: A Parlog Object oriented language
-
Davison, A.
-
Ph.D. Thesis, Imperial College, London, 1989
-
- -
-
[Davison 92]
-
A survey of logic programming-based object oriented languages
-
Davison, A.
-
Tech Report 92/3, Dept. of Computer Science, University of Melbourne, Australia
-
URL: http://www.cs.mu.oz.au/tr_db/mu_92_03.ps.gz
-
- -
-
[Davison 93]
-
The deductive and object oriented features of BeBOP
-
Davison, A.
-
Tech Report 93/6, Dept. of Computer Science, University of Melbourne, Australia
-
URL:http://www.cs.mu.oz.au/tr_db/mu_93_06.ps.gz
-
- -
-
[Delzanno 97]
-
Logic and Object-Oriented Programming in Linear Logic
-
Delzanno, G.
-
Ph.D. Thesis, University of Pisa, Italy
-
URL:http://www.mpi-sb.mpg.de/~delzanno/
-
- -
-
[Dony 90]
-
Exception Handling and Object-Oriented Programming: Towards a Synthesis
-
Dony, C.
-
Proceedings OOPLSLA 90:322-330, ACM
-
- -
-
[Fornarino et al. 89]
-
An Original Object-Oriented Approach for Relation Management
-
Fornarino, M., Pinna, A.-M.,Trousse, B.
-
Proceedings of the 4th Portuguese Conference on Artificial Intelligence
-
Lecture Notes in Artificial Intelligence, Springer-Verlag (390):13-26
-
- -
-
[Fromherz 93]
-
OL(P): Object Layer for Prolog
-
Fromherz, M.
-
URL: ftp://parcftp.xerox.com/ftp/pub/ol/
-
- -
-
[Fukunaga 86]
-
An Experience with a Prolog-based Object-Oriented Language
-
Fukunaga, K., Hirose, S.
-
Proceedings OOPLSLA 86, 21(11):224-231, ACM
-
- -
-
[Goldberg 83]
-
Smalltalk-80 The language and its implementation
-
Goldberg, A., Robson, D.
-
Addison-Wesley Series in Computer Science
-
- -
-
[Joy et al. 00]
-
The Java Language Specification, Second Edition
-
Joy, B., Steele, G., Gosling, J., Bracha, G.
-
Addison-Wesley, 2000
-
- -
-
[ISO 95]
-
ISO/IEC DIS 13211-1 - Programming Language Prolog Part 1: General Core
-
Joint Technical Committee ISO/IEC JTC 1
-
URL: http://www.iso.ch/cate/d21413.html
-
- -
-
[Knuth 84]
-
Literate Programming
-
Knuth, D. E.
-
Computer Journal, May 84, 27(2):97-111
-
- -
-
[Lieberman 86]
-
Using Prototypical Objects to Implement Shared Behaviour in Object Oriented Systems
-
Lieberman, H.
-
Proceedings OOPLSLA 86:189-214, ACM
-
- -
-
[Maes 87]
-
Concepts and Experiments in Computational Reflection
-
Maes, P.
-
Proceedings OOPLSLA 87, ACM
-
- -
-
[McCabe 92]
-
Logic and Objects
-
McCabe, F. G.
-
Prentice Hall Series in Computer Science
-
- -
-
[Moon 86]
-
Object-Oriented Programming in Flavors
-
Moon, D.
-
Proceedings OOPLSLA 86:1-8, ACM
-
- -
-
[Moss 94]
-
Prolog++ The Power of Object-Oriented and Logic Programming
-
Moss, C.
-
Addison-Wesley International Series in Logic Programming, 1994
-
- -
-
[Moura 94]
-
Logtalk: Programação Orientada para Objectos em Prolog
-
Moura, P., Costa, E.
-
2ª Conferência e Exposição Portuguesa de Tecnologia Orientada por Objectos
-
3i Consultores, Liboa
-
- -
-
[Moura 99]
-
Porting Prolog: Notes on porting a Prolog program to 22 Prolog compilers or the relevance of the ISO Prolog standard
-
Moura, P.
-
ALP Newsletter, Vol. 12/2, May 1999
-
- -
-
[Moura 00]
-
Logtalk 2.6 Documentation
-
Moura, P.
-
Technical Report DMI 2000/1
-
University of Beira Interior, Portugal
-
- -
-
[Razek 92]
-
Combining Objects and Relations
-
Razek, G.
-
Comunications of the ACM, 27(12):66-70
-
- -
-
[Rumbaugh 87]
-
Relations as Semantic Constructs in an Object-Oriented Language
-
Rumbaugh, J.
-
Proceedings OOPLSLA 87:466-481, ACM
-
- -
-
[Rumbaugh 88]
-
Controlling Propagation of Operations using Attributes on Relations
-
Rumbaugh, J.
-
Proceedings OOPLSLA 88:285-296, ACM
-
- -
-
[Schachte 95]
-
Efficient Object-Oriented Programming in Prolog
-
Schachte, P., Saab, G.
-
Logic Programming: Formal Methods and Pratical Applications
-
Studies in Computer Science and Artificial Intelligence, 11
-
Elsevier Science B.V. North-Holland, Amsterdam, 1995
-
- -
-
[SICStus 95]
-
SICStus Prolog Manual
-
SICStus
-
URL: http://www.sics.se/ps/sicstus.html
-
- -
-
[Shan et al. 93]
-
Is Multiple Inheritance Essential to OOP? (Panel)
-
Shan, Y., Cargill, T., Cox, B., Cook, W., Loomis, M., Snyder, A.
-
Proceedings OOPLSLA 93:360-363
-
- -
-
[Stefik et al. 86]
-
Integrating Acess-Oriented Programming into a Multiparadigm Environment
-
Stefik, M. J., Bobrow, D. G. , Kahn, K. M.
-
IEEE Software, January 1986:10-18
-
- -
-
[Stroustrup 86]
-
The C++ Programming Language
-
Stroustrup, B.
-
Addison-Wesley Series in Computer Science
-
- -
-
[Taenzer 89]
-
Problems in Object-Oriented Software Reuse
-
Taenzer, D., Ganti, M., Podar, S.
-
Proceedings of ECOOP 89
-
British Computer Society Workshop Series, Cambridge University Press
-
- -
-
[Tanzer 95]
-
Remarks on Object-Oriented Modeling of Associations
-
Tanzer, C.
-
Journal of Object-Oriented Programming, February 1995, SIGS Publications
-
- -
-
[Tanenbaum 87]
-
Operating Systems - Design and Implementation
-
Tanenbaum, A.
-
Prentice-Hall Software Series, 1987
-
- -
-
[Welsch 89]
-
Reasoning Objects with Dynamic Knowledge Bases
-
Welsch, C., Barth, G.
-
Proceedings of the 4th Portuguese Conference on Artificial Intelligence(390):257-268
-
Lecture Notes in Artificial Intelligence, Springer-Verlag, 1989
-
- -

-More references can be found in the Object-Oriented Logic Programming Resources web page. -

- - - - - - diff --git a/Logtalk/manuals/glossary.html b/Logtalk/manuals/glossary.html deleted file mode 100644 index 5ba2798c3..000000000 --- a/Logtalk/manuals/glossary.html +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - - Logtalk: Glossary - - - - - - -
Logtalk documentation
-
Glossary
-
-
- - -

Glossary

- -
- -
ancestor
-
A class or parent that contributes (via inheritance) to the definition of an object. For class-based hierarchies, the ancestors of an object are its class(es) and all the superclasses of its class(es). For prototype-based hierarchies, the ancestors of an object are its parent(s) and the ancestors of its parent(s).
- -
category
-
A set of predicates directives and clauses that can be imported by any object.
- -
class
-
An object that defines the common predicates of a set of objects (its instances).
- -
- -
abstract class
-
A class that cannot be instantiated. Usually used to store common predicates that are inherited by other classes.
- -
metaclass
-
The class of a class, when we see it as an object. Metaclass instances are themselves classes. In a reflexive system any metaclass is also an object.
- -
subclass
-
A class that is a specialization, direct or indirectly, of another class.
- -
superclass
-
A class from which another class is a specialization (directly or indirectly via another class).
- -
- -
directive
-
A Prolog/Logtalk term that affects the interpretation of Prolog/Logtalk code. Directives are represented using the :-/1 prefix operator.
- -
- -
entity directive
-
A directive that affects how Logtalk entities (objects, protocols, or categories) are used or compiled.
- -
predicate directive
-
A directive that affects how predicates are called or compiled.
- -
source file directive
-
A directive that affects how a source file is compiled.
- -
- -
encapsulation
-
The hiding of an object implementation. This promotes software reuse by isolating users from implementation details.
- -
entity
-
Generic name for Logtalk compilation units: objects, categories, and protocols.
- -
event
-
The sending of a message to an object. An event can be expressed as an ordered tuple: (Event, Object, Message, Sender). Logtalk distinguish between the sending of a message - before event - and the return of control to the sender - after event.
- -
grammar rule
-
An alternative notation for predicates used to parse or generate sentences on some language. This notation hides the arguments used to pass the lists of tokens being processed, thus simplifying the representation of grammars. Grammar rules are represented using the infix operator -->/2 instead of the operator used on predicate clauses (:-/2).
- -
- -
grammar rule non-terminal
-
A syntactic category of words of phrases. A non-terminal is identified by its name and number of arguments using the notation <name>//<nargs>.
- -
grammar rule terminal
-
A word or a basic symbol of a language.
- -
- -
identity
-
Property of an entity that distinguishes it from every other entity. In Logtalk, an object identity can be an atom or a compound term. Category and protocol identities must be atoms. All Logtalk entities (objects, protocols, and categories) share the same name space.
- -
inheritance
-
An object inherits predicate directives and clauses from other objects that it extends or specializes. If an object extends other object then we have a prototype-based inheritance. If an object specializes or instantiates another object we have a class-based inheritance.
- -
- -
private inheritance
-
All public and protected predicates are inherited as private predicates.
- -
protected inheritance
-
All public predicates are inherited as protected. No change for protected or private predicates.
- -
public inheritance
-
All inherited predicates maintain the declared scope.
- -
- -
instance
-
The same as object. This term is used when we want to emphasize that an object characteristics are defined by another object (its class).
- -
instantiation
-
The process of creating a new class instance. In Logtalk, this does not necessarily implies dynamic creation of an object at runtime; an instance may also be defined as a static object in a source file.
- -
library
-
A directory containing source files. The directory name is used as the library name.
- -
message
-
A request for a service, sent to an object. In more logical terms, a message can be seen as a request for proof construction using an object's predicates.
- -
metainterpreter
-
A program capable of running other programs written in the same language.
- -
method
-
Set of predicate clauses used to answer a message sent to an object. Logtalk uses dynamic binding to find which method to run to answer a message.
- -
monitor
-
Any object that is notified when a spied event occurs. The spied events can be set by the monitor itself or by any other object.
- -
object
-
An entity characterized by an identity and a set of predicate directives and clauses. Logtalk objects can be either static or dynamic. Logtalk objects can play the role of classes, instances, or prototypes.
- -
- -
parametric object
-
An object whose name is a compound term containing free variables that can be used to parameterize the object predicates.
- -
parametric object proxy
-
A compound term with the same functor and usually with the same number of arguments as the identifier of a parametric object.
- -
- - -
parent
-
A prototype that is extended by another prototype.
- -
predicate
-
Predicates describe what is true about the application domain. A predicate is identified by its name and number of arguments using the notation <name>/<nargs>.
- -
- -
local predicate
-
A predicate that is defined in an object (or in a category) but that is not listed in a scope directive. These predicates behave like private predicates but are invisible to the reflection built-in methods. Local predicates are usually auxiliary predicates, only relevant to the entity where they are defined.
- -
meta-predicate
-
A predicate where one of its arguments will be called as a goal. For instance, findall/3 and call/1 are Prolog built-ins meta-predicates.
- -
private predicate
-
A predicate that can only be called from the object that contains the scope directive.
- -
protected predicate
-
A predicate that can only be called from the object containing the scope directive or from an object that inherits the predicate.
- -
public predicate
-
A predicate that can be called from any object.
- -
visible predicate
-
A predicate that is declared for an object, a built-in method, or a Prolog/Logtalk built-in predicate.
- -
- -
profiler
-
A program that collects data about other program performance.
- -
protocol
-
A set of predicates directives that can be implemented by an object or a category (or extended by another protocol).
- -
prototype
-
A self-describing object that may extend or be extended by other objects.
- -
self
-
The original object that received the message under processing.
- -
sender
-
An object that sends a message to other object.
- -
specialization
-
A class is specialized by constructing a new class that inherit its predicates and possibly add new ones.
- -
this
-
The object that contains the predicate clause under execution.
- -
- - - - - - diff --git a/Logtalk/manuals/index.html b/Logtalk/manuals/index.html deleted file mode 100644 index e81ea75e4..000000000 --- a/Logtalk/manuals/index.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - Logtalk 2.30.7 Documentation - - - - - - - - -

Logtalk 2.30.7 Documentation

- - - - - - - - diff --git a/Logtalk/manuals/migration/index.html b/Logtalk/manuals/migration/index.html deleted file mode 100644 index 9a129c501..000000000 --- a/Logtalk/manuals/migration/index.html +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - - Logtalk: Prolog Integration and Migration Guide - - - - - - - - - -

Prolog Integration and Migration Guide

- -

-An application may include plain Prolog files, Prolog modules, and Logtalk objects. This is a perfectly valid way of developing a complex application and, in some cases, it might be the most appropriated solution. Modules may be used for legacy code or when a simple encapsulation mechanism is adequate. Logtalk objects may be used when more powerful encapsulation, abstraction, and reuse features are needed. Logtalk supports the compilation of source files containing both plain Prolog and Prolog modules. This guide provides tips for helping integrating and migrating plain Prolog code and Prolog module code to Logtalk. Step-by-step instructions are provided for encapsulating plain Prolog code in objects, converting Prolog modules into objects, and compiling and reusing Prolog modules as objects from inside Logtalk. An interesting application of the techniques described in this guide is a solution for running a Prolog application which uses modules on a Prolog compiler with no module system. -

- - -

Source files with both Prolog code and Logtalk code

- -

-Logtalk source files may contain plain Prolog code intermixed with Logtalk code. The Logtalk compiler just copies the plain Prolog code as-is to the generated Prolog file. With Prolog modules, it is assumed that the module code starts with a module/1-2 directive and ends at the end of the file. There is no module ending directive which would allowed us define more than one module per file. In fact, most Prolog module systems always define a single module per file. Some of them mandate that the module/1-2 directive be the first term on a source file. As such, when the Logtalk compiler finds a module/1-2 directive, it assumes that all code that follows until the end of the file belongs to the module. -

- - -

Encapsulating plain Prolog code in objects

- -

-Most applications consist of several plain Prolog source files, each one defining a few top predicates and auxiliary predicates that are not meant to be directly called by the user. Encapsulating plain Prolog code in objects allows us to make clear the different roles of each predicate, to hide implementation details, and to take advantage of other Logtalk features. -

-

-Encapsulating Prolog code using Logtalk objects is easy. First, for each source file, add an opening object directive, object/1, to the beginning of the file and an ending object directive, end_object/0, to end of the file. Choose an object name that reflects the purpose of source file code (this is a good opportunity to reorganize your code if needed). Second, add public predicate directives for the top-level predicates that are used directly by the user or called from other source files. Third, we need to be able to call from inside an object a predicate defined in other source file/object. The easiest solution, which has the advantage of not implying any modification to the predicate clauses, is to use the uses/2 directive. If your Prolog compiler supports cross-referencing tools, you may use them to help you make sure that all calls to predicates on other source files/objects are listed in the uses/2 directives. Compiling the resulting objects with the Logtalk portability flag set to warning will help you locate calls to predicates defined on other converted source files. -

- -

Prolog multifile predicates

- -

-Prolog multifile predicates are used when clauses for the same predicate are spread among several source files. When encapsulating plain Prolog code that uses multifile predicates, is often the case that the clauses of the multifile predicates get spread between different objects and categories. When calling such predicates, you often want to use not only local clauses but also clauses stored in ancestor objects or imported. However, these inherited clauses are overridden by the local ones. For ancestor objects, use the super call operator, ^^/1, to get access to the overridden clauses. For imported categories, use the message to self operator, ::/1, to get access to the overridden clauses. For example, assume a multifile predicate, mp/2 with both local clauses and clauses imported from a category. The solution is to add a local clause giving access to the imported clauses by using the ::/1 operator: -

-
-mp(..., ...).    % local clauses
-...
-mp(A, B) :-      % imported clauses
-    ::mp(A, B).
-
-

-By adding the gateway clause after or before the local clauses, you can choose if the local clauses should be used before or after the overridden clauses. -

- -

Converting Prolog modules into objects

- -

-Converting Prolog modules into objects allows an application to run on a wider range of Prolog compilers, overcoming module compatibility problems. Not all Prolog compilers support a module system. Among those Prolog compilers which support a module system, the lack of standardization leads to several issues, specially with operators and meta-predicates. In addition, the conversion allows you to take advantage of Logtalk more powerful abstraction and reuse mechanisms such as separating interface from implementation. -

-

-Converting a Prolog module into an object is easy as long as the directives used in the module are supported by Logtalk (see below). First, convert the module module/1 directive into an opening object directive, object/1, using the module name as the object name. For module/2 directives apply the same conversion and convert the list of exported predicates into Logtalk public predicate directives. Second, add a closing object directive, end_object/0, at the end of the module code. Third, convert any export/1 directives into public predicate directives. Fourth, convert any use_module/2 directives into Logtalk uses/2 directives. Any use_module/1 directives are also converted into Logtalk uses/2 directives but you will need first to find out which predicates your module uses from the specified modules. Fifth, convert any meta_predicate/1 directives into Logtalk meta-predicate/1 directives by replacing the module meta-argument indicator, :, into the Logtalk meta-predicate indicator, ::. Arguments which are not meta-arguments are represented by the * character. Compile the resulting objects with the Logtalk portability flag set to warning to help you locate calls to predicates defined on other converted modules. -

- - -

Compiling Prolog modules as objects

- -

-An alternative to convert Prolog modules into objects is to just compile the modules as objects. This has the advantage of not implying any code changes. However, this is only possible for modules containing only predicates clauses and Logtalk supported directives (see below). Assuming that is the case, you may compile a Prolog module as an object by changing the source file name extension to .lgt and then using the logtalk_load/1-2 and logtalk_compile/1-2 predicates (set the Logtalk portability flag set to warning to help you catch any unnoticed cross-module predicate calls). This allows you to reuse existing module code as objects. However, there are some limitations that you should be aware. These limitations are a consequence of the lack of standardization of Prolog module systems. Currently, Logtalk supports the following module directives: -

-
-
module/1
-
The module name becomes the object name.
-
module/2
-
The module name becomes the object name. The exported predicates become public object predicates.
-
use_module/2
-
This directive is compiled as a Logtalk uses/2 directive in order to ensure correct compilation of the module predicate clauses. Note that the module specified on the directive is not automatically loaded by Logtalk (as it would be when compiling the directive using Prolog instead of Logtalk; the programmer may also want the specified module to be compiled as an object).
-
export/1
-
Exported predicates are compiled as public object predicates. The argument must be a predicate indicator (Functor/Arity) or a list of predicate indicators.
-
meta_predicate/1
-
Module meta-predicates become object meta-predicates. Only predicate arguments marked as : are interpreted as meta-arguments. However, note that Prolog module meta-predicates and Logtalk meta-predicates don't share the same exact semantics; check results carefully.
-
-

-Logtalk supports the use of the library(name) notation on the module/1-2 and use_module/2 directives (assuming there is an entry for the library on the logtalk_library_path/2 table). -

-

-When compiling modules as objects, you probably don't need event support turned on. Thus, you may want to use the compiler option events(off) with the Logtalk compiling and loading built-in methods for a small performance gain for the compiled code. -

- -

Current limitations and workarounds

- -

-Note that use_module/1 directives are not directly supported. Therefore, this directives must be converted into use_module/2 directives by finding which predicates exported by the specified module are imported into the module containing the directive. Automating the conversion would imply loading the module without re-interpreting it as an object, which might not be what the user intended. Nevertheless, finding the names of the imported predicates is easy. First, comment out the use_module/1 directives and compile the file (making sure that the compiler flag misspelt is set to warning). Logtalk will print a warning with a list of predicates that are called but never defined. Second, use these list to replace the use_module/1 directives by use_module/2 directives. You should then be able to compile the modified Prolog module as an object. -

-

-Changing the extension of a module source file to .lgt in order to be able to compile it as Logtalk source file is not always feasible. An alternative is to create symbolic links or shortcuts for the module files using *.lgt names. In addition, for avoiding conflicts between the Logtalk generated Prolog files and the module files, create the links on a different directory and add a library entry for the directory using the predicate logtalk_library_path/2. For example, on a POSIX operating-system with library/*.pl module source file names, the links can be easily created by running the following bash shell commands: -

-
$ mkdir lgtlib
-$ cd lgtlib
-$ for i in ../library/*.pl; do ln -sf $i `basename $i .pl`.lgt; done
-

-The symbolic links or shortcuts can also be easily created on most operating-systems using the GUI tools. -

- - -

Dealing with proprietary Prolog directives

- -

-Most Prolog compilers define proprietary, non-standard directives that may be used in both plain code and module code. Logtalk will generate compilation errors on source files containing these directives unless you first specify how the directives should be handled. Three actions are possible and can be specified, on a per-directive basis, on the Prolog configuration files: ignoring the directive (i.e. do not copy the directive, although a goal can be proved as a consequence), rewriting and copy the directive to the generated Prolog files, or rewriting and recompiling the resulting directive. Each action is specified using, respectively, the predicates: '$lgt_ignore_pl_directive'/1, '$lgt_rewrite_and_copy_pl_directive'/2, and '$lgt_rewrite_and_recompile_pl_directive'/2. For example, assume that a given Prolog compiler defines a comment/2 directive for predicates using the format: -

-
:- comment(foo/2, "Brief description of the predicate").
-

-We can rewrite this predicate into a Logtalk info/2 directive by defining a suitable clause for the '$lgt_rewrite_and_recompile_pl_directive'/2 predicate: -

-
'$lgt_rewrite_and_recompile_pl_directive'(comment(F/A, String), info(F/A, [comment is Atom])) :-
-    atom_codes(Atom, String).
-

-This Logtalk feature can be used to allow compilation of legacy Prolog code without the need of changing the sources. When used, is advisable to set the portability/1 compiler flag to warning in order to more easily identify source files that are likely non-portable across Prolog compilers. -

-

-A second example, using the '$lgt_ignore_pl_directive'/1 hook predicate: -

-
'$lgt_ignore_pl_directive'(load_foreign_files(Files,Libs,InitRoutine)) :-
-    load_foreign_files(Files,Libs,InitRoutine).
-

-In this case, although the directive is not copied to the generated Prolog file, the foreign library files are loaded as a side-effect of calling the hook predicate. -

- - -

Calling Prolog module predicates using message sending

- -

-Logtalk allows you to send a message to a module in order to call one of its predicates. This is usually not advised as it implies a performance penalty when compared to just using the Module:Call notation (encapsulating the call between curly brackets when sending the message from inside an object). Note that this only works if there is no object with the same name as the module you are targeting. -

-

-This feature is needed to properly support compilation of modules containing use_module/2 directives as objects. If the modules specified in the use_module/2 directives are not compiled as objects but are instead loaded as-is by Prolog, the exported predicates would need to be called using the Module:Call notation but the converted module will be calling them through message sending. Thus, this feature ensures that, on a module compiled as an object, any predicate calling other module predicates will work as expected either these other modules are loaded as-is or also compiled as objects. -

- - - - - - diff --git a/Logtalk/manuals/print.css b/Logtalk/manuals/print.css deleted file mode 100644 index b39bd5af4..000000000 --- a/Logtalk/manuals/print.css +++ /dev/null @@ -1,275 +0,0 @@ - -div.bottom-left > span.page:before { - content: counter(page, decimal); -} - -div.bottom-right > span.page:before { - content: counter(page, decimal); -} - -div.toc-bottom-left > span.page:before { - content: counter(page, lower-roman); -} - -div.toc-bottom-right > span.page:before { - content: counter(page, lower-roman); -} - -@page title { - margin-left: 25mm; - margin-right: 15mm; - margin-top: 15mm; - margin-bottom: 15mm; -} - -@page toc { - counter-reset: page; -} - -@page body { - counter-reset: page; -} - -@page :left { - margin-left: 15mm; - margin-right: 25mm; - margin-top: 15mm; - margin-bottom: 15mm; -} - -@page :right { - margin-left: 25mm; - margin-right: 15mm; - margin-top: 15mm; - margin-bottom: 15mm; -} - -body { - color: black; - font-size: 10pt; - font-family: Times, serif; - padding-top: 18pt; - padding-bottom: 18pt; - background: white; - region: body; - hyphenate: true; -} - -.navtop { - display: none; -} - -.toc-top-left, .toc-top-right, .top-left, .top-right { - font-size: 9pt; - font-weight: bold; - font-family: Helvetica, Arial, Verdana, sans-serif; - border-color: black; - border-left: 0pt; - border-top: 0pt; - border-right: 0pt; - border-bottom: 1pt; - border-style: solid; - region: top; -} - -.toc-top-left { - page: left-toc; - text-align: left; -} - -.toc-top-right { - page: right-toc; - text-align: right; -} - -.top-left { - page: left-body; - text-align: left; -} - -.top-right { - display: none; - page: right-body; - text-align: right; -} - -div.top-right > span.chapter:before { - content: string(chapter); -} - -.toc-bottom-left, .toc-bottom-right, .bottom-left, .bottom-right { - region: bottom; - font-size: 9pt; - font-weight: bold; - font-family: Helvetica, Arial, Verdana, sans-serif; - border-color: black; - border-left: 0pt; - border-top: 1pt; - border-right: 0pt; - border-bottom: 0pt; - border-style: solid; -} - -.toc-bottom-left { - page: left-toc; - text-align: left; -} - -.toc-bottom-right { - page: right-toc; - text-align: right; -} - -.bottom-left { - page: left-body; - text-align: left; -} - -.bottom-right { - page: right-body; - text-align: right; -} - -a { - color: black; - text-decoration: none; - outline: none; -} - -a[href] { - link: href; -} - -a[id] { - anchor: name; -} - -.footer { - text-align: right; - font-size: 9pt; - page-break-before: avoid; - page-break-inside: avoid; -} - -.navbottom { - display: none; -} - -.copyright { - display: block; - padding-top: 18pt; -} - -.footnote { -} - -span.leader { - display: leader; - leader-pattern: dots; - leader-pattern-width: 5pt; -} - -span.page-ref > span:before { - content: page-ref(class); -} - -.title-page { - page: title; - page-break-after: always; - font-family: Helvetica, Arial, Verdana, sans-serif; -} - -.title-top { - page: first-title; - region: top; -} - -.title-bottom { - page: first-title; - region: bottom; -} - -.title { - text-align: center; - font-size: 36pt; -} - -.sub-title { - text-align: center; - font-size: 24pt; -} - -.credits { - text-align: center; - font-size: 18pt; -} - -.date { - text-align: center; - font-size: 14pt; -} - -h1, h2, h3, h4, h5, h6 { - font-family: Helvetica, Arial, Verdana, sans-serif; - text-align: left; - page-break-after: avoid; -} - -h1 { - padding-top: 96pt; - page-break-before: right; - string-set: chapter contents; -} - -.toc { - page: toc; -} - -div.toc > h1 { - text-align-last: left; -} - -.toc-entries { - page-break-before: avoid; - text-align-last: justify; -} - -.body { - page: body; -} - -pre, code, .code, .codenp { - color: maroon; - font-family: Monaco, 'Courier New', Courier, monospace; -} - -code { - font-size: 9pt; - hyphenate: false; -} - -.codenp { - padding-top: 24pt; - page-break-before: always; -} - -pre { - font-size: 9pt; - text-align: left; - background-color: #efefef; - border-color: #111111; - border-width: 1pt; - border-style: double; - padding: 8pt; - page-break-before: avoid; -} - -ul, ol { - display: compact; - page-break-before: avoid; -} - -dl { - page-break-before: avoid; - padding-left: 2em; -} diff --git a/Logtalk/manuals/refman/builtins.header b/Logtalk/manuals/refman/builtins.header deleted file mode 100644 index 93fe7afb2..000000000 --- a/Logtalk/manuals/refman/builtins.header +++ /dev/null @@ -1,2 +0,0 @@ - -

Built-in predicates

diff --git a/Logtalk/manuals/refman/builtins/abolish_category1.html b/Logtalk/manuals/refman/builtins/abolish_category1.html deleted file mode 100644 index 8bffe2edf..000000000 --- a/Logtalk/manuals/refman/builtins/abolish_category1.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - Logtalk built-in predicate: abolish_category/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: abolish_category/1
-
-
- - -

abolish_category/1

- -

Description

- -
abolish_category(Category)
-

-Removes from the database a dynamic category. -

- -

Template and modes

- -
abolish_category(@category_identifier)
- -

Errors

- -
-
Category is a variable:
-
instantiation_error
-
Category is neither a variable nor a valid category identifier:
-
type_error(category_identifier, Category)
-
Category is an identifier of a static category:
-
permission_error(modify, static_category, Category)
-
Category does not exist:
-
existence_error(category, Category)
-
- -

Examples

- -
| ?- abolish_category(monitoring).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/abolish_events5.html b/Logtalk/manuals/refman/builtins/abolish_events5.html deleted file mode 100644 index 4fdd02808..000000000 --- a/Logtalk/manuals/refman/builtins/abolish_events5.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - Logtalk built-in predicate: abolish_events/5 - - - - - - -
Logtalk reference manual
-
Built-in predicate: abolish_events/5
-
-
- - -

abolish_events/5

- - -

Description

- -
abolish_events(Event, Object, Message, Sender, Monitor)
-

-Abolishes all matching events. The two types of events are represented by the atoms before and after. -

- -

Template and modes

- -
abolish_events(@event, @object_identifier, @callable, @object_identifier, @object_identifier)
- -

Errors

- -
-
Event is neither a variable nor a valid event identifier:
-
type_error(event, Event)
-
Object is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Object)
-
Message is neither a variable nor a callable term:
-
type_error(callable, Message)
-
Sender is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Sender)
-
Monitor is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Monitor)
-
- -

Examples

- -
| ?- abolish_events(_, list, _, _, debugger).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/abolish_object1.html b/Logtalk/manuals/refman/builtins/abolish_object1.html deleted file mode 100644 index 7a4baf33e..000000000 --- a/Logtalk/manuals/refman/builtins/abolish_object1.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - Logtalk built-in predicate: abolish_object/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: abolish_object/1
-
-
- - -

abolish_object/1

- -

Description

- -
abolish_object(Object)
-

-Removes from the database a dynamic object. -

- -

Template and modes

- -
abolish_object(@object_identifier)
- -

Errors

- -
-
Object is a variable:
-
instantiation_error
-
Object is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Object)
-
Object is an identifier of a static object:
-
permission_error(modify, static_object, Object)
-
Object does not exist:
-
existence_error(object, Object)
-
- -

Examples

- -
| ?- abolish_object(list).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/abolish_protocol1.html b/Logtalk/manuals/refman/builtins/abolish_protocol1.html deleted file mode 100644 index 3947abb23..000000000 --- a/Logtalk/manuals/refman/builtins/abolish_protocol1.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - Logtalk built-in predicate: abolish_protocol/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: abolish_protocol/1
-
-
- - -

abolish_protocol/1

- -

Description

- -
abolish_protocol(Protocol)
-

-Removes from the database a dynamic protocol. -

- -

Template and modes

- -
abolish_protocol(@protocol_identifier)
- -

Errors

- -
-
Protocol is a variable:
-
instantiation_error
-
Protocol is neither a variable nor a valid protocol identifier:
-
type_error(protocol_identifier, Protocol)
-
Protocol is an identifier of a static protocol:
-
permission_error(modify, static_protocol, Protocol)
-
Protocol does not exist:
-
existence_error(protocol, Protocol)
-
- -

Examples

- -
| ?- abolish_protocol(listp).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/category_property2.html b/Logtalk/manuals/refman/builtins/category_property2.html deleted file mode 100644 index 655abc8d5..000000000 --- a/Logtalk/manuals/refman/builtins/category_property2.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - Logtalk built-in predicate: category_property/2 - - - - - - -
Logtalk reference manual
-
Built-in predicate: category_property/2
-
-
- - -

category_property/2

- -

Description

- -
category_property(Category, Property)
-

- Enumerates, by backtracking, the properties associated with the defined categories. -

- -

Template and modes

- -
category_property(?category_identifier, ?category_property)
- -

Errors

- -
-
Category is neither a variable nor a valid category identifier:
-
type_error(category_identifier, Category)
-
Property is neither a variable nor a valid category property:
-
domain_error(category_property, Property)
-
- -

Examples

- -
| ?- category_property(Category, dynamic).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/create_category4.html b/Logtalk/manuals/refman/builtins/create_category4.html deleted file mode 100644 index 9a5bd4b07..000000000 --- a/Logtalk/manuals/refman/builtins/create_category4.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - Logtalk built-in predicate: create_category/4 - - - - - - -
Logtalk reference manual
-
Built-in predicate: create_category/4
-
-
- - -

create_category/4

- -

Description

- -
create_category(Identifier, Relations, Directives, Clauses)
-

- Creates a new, dynamic, category. -

- -

Template and modes

- -
create_category(+category_identifier, +list, +list, +list)
- -

Errors

- -
-
One of the predicate arguments is a variable:
-
instantiation_error
-
Identifier is neither a variable nor a valid category identifier:
-
type_error(category_identifier, Identifier)
-
Identifier is already in use:
-
permission_error(replace, category, Identifier)
-
permission_error(replace, object, Identifier)
-
permission_error(replace, protocol, Identifier)
-
Relations is neither a variable nor a proper list:
-
type_error(list, Relations)
-
Directives is neither a variable nor a proper list:
-
type_error(list, Directives)
-
Clauses is neither a variable nor a proper list:
-
type_error(list, Clauses)
-
- -

Examples

- -
| ?- create_category(foo, [implements(bar)], [], [bar(1), bar(2)]).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/create_object4.html b/Logtalk/manuals/refman/builtins/create_object4.html deleted file mode 100644 index a0825c9ad..000000000 --- a/Logtalk/manuals/refman/builtins/create_object4.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - Logtalk built-in predicate: create_object/4 - - - - - - -
Logtalk reference manual
-
Built-in predicate: create_object/4
-
-
- - -

create_object/4

- -

Description

- -
create_object(Identifier, Relations, Directives, Clauses)
-

-Creates a new, dynamic, object. -

- -

Template and modes

- -
create_object(+object_identifier, +list, +list, +list)
- -

Errors

- -
-
One of the predicate arguments is a variable:
-
instantiation_error
-
Identifier is not a valid object identifier:
-
type_error(object_identifier, Identifier)
-
Identifier is already in use:
-
permission_error(replace, category, Identifier)
-
permission_error(replace, object, Identifier)
-
permission_error(replace, protocol, Identifier)
-
Relations is neither a variable nor a proper list:
-
type_error(list, Relations)
-
Directives is neither a variable nor a proper list:
-
type_error(list, Directives)
-
Clauses is neither a variable nor a proper list:
-
type_error(list, Clauses)
-
- -

Examples

- -
| ?- create_object(foo, [extends(bar)], [public(foo/1)], [foo(1), foo(2)]).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/create_protocol3.html b/Logtalk/manuals/refman/builtins/create_protocol3.html deleted file mode 100644 index 7c298c9a2..000000000 --- a/Logtalk/manuals/refman/builtins/create_protocol3.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - Logtalk built-in predicate: create_protocol/3 - - - - - - -
Logtalk reference manual
-
Built-in predicate: create_protocol/3
-
-
- - -

create_protocol/3

- -

Description

- -
create_protocol(Identifier, Relations, Directives)
-

-Creates a new, dynamic, protocol. -

- -

Template and modes

- -
create_protocol(+protocol_identifier, +list, +list)
- -

Errors

- -
-
One of the predicate arguments is a variable:
-
instantiation_error
-
Identifier is not a valid protocol identifier:
-
type_error(protocol_identifier, Identifier)
-
Identifier is already in use:
-
permission_error(replace, category, Identifier)
-
permission_error(replace, object, Identifier)
-
permission_error(replace, protocol, Identifier)
-
Relations is neither a variable nor a proper list:
-
type_error(list, Relations)
-
Directives is neither a variable nor a proper list:
-
type_error(list, Directives)
-
- -

Examples

- -
| ?- create_protocol(foo, [extends(bar)], [public(foo/1)]).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/current_category1.html b/Logtalk/manuals/refman/builtins/current_category1.html deleted file mode 100644 index 5e246dd28..000000000 --- a/Logtalk/manuals/refman/builtins/current_category1.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - Logtalk built-in predicate: current_category/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: current_category/1
-
-
- - -

current_category/1

- -

Description

- -
current_category(Category)
-

-Enumerates, by backtracking, all currently defined categories. All categories are found, either static, dynamic, or built-in. -

- -

Template and modes

- -
current_category(?category_identifier)
- -

Errors

- -
-
Category is neither a variable nor a valid category identifier:
-
type_error(category_identifier, Category)
-
- -

Examples

- -
| ?- current_category(monitoring).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/current_event5.html b/Logtalk/manuals/refman/builtins/current_event5.html deleted file mode 100644 index 6dddcb81c..000000000 --- a/Logtalk/manuals/refman/builtins/current_event5.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - Logtalk built-in predicate: current_event/5 - - - - - - -
Logtalk reference manual
-
Built-in predicate: current_event/5
-
-
- - -

current_event/5

- -

Description

- -
current_event(Event, Object, Message, Sender, Monitor)
-

-Enumerates, by backtracking, all defined events. The two types of events are represented by the atoms before and after. -

- -

Template and modes

- -
current_event(?event, ?object_identifier, ?callable, ?object_identifier, ?object_identifier)
- -

Errors

- -
-
Event is neither a variable nor a valid event identifier:
-
type_error(event, Event)
-
Object is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Object)
-
Message is neither a variable nor a callable term:
-
type_error(callable, Message)
-
Sender is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Sender)
-
Monitor is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Monitor)
-
- -

Examples

- -
| ?- current_event(Event, Object, Message, Sender, debugger).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/current_logtalk_flag2.html b/Logtalk/manuals/refman/builtins/current_logtalk_flag2.html deleted file mode 100644 index 60935e39e..000000000 --- a/Logtalk/manuals/refman/builtins/current_logtalk_flag2.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - Logtalk built-in predicate: current_logtalk_flag/2 - - - - - - -
Logtalk reference manual
-
Built-in predicate: current_logtalk_flag/2
-
-
- - -

current_logtalk_flag/2

- -

Description

- -
current_logtalk_flag(Flag, Value)
-

-Enumerates, by backtracking, the current Logtalk flag values. -

- -

Template and modes

- -
current_logtalk_flag(?atom, ?atom)
- -

Errors

- -
-
Flag is neither a variable nor an atom:
-
type_error(atom, Flag)
-
Flag is not a valid flag:
-
domain_error(valid_flag, Value)
-
- -

Examples

- -
| ?- current_logtalk_flag(xml, Value).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/current_object1.html b/Logtalk/manuals/refman/builtins/current_object1.html deleted file mode 100644 index 6546e1657..000000000 --- a/Logtalk/manuals/refman/builtins/current_object1.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - Logtalk built-in predicate: current_object/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: current_object/1
-
-
- - -

current_object/1

- -

Description

- -
current_object(Object)
-

-Enumerates, by backtracking, all currently defined objects. All objects are found, either static, dynamic or built-in. -

- -

Template and modes

- -
current_object(?object_identifier)
- -

Errors

- -
-
Object is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Object)
-
- -

Examples

- -
| ?- current_object(list).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/current_protocol1.html b/Logtalk/manuals/refman/builtins/current_protocol1.html deleted file mode 100644 index 5f6fbb877..000000000 --- a/Logtalk/manuals/refman/builtins/current_protocol1.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - Logtalk built-in predicate: current_protocol/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: current_protocol/1
-
-
- - -

current_protocol/1

- -

Description

- -
current_protocol(Protocol)
-

-Enumerates, by backtracking, all currently defined protocols. All protocols are found, either static, dynamic, or built-in. -

- -

Template and modes

- -
current_protocol(?protocol_identifier)
- -

Errors

- -
-
Protocol is neither a variable nor a valid protocol identifier:
-
type_error(protocol_identifier, Protocol)
-
- -

Examples

- -
| ?- current_protocol(listp).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/define_events5.html b/Logtalk/manuals/refman/builtins/define_events5.html deleted file mode 100644 index 555c3eb90..000000000 --- a/Logtalk/manuals/refman/builtins/define_events5.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - Logtalk built-in predicate: define_events/5 - - - - - - -
Logtalk reference manual
-
Built-in predicate: define_events/5
-
-
- - -

define_events/5

- -

Description

- -
define_events(Event, Object, Message, Sender, Monitor)
-

-Defines a new set of events. The two types of events are represented by the atoms before and after. -

- -

Template and modes

- -
define_events(@event, @object_identifier, @callable, @object_identifier, +object_identifier)
- -

Errors

- -
-
Event is neither a variable nor a valid event identifier:
-
type_error(event, Event)
-
Object is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Object)
-
Message is neither a variable nor a callable term:
-
type_error(callable, Message)
-
Sender is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Sender)
-
Monitor is a variable:
-
instantiation_error
-
Monitor is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Monitor)
-
- -

Examples

- -
| ?- define_events(_, list, member(_, _), _ , debugger).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/extends_object2_3.html b/Logtalk/manuals/refman/builtins/extends_object2_3.html deleted file mode 100644 index 613e6f3af..000000000 --- a/Logtalk/manuals/refman/builtins/extends_object2_3.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - Logtalk built-in predicate: extends_object/2-3 - - - - - - -
Logtalk reference manual
-
Built-in predicate: extends_object/2-3
-
-
- - -

extends_object/2-3

- -

Description

- -
extends_object(Prototype, Parent)
-extends_object(Prototype, Parent, Scope)
-

-Enumerates, by backtracking, all pairs of objects such that the first one extends the second. The relation scope is represented by the atoms public, protected, and private. -

- -

Template and modes

- -
extends_object(?object_identifier, ?object_identifier)
-extends_object(?object_identifier, ?object_identifier, ?scope)
- -

Errors

- -
-
Prototype is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Prototype)
-
Parent is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Parent)
-
Scope is neither a variable nor a valid entity scope:
-
type_error(scope, Scope)
-
- -

Examples

- -
| ?- extends_object(Object, state_space).
-
-| ?- extends_object(Object, list, public).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/extends_protocol2_3.html b/Logtalk/manuals/refman/builtins/extends_protocol2_3.html deleted file mode 100644 index 6e77fdbd1..000000000 --- a/Logtalk/manuals/refman/builtins/extends_protocol2_3.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - Logtalk built-in predicate: extends_protocol/2-3 - - - - - - -
Logtalk reference manual
-
Built-in predicate: extends_protocol/2-3
-
-
- - -

extends_protocol/2-3

- -

Description

- -
extends_protocol(Protocol1, Protocol2)
-extends_protocol(Protocol1, Protocol2, Scope)
-

-Enumerates, by backtracking, all pairs of protocols such that the first one extends the second. The relation scope is represented by the atoms public, protected, and private. -

- -

Template and modes

- -
extends_protocol(?protocol_identifier, ?protocol_identifier)
-extends_protocol(?protocol_identifier, ?protocol_identifier, ?scope)
- -

Errors

- -
-
Protocol1 is neither a variable nor a valid protocol identifier:
-
type_error(protocol_identifier, Protocol1)
-
Protocol2 is neither a variable nor a valid protocol identifier:
-
type_error(protocol_identifier, Protocol2)
-
Scope is neither a variable nor a valid entity scope:
-
type_error(scope, Scope)
-
- -

Examples

- -
| ?- extends_protocol(listp, Protocol).
-
-| ?- extends_protocol(Protocol, termp, private).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/forall2.html b/Logtalk/manuals/refman/builtins/forall2.html deleted file mode 100644 index 2b8a65408..000000000 --- a/Logtalk/manuals/refman/builtins/forall2.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - Logtalk built-in predicate: forall/2 - - - - - - -
Logtalk reference manual
-
Built-in predicate: forall/2
-
-
- - -

forall/2

- -

Description

- -
forall(Generator, Test)
-

-This predicate is true if, for all solutions of Generator, Test is true (some Prolog compilers already define this or a similar predicate). -

- -

Template and modes

- -
forall(+callable, +callable)
- -

Errors

- -
-
Generator is not a callable term:
-
type_error(callable, Generator)
-
Test is not a callable term:
-
type_error(callable, Test)
-
- -

Examples

- -
| ?- forall(member(X, [1, 2, 3]), write(X)).
-
-123
-yes
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/implements_protocol2_3.html b/Logtalk/manuals/refman/builtins/implements_protocol2_3.html deleted file mode 100644 index 7b6d16acd..000000000 --- a/Logtalk/manuals/refman/builtins/implements_protocol2_3.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - Logtalk built-in predicate: implements_protocol/2-3 - - - - - - -
Logtalk reference manual
-
Built-in predicate: implements_protocol/2-3
-
-
- - -

implements_protocol/2-3

- -

Description

- -
implements_protocol(Object, Protocol)
-implements_protocol(Category, Protocol)
-
-implements_protocol(Object, Protocol, Scope)
-implements_protocol(Category, Protocol, Scope)
-

-Enumerates, by backtracking, all pairs of entities such that an object or a category implements a protocol. The relation scope is represented by the atoms public, protected, and private. -

- -

Template and modes

- -
implements_protocol(?object_identifier, ?protocol_identifier)
-implements_protocol(?category_identifier, ?protocol_identifier)
-
-implements_protocol(?object_identifier, ?protocol_identifier, ?scope)
-implements_protocol(?category_identifier, ?protocol_identifier, ?scope)
- -

Errors

- -
-
Object is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Object)
-
Category is neither a variable nor a valid category identifier:
-
type_error(category_identifier, Category)
-
Protocol is neither a variable nor a valid protocol identifier:
-
type_error(protocol_identifier, Protocol)
-
Scope is neither a variable nor a valid entity scope:
-
type_error(scope, Scope)
-
- -

Examples

- -
| ?- implements_protocol(List, listp).
-
-| ?- implements_protocol(List, listp, public).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/imports_category2_3.html b/Logtalk/manuals/refman/builtins/imports_category2_3.html deleted file mode 100644 index b969f890a..000000000 --- a/Logtalk/manuals/refman/builtins/imports_category2_3.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - Logtalk built-in predicate: imports_category/2-3 - - - - - - -
Logtalk reference manual
-
Built-in predicate: imports_category/2-3
-
-
- - -

imports_category/2-3

- -

Description

- -
imports_category(Object, ImportedCategory)
-imports_category(Category, ImportedCategory)
-
-imports_category(Object, ImportedCategory, Scope)
-imports_category(Category, ImportedCategory, Scope)
-

-Enumerates, by backtracking, importation relations between objects and categories. The relation scope is represented by the atoms public, protected, and private. -

- -

Template and modes

- -
imports_category(?object_identifier, ?category_identifier)
-imports_category(?category_identifier, ?category_identifier)
-
-imports_category(?object_identifier, ?category_identifier, ?scope)
-imports_category(?category_identifier, ?category_identifier, ?scope)
- -

Errors

- -
-
Object is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Object)
-
Category is neither a variable nor a valid category identifier:
-
type_error(category_identifier, Category)
-
ImportedCategory is neither a variable nor a valid category identifier:
-
type_error(category_identifier, ImportedCategory)
-
Scope is neither a variable nor a valid entity scope:
-
type_error(scope, Scope)
-
- -

Examples

- -
| ?- imports_category(debugger, monitoring).
-
-| ?- imports_category(Object, monitoring, protected).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/instantiates_class2_3.html b/Logtalk/manuals/refman/builtins/instantiates_class2_3.html deleted file mode 100644 index 36309f93a..000000000 --- a/Logtalk/manuals/refman/builtins/instantiates_class2_3.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - Logtalk built-in predicate: instantiates_class/2-3 - - - - - - -
Logtalk reference manual
-
Built-in predicate: instantiates_class/2-3
-
-
- - -

instantiates_class/2-3

- -

Description

- -
instantiates_class(Instance, Class)
-instantiates_class(Instance, Class, Scope)
-

-Enumerates, by backtracking, all pairs of objects such that the first one instantiates the second. The relation scope is represented by the atoms public, protected, and private. -

- -

Template and modes

- -
instantiates_class(?object_identifier, ?object_identifier)
-instantiates_class(?object_identifier, ?object_identifier, ?scope)
- -

Errors

- -
-
Instance is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Instance)
-
Class is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Class)
-
Scope is neither a variable nor a valid entity scope:
-
type_error(scope, Scope)
-
- -

Examples

- -
| ?- instantiates_class(water_jug, state_space).
-
-| ?- instantiates_class(Space, state_space, public).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/logtalk_compile1.html b/Logtalk/manuals/refman/builtins/logtalk_compile1.html deleted file mode 100644 index 22d878e55..000000000 --- a/Logtalk/manuals/refman/builtins/logtalk_compile1.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - Logtalk built-in predicate: logtalk_compile/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: logtalk_compile/1
-
-
- - -

logtalk_compile/1

- -

Description

- -
logtalk_compile(File)
-logtalk_compile(Files)
-

-Compiles to disk a source file or a list of source files using the default compiler flags specified in the Logtalk configuration file. The Logtalk source file name extension (by default, .lgt) must be omitted. Note that the argument is a source file name or a list of source file names, not file paths. In other words, the files must exist in the current working directory, unless library notation is used. -

-

-Note that only the errors related to problems in the predicate argument are listed below. Other exceptions may be thrown by the compiler if any of the compiled entities contain syntax errors. -

- -

Template and modes

- -
logtalk_compile(@source_file_names)
- -

Errors

- -
-
File is a variable:
-
instantiation_error
-
Files is a variable or a list with an element which is a variable:
-
instantiation_error
-
File, or an element File of the Files list, is neither a variable nor a source file name:
-
type_error(source_file_name, File)
-
File, or an element File of the Files list, is a compound term but not a library name:
-
type_error(library_name, File)
-
File or an element File of the Files list does not exist in the current working directory or in the specified library directory:
-
existence_error(file, File)
-
Source file library does not exist:
-
existence_error(library, Library)
-
- -

Examples

- -
| ?- logtalk_compile(set).
-
-| ?- logtalk_load(types(tree)).
-
-| ?- logtalk_compile([listp, list]).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/logtalk_compile2.html b/Logtalk/manuals/refman/builtins/logtalk_compile2.html deleted file mode 100644 index 67e77f72e..000000000 --- a/Logtalk/manuals/refman/builtins/logtalk_compile2.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - Logtalk built-in predicate: logtalk_compile/2 - - - - - - -
Logtalk reference manual
-
Built-in predicate: logtalk_compile/2
-
-
- - -

logtalk_compile/2

- -

Description

- -
logtalk_compile(File, Flags)
-logtalk_compile(Files, Flags)
-

-Compiles to disk a source file or a list of source files using a list of flag values. The Logtalk file name extension (by default, .lgt) must be omitted. Note that the first argument is a source file name or a list of source file names, not file paths. In other words, the files must exist in the current working directory, unless library notation is used. -

-

-For a description of the available compiler flags, please consult the User Manual. -

-

-Note that only the errors related to problems in the predicate arguments are listed below. Other exceptions may be thrown by the compiler if any of the compiled entities contain syntax errors. -

- -

Template and modes

- -
logtalk_compile(@source_file_names, @list)
- -

Errors

- -
-
File is a variable:
-
instantiation_error
-
Files is a variable or a list with an element which is a variable:
-
instantiation_error
-
File, or an element File of the Files list, is neither a variable nor an entity file name nor a library entity file name:
-
type_error(source_file_name, File)
-
File, or an element File of the Files list, is a compound term but not a library entity file name:
-
type_error(library_source_file_name, Entity)
-
File or an element File of the Files list does not exist in the current working directory or in the specified library directory:
-
existence_error(file, File)
-
Entity library does not exist:
-
existence_error(library, Library)
-
Flags is a variable:
-
instantiation_error
-
Flags is neither a variable nor a proper list:
-
type_error(list, Flags)
-
An element Flag of the Flags list is not valid:
-
type_error(compiler_flag, Flag)
-
- -

Examples

- -
| ?- logtalk_compile(list, []).
-
-| ?- logtalk_compile(types(tree), [xmlspec(xsd)]).
-
-| ?- logtalk_compile([listp, list], [xml(off), plredf(warning)]).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/logtalk_library_path2.html b/Logtalk/manuals/refman/builtins/logtalk_library_path2.html deleted file mode 100644 index 974419406..000000000 --- a/Logtalk/manuals/refman/builtins/logtalk_library_path2.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - Logtalk built-in predicate: logtalk_library_path/2 - - - - - - -
Logtalk reference manual
-
Built-in predicate: logtalk_library_path/2
-
-
- - -

logtalk_library_path/2

- -

Description

- -
logtalk_library_path(Library, Path)
-

-Dynamic, user-defined predicate, allowing the declaration of aliases to library paths. Library aliases may also be used on the second argument (using the notation alias(path)). Paths must always end with the path directory separator character ("/"). -

- -

Template and modes

- -
logtalk_library_path(?atom, -atom)
-logtalk_library_path(?atom, -compound)
- -

Errors

- -
-
(none)
-
- -

Examples

- -
| ?- logtalk_library_path(viewpoints, Path).
-
-Path = examples('viewpoints/')
-yes
-
-| ?- logtalk_library_path(Library, Path).
-
-Library = lgtuser
-Path = '$LOGTALKUSER/' ;
-
-Library = library
-Path = lgtuser('library/') ;
-
-Library = examples
-Path = lgtuser('examples/') ;
-
-Library = viewpoints
-Path = examples('viewpoints/')
-yes
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/logtalk_load1.html b/Logtalk/manuals/refman/builtins/logtalk_load1.html deleted file mode 100644 index 7f962aa38..000000000 --- a/Logtalk/manuals/refman/builtins/logtalk_load1.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - Logtalk built-in predicate: logtalk_load/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: logtalk_load/1
-
-
- - -

logtalk_load/1

- -

Description

- -
logtalk_load(File)
-logtalk_load(Files)
-

-Compiles to disk and then loads to memory a source file or a list of source files using the default compiler flags specified in the Logtalk configuration file. The Logtalk file name extension (by default, .lgt) must be omitted. Note that the argument is a source file name or a list of source file names, not file paths. In other words, the files must exist in the current working directory, unless library notation is used. -

-

-Note that only the errors related to problems in the predicate argument are listed below. Other exceptions may be thrown by the compiler if any of the loaded entities contain syntax errors. -

-

-Depending on the back-end Prolog compiler, the notation {File} may be used in alternative (check the config files for its availability). -

- -

Template and modes

- -
logtalk_load(@source_file_names)
- -

Errors

- -
-
File is a variable:
-
instantiation_error
-
Files is a variable or a list with an element which is a variable:
-
instantiation_error
-
File, or an element File of the Files list, is neither a variable nor a source file name nor a library entity file name:
-
type_error(source_file_name, File)
-
File, or an element File of the Files list, is a compound term but not a library source file name:
-
type_error(library_source_file_name, File)
-
File or an element File of the Files list does not exist in the current working directory or in the specified library directory:
-
existence_error(file, File)
-
Entity library does not exist:
-
existence_error(library, Library)
-
- -

Examples

- -
| ?- logtalk_load(set).
-
-| ?- logtalk_load(types(tree)).
-
-| ?- logtalk_load([listp, list]).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/logtalk_load2.html b/Logtalk/manuals/refman/builtins/logtalk_load2.html deleted file mode 100644 index ea606e84c..000000000 --- a/Logtalk/manuals/refman/builtins/logtalk_load2.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - Logtalk built-in predicate: logtalk_load/2 - - - - - - -
Logtalk reference manual
-
Built-in predicate: logtalk_load/2
-
-
- - -

logtalk_load/2

- -

Description

- -
logtalk_load(File, Flags)
-logtalk_load(Files, Flags)
-

-Compiles to disk and then loads to memory a source file or a list of source files using a list of flag values. The Logtalk file name extension (by default, .lgt) must be omitted. Note that the first argument is a source file name or a list of source file names, not file paths. In other words, the files must exist in the current working directory, unless library notation is used. -

-

-For a description of the available compiler flags, please consult the User Manual. -

-

-Note that only the errors related to problems in the predicate arguments are listed below. Other exceptions may be thrown by the compiler if any of the loaded entities contain syntax errors. -

- -

Template and modes

- -
logtalk_load(@source_file_names, @list)
- -

Errors

- -
-
File is a variable:
-
instantiation_error
-
Files is a variable or a list with an element which is a variable:
-
instantiation_error
-
File, or an element File of the Files list, is neither a variable nor a source file name:
-
type_error(source_file_name, File)
-
File, or an element File of the Files list, is a compound term but not a library source file name:
-
type_error(library_source_file_name, Entity)
-
File or an element File of the Files list does not exist in the current working directory or in the specified library directory:
-
existence_error(file, File)
-
Entity library does not exist:
-
existence_error(library, Library)
-
Flags is a variable:
-
instantiation_error
-
Flags is neither a variable nor a proper list:
-
type_error(list, Flags)
-
An element Flag of the Flags list is not valid:
-
type_error(compiler_flag, Flag)
-
- -

Examples

- -
| ?- logtalk_load(list, []).
-
-| ?- logtalk_load(types(tree), [xmlspec(xsd)]).
-
-| ?- logtalk_load([listp, list], [xml(off), plredf(warning)]).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/logtalk_version3.html b/Logtalk/manuals/refman/builtins/logtalk_version3.html deleted file mode 100644 index c9de80460..000000000 --- a/Logtalk/manuals/refman/builtins/logtalk_version3.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - Logtalk built-in predicate: logtalk_version/3 - - - - - - -
Logtalk reference manual
-
Built-in predicate: logtalk_version/3
-
-
- - -

logtalk_version/3

- -

Description

- -
logtalk_version(Major, Minor, Patch)
-

-Returns the Logtalk compiler and runtime version. -

- -

Template and modes

- -
logtalk_version(?integer, ?integer, ?integer)
- -

Errors

- -
-
Major is neither a variable nor an integer:
-
type_error(integer, Major)
-
Minor is neither a variable nor an integer:
-
type_error(integer, Minor)
-
Patch is neither a variable nor an integer:
-
type_error(integer, Patch)
-
- -

Examples

- -
| ?- logtalk_version(Major, Minor, Patch).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/object_property2.html b/Logtalk/manuals/refman/builtins/object_property2.html deleted file mode 100644 index d8ee56233..000000000 --- a/Logtalk/manuals/refman/builtins/object_property2.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - Logtalk built-in predicate: object_property/2 - - - - - - -
Logtalk reference manual
-
Built-in predicate: object_property/2
-
-
- - -

object_property/2

- -

Description

- -
object_property(Object, Property)
-

-Enumerates, by backtracking, the properties associated with the defined objects. -

- -

Template and modes

- -
object_property(?object_identifier, ?object_property)
- -

Errors

- -
-
Object is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Object)
-
Property is neither a variable nor a valid object property:
-
domain_error(object_property, Property)
-
- -

Examples

- -
| ?- object_property(list, Property).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/protocol_property2.html b/Logtalk/manuals/refman/builtins/protocol_property2.html deleted file mode 100644 index 6f544792c..000000000 --- a/Logtalk/manuals/refman/builtins/protocol_property2.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - Logtalk built-in predicate: protocol_property/2 - - - - - - -
Logtalk reference manual
-
Built-in predicate: protocol_property/2
-
-
- - -

protocol_property/2

- -

Description

- -
protocol_property(Protocol, Property)
-

- Enumerates, by backtracking, the properties associated with the currently defined protocols. -

- -

Template and modes

- -
protocol_property(?protocol_identifier, ?protocol_property)
- -

Errors

- -
-
Protocol is neither a variable nor a valid protocol identifier:
-
type_error(protocol_identifier, Protocol)
-
Property is neither a variable nor a valid protocol property:
-
domain_error(protocol_property, Property)
-
- -

Examples

- -
| ?- protocol_property(listp, Property).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/retractall1.html b/Logtalk/manuals/refman/builtins/retractall1.html deleted file mode 100644 index 7f7a58076..000000000 --- a/Logtalk/manuals/refman/builtins/retractall1.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - Logtalk built-in predicate: retractall/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: retractall/1
-
-
- - -

retractall/1

- -

Description

- -
retractall(Head)
-

-Logtalk adds this built-in predicate, with the usual definition, to a Prolog compiler if it is not already defined. -

- -

Template and modes

- -
retractall(+callable)
- -

Errors

- -
-
Head is not a callable term:
-
type_error(callable, Head)
-
- -

Examples

- -
| ?- retractall(foo(_)).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/set_logtalk_flag2.html b/Logtalk/manuals/refman/builtins/set_logtalk_flag2.html deleted file mode 100644 index cad04a34e..000000000 --- a/Logtalk/manuals/refman/builtins/set_logtalk_flag2.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - Logtalk built-in predicate: set_logtalk_flag/2 - - - - - - -
Logtalk reference manual
-
Built-in predicate: set_logtalk_flag/2
-
-
- - -

set_logtalk_flag/2

- -

Description

- -
set_logtalk_flag(Flag, Value)
-

- Sets Logtalk flag values. -

- -

Template and modes

- -
set_logtalk_flag(+atom, +atom)
- -

Errors

- -
-
Flag is a variable:
-
instantiation_error
-
Value is a variable:
-
instantiation_error
-
Flag is not an atom:
-
type_error(atom, Flag)
-
Flag is neither a variable nor a valid flag:
-
domain_error(valid_flag, Flag)
-
Value is not a valid value for flag Flag:
-
domain_error(valid_flag_value, Value)
-
Flag is a read-only flag:
-
permission_error(modify, read_only_flag, Flag)
-
- -

Examples

- -
| ?- set_logtalk_flag(xml, on).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/specializes_class2_3.html b/Logtalk/manuals/refman/builtins/specializes_class2_3.html deleted file mode 100644 index 670bfddd0..000000000 --- a/Logtalk/manuals/refman/builtins/specializes_class2_3.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - Logtalk built-in predicate: specializes_class/2-3 - - - - - - -
Logtalk reference manual
-
Built-in predicate: specializes_class/2-3
-
-
- - -

specializes_class/2-3

- -

Description

- -
specializes_class(Class, Superclass)
-specializes_class(Class, Superclass, Scope)
-

-Enumerates, by backtracking, all pairs of objects such that the first one specializes the second. The relation scope is represented by the atoms public, protected, and private. -

- -

Template and modes

- -
specializes_class(?object_identifier, ?object_identifier)
-specializes_class(?object_identifier, ?object_identifier, ?scope)
- -

Errors

- -
-
Class is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Class)
-
Superclass is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Superclass)
-
Scope is neither a variable nor a valid entity scope:
-
type_error(scope, Scope)
-
- -

Examples

- -
| ?- specializes_class(Subclass, state_space).
-
-| ?- specializes_class(Subclass, state_space, public).
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/threaded1.html b/Logtalk/manuals/refman/builtins/threaded1.html deleted file mode 100644 index cd32750fa..000000000 --- a/Logtalk/manuals/refman/builtins/threaded1.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - Logtalk built-in predicate: threaded/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: threaded/1
-
-
- - -

threaded/1

- -

Description

- -
threaded(Goals)
-
-threaded(Conjunction)
-threaded(Disjunction)
-

-Proves each goal in a conjunction (disjunction) of goals in its own thread. The argument can also be a conjunction (disjunction) of messages, either to self or to an explicit object. This predicate is deterministic and opaque to cuts. -

-

-When the argument is a conjunction of goals, a call to this predicate blocks until either all goals succeed, one of the goals fail, or one of the goals generate an exception; the failure of one of the goals or an exception on the execution of one of the goals results in the termination of the remaining threads. The predicate call is true iff all goals are true. -

-

-When the argument is a disjunction of goals, a call to this predicate blocks until either one of the goals succeeds, all the goals fail, or one of the goals generate an exception; the success of one of the goals or an exception on the execution of one of the goals results in the termination of the remaining threads. The predicate call is true iff one of the goals is true. -

-

-When the predicate argument is neither a conjunction not a disjunction of goals, no threads are used. In this case, the predicate call is equivalent to a once/1 predicate call. -

- -

Template and modes

- -
threaded(+callable)
- -

Errors

- -
-
Goals is a variable:
-
instantiation_error
-
A goal in Goals is a variable:
-
instantiation_error
-
Goals is neither a variable nor a callable term:
-
type_error(callable, Goals)
-
A goal Goal in Goals is neither a variable nor a callable term:
-
type_error(callable, Goal)
-
- -

Examples

- -
-
Prove a conjunction of goals, each one in its own thread:
-
threaded((Goal, Goals))
-
Prove a conjunction of messages to self, each one in its own thread:
-
threaded(::(Message, Messages))
-
Prove a conjunction of messages to an object, each one in its own thread:
-
threaded(Object::(Message, Messages))
-
Prove a conjunction of objects receiving the same message, each one in its own thread:
-
threaded((Object, Objects)::Message)
-
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/threaded_call1.html b/Logtalk/manuals/refman/builtins/threaded_call1.html deleted file mode 100644 index 8994e73c0..000000000 --- a/Logtalk/manuals/refman/builtins/threaded_call1.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - Logtalk built-in predicate: threaded_call/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: threaded_call/1
-
-
- - -

threaded_call/1

- -

Description

- -
threaded_call(Goal)
-

-Proves Goal asynchronously using a new thread. The argument can be a message sending goal. Calls to this predicate always succeeds and return immediately. The results (success, failure, or exception) are sent back to the message queue of the object containing the call (this); they can be retrieved by calling the threaded_exit/1 predicate. -

- -

Template and modes

- -
threaded_call(@callable)
- -

Errors

- -
-
Goal is a variable:
-
instantiation_error
-
Goal is neither a variable nor a callable term:
-
type_error(callable, Goal)
-
- -

Examples

- -
-
Prove Goal asynchronously in a new thread:
-
threaded_call(Goal)
-
Prove ::Message asynchronously in a new thread:
-
threaded_call(::Message)
-
Prove Object::Message asynchronously in a new thread:
-
threaded_call(Object::Message)
-
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/threaded_call1_2.html b/Logtalk/manuals/refman/builtins/threaded_call1_2.html deleted file mode 100644 index a8cf11b28..000000000 --- a/Logtalk/manuals/refman/builtins/threaded_call1_2.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - Logtalk built-in predicate: threaded_call/1-2 - - - - - - -
Logtalk reference manual
-
Built-in predicate: threaded_call/1-2
-
-
- - -

threaded_call/1-2

- -

Description

- -
threaded_call(Goal)
-threaded_call(Goal, Tag)
-

-Proves Goal asynchronously using a new thread. The argument can be a message sending goal. Calls to this predicate always succeeds and return immediately. The results (success, failure, or exception) are sent back to the message queue of the object containing the call (this); they can be retrieved by calling the threaded_exit/1 predicate. -

-

-The variant threaded_call/2 returns a threaded call identifier tag that can be used with the threaded_exit/2 predicate. Tags shall be considered as an opaque term; users shall not rely on its type. -

- -

Template and modes

- -
threaded_call(@callable)
-threaded_call(@callable, -nonvar)
- -

Errors

- -
-
Goal is a variable:
-
instantiation_error
-
Goal is neither a variable nor a callable term:
-
type_error(callable, Goal)
-
Tag is not a variable:
-
type_error(variable, Goal)
-
- -

Examples

- -
-
Prove Goal asynchronously in a new thread:
-
threaded_call(Goal)
-
Prove ::Message asynchronously in a new thread:
-
threaded_call(::Message)
-
Prove Object::Message asynchronously in a new thread:
-
threaded_call(Object::Message)
-
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/threaded_call2.html b/Logtalk/manuals/refman/builtins/threaded_call2.html deleted file mode 100644 index 973c7761c..000000000 --- a/Logtalk/manuals/refman/builtins/threaded_call2.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - Logtalk built-in predicate: threaded_call/2 - - - - - - -
Logtalk reference manual
-
Built-in predicate: threaded_call/2
-
-
- - -

threaded_call/2

- - -

Description

- -
threaded_call(Goal, Options)
-threaded_call((Goal1, Goal2, ...), Options)
-threaded_call((Goal1; Goal2; ...), Options)
-

-Prove Goal using a new thread. By default, the proof is done asynchronously. The argument can be a message sending. The result (success, failure, or exception) is sent back to the thread of the object containing the call (this). The option noreply may be used when no reply with the proof results is necessary. The option atomic may be used if the goal has side-effects such as dynamic database updates or input-output operations; this option is only safe if the side-effects are confined to the object where the goal is proved (or to the object receiving the asynchronous message). -

-

-When the argument is a conjunction of goals, the call is equivalent the conjunction of calls of the individual goals. However, when the argument is a disjunction of goals, the call is equivalent to the competing calls of the individual goals: when one of the goals complete, the other ones are aborted (i.e. their threads are terminated). In this case, the corresponding threaded_exit/1-2 goal must match all the goals in the disjunction. This is useful when you have a set of different methods to solve a problem without knowing a priori which one will lead to the fastest result. -

- -

Template and modes

- -
threaded_call(+callable, +list)
- -

Examples

- -
-
Prove Goal asynchronously in a new thread:
-
threaded_call(Goal, Options)
-
Send an asynchronous message to self:
-
threaded_call(::Message, Options)
-
Send an asynchronous message to an object:
-
threaded_call(Object::Message, Options)
-
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/threaded_exit1.html b/Logtalk/manuals/refman/builtins/threaded_exit1.html deleted file mode 100644 index 02c8b68cb..000000000 --- a/Logtalk/manuals/refman/builtins/threaded_exit1.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - Logtalk built-in predicate: threaded_exit/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: threaded_exit/1
-
-
- - -

threaded_exit/1

- -

Description

- -
threaded_exit(Goal)
-

-Retrieve the result of proving Goal in a new thread. This predicate blocks execution until the reply is sent to the this message queue by the thread executing the goal. When there is no thread proving the goal, the predicate generates an exception. This predicate is non-deterministic, providing access to any alternative solutions of its argument. -

- -

Template and modes

- -
threaded_exit(+callable)
- -

Errors

- -
-
Goal is a variable:
-
instantiation_error
-
Goal is neither a variable nor a callable term:
-
type_error(callable, Goal)
-
no thread is running for proving Goal:
-
existence_error(goal_thread, Goal)
-
- -

Examples

- -
-
To retrieve an asynchronous goal proof result:
-
threaded_exit(Goal)
-
To retrieve an asynchronous message to self result:
-
threaded_exit(::Goal)
-
To retrieve an asynchronous message result:
-
threaded_exit(Object::Goal)
-
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/threaded_exit1_2.html b/Logtalk/manuals/refman/builtins/threaded_exit1_2.html deleted file mode 100644 index 192a77c5c..000000000 --- a/Logtalk/manuals/refman/builtins/threaded_exit1_2.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - Logtalk built-in predicate: threaded_exit/1-2 - - - - - - -
Logtalk reference manual
-
Built-in predicate: threaded_exit/1-2
-
-
- - -

threaded_exit/1-2

- -

Description

- -
threaded_exit(Goal)
-threaded_exit(Goal, Tag)
-

-Retrieves the result of proving Goal in a new thread. This predicate blocks execution until the reply is sent to the this message queue by the thread executing the goal. When there is no thread proving the goal, the predicate generates an exception. This predicate is non-deterministic, providing access to any alternative solutions of its argument. -

-

-The argument of this predicate should be a variant of the argument of the corresponding threaded_call/1 call. When the predicate argument is subsumed by the threaded_call/1 call argument, the threaded_exit/1 call will succeed iff its argument is a solution of the (more general) goal. -

-

-The variant threaded_exit/2 accepts a threaded call identifier tag generated by the calls to the threaded_call/2 and threaded_once/2 predicates. Tags shall be considered as an opaque term; users shall not rely on its type. -

- -

Template and modes

- -
threaded_exit(+callable)
-threaded_exit(+callable, +nonvar)
- -

Errors

- -
-
Goal is a variable:
-
instantiation_error
-
Goal is neither a variable nor a callable term:
-
type_error(callable, Goal)
-
no thread is running for proving Goal:
-
existence_error(goal_thread, Goal)
-
Tag is a variable:
-
instantiation_error
-
- -

Examples

- -
-
To retrieve an asynchronous goal proof result:
-
threaded_exit(Goal)
-
To retrieve an asynchronous message to self result:
-
threaded_exit(::Goal)
-
To retrieve an asynchronous message result:
-
threaded_exit(Object::Goal)
-
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/threaded_exit2.html b/Logtalk/manuals/refman/builtins/threaded_exit2.html deleted file mode 100644 index 3a57bfc45..000000000 --- a/Logtalk/manuals/refman/builtins/threaded_exit2.html +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - Logtalk built-in predicate: threaded_exit/2 - - - - - - -
Logtalk reference manual
-
Built-in predicate: threaded_exit/2
-
-
- - -

threaded_exit/2

- - -

Description

- -
threaded_exit(Goal, Options)
-

-Retrieve the result of proving Goal in a new thread. By default, this call blocks execution until the reply is sent to the this thread by the thread executing the goal. This predicate is non-deterministic, providing access to the alternative solutions of its first argument. The option peek may be used to check if the reply is already available on the this thread. The option discard may be used to discard all matching replies. -

- -

Template and modes

- -
threaded_exit(+callable, +list)
- -

Examples

- -
-
To retrieve the goal proof result:
-
threaded_exit(Goal, List)
-
To retrieve the message result:
-
threaded_exit(::Goal, List)
-
To retrieve the message result:
-
threaded_exit(Object::Goal, List)
-
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/threaded_ignore1.html b/Logtalk/manuals/refman/builtins/threaded_ignore1.html deleted file mode 100644 index 1a1461e30..000000000 --- a/Logtalk/manuals/refman/builtins/threaded_ignore1.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - Logtalk built-in predicate: threaded_ignore/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: threaded_ignore/1
-
-
- - -

threaded_ignore/1

- -

Description

- -
threaded_ignore(Goal)
-

-Proves Goal asynchronously using a new thread. Only the first goal solution is found. The argument can be a message sending goal. This call always succeeds, independently of the result (success, failure, or exception), which is simply discarded instead of being sent back to the message queue of the object containing the call (this). -

- -

Template and modes

- -
threaded_ignore(@callable)
- -

Errors

- -
-
Goal is a variable:
-
instantiation_error
-
Goal is neither a variable nor a callable term:
-
type_error(callable, Goal)
-
- -

Examples

- -
-
Prove Goal asynchronously in a new thread:
-
threaded_ignore(Goal)
-
Prove ::Message asynchronously in a new thread:
-
threaded_ignore(::Message)
-
Prove Object::Message asynchronously in a new thread:
-
threaded_ignore(Object::Message)
-
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/threaded_notify1.html b/Logtalk/manuals/refman/builtins/threaded_notify1.html deleted file mode 100644 index 2e969999c..000000000 --- a/Logtalk/manuals/refman/builtins/threaded_notify1.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - Logtalk built-in predicate: threaded_notify/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: threaded_notify/1
-
-
- - -

threaded_notify/1

- -

Description

- -
threaded_notify(Term)
-threaded_notify([Term| Terms])
-

-Sends Term as a notification to any thread suspended waiting for it in order to proceed. The call must be made within the same object (this) containing the calls to the threaded_wait/1 predicate waiting for the notification. The argument may also be a list of notifications, [Term| Terms]. In this case, all notifications in the list will be sent to any threads suspended waiting for them in order to proceed. -

- -

Template and modes

- -
threaded_notify(@term)
-threaded_notify(@list(term))
- -

Errors

- -
-

-(none) -

-
- -

Examples

- -
-
Send the notification data_available:
-
threaded_notify(data_available)
-
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/threaded_once1.html b/Logtalk/manuals/refman/builtins/threaded_once1.html deleted file mode 100644 index 1100240da..000000000 --- a/Logtalk/manuals/refman/builtins/threaded_once1.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - Logtalk built-in predicate: threaded_once/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: threaded_once/1
-
-
- - -

threaded_once/1

- -

Description

- -
threaded_once(Goal)
-

-Proves Goal asynchronously using a new thread. Only the first goal solution is found. The argument can be a message sending goal. This call always succeeds. The result (success, failure, or exception) is sent back to the message queue of the object containing the call (this). -

- -

Template and modes

- -
threaded_once(@callable)
- -

Errors

- -
-
Goal is a variable:
-
instantiation_error
-
Goal is neither a variable nor a callable term:
-
type_error(callable, Goal)
-
- -

Examples

- -
-
Prove Goal asynchronously in a new thread:
-
threaded_once(Goal)
-
Prove ::Message asynchronously in a new thread:
-
threaded_once(::Message)
-
Prove Object::Message asynchronously in a new thread:
-
threaded_once(Object::Message)
-
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/threaded_once1_2.html b/Logtalk/manuals/refman/builtins/threaded_once1_2.html deleted file mode 100644 index 19415e5e1..000000000 --- a/Logtalk/manuals/refman/builtins/threaded_once1_2.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - Logtalk built-in predicate: threaded_once/1-2 - - - - - - -
Logtalk reference manual
-
Built-in predicate: threaded_once/1-2
-
-
- - -

threaded_once/1-2

- -

Description

- -
threaded_once(Goal)
-threaded_once(Goal, Tag)
-

-Proves Goal asynchronously using a new thread. Only the first goal solution is found. The argument can be a message sending goal. This call always succeeds. The result (success, failure, or exception) is sent back to the message queue of the object containing the call (this). -

-

-The variant threaded_once/2 returns a threaded call identifier tag that can be used with the threaded_exit/2 predicate. Tags shall be considered as an opaque term; users shall not rely on its type. -

- -

Template and modes

- -
threaded_once(@callable)
-threaded_once(@callable, -nonvar)
- -

Errors

- -
-
Goal is a variable:
-
instantiation_error
-
Goal is neither a variable nor a callable term:
-
type_error(callable, Goal)
-
Tag is not a variable:
-
type_error(variable, Goal)
-
- -

Examples

- -
-
Prove Goal asynchronously in a new thread:
-
threaded_once(Goal)
-
Prove ::Message asynchronously in a new thread:
-
threaded_once(::Message)
-
Prove Object::Message asynchronously in a new thread:
-
threaded_once(Object::Message)
-
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/threaded_peek1.html b/Logtalk/manuals/refman/builtins/threaded_peek1.html deleted file mode 100644 index 8d98d3a71..000000000 --- a/Logtalk/manuals/refman/builtins/threaded_peek1.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - Logtalk built-in predicate: threaded_peek/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: threaded_peek/1
-
-
- - -

threaded_peek/1

- -

Description

- -
threaded_peek(Goal)
-

-Checks if the result of proving Goal in a new thread is already available. This call succeeds or fails without blocking execution waiting for a reply to be avaialble. -

- -

Template and modes

- -
threaded_peek(?callable)
- -

Errors

- -
-
Goal is a variable:
-
instantiation_error
-
Goal is neither a variable nor a callable term:
-
type_error(callable, Goal)
-
- -

Examples

- -
-
To check for an asynchronous goal proof result:
-
threaded_peek(Goal)
-
To check for an asynchronous message to self result:
-
threaded_peek(::Goal)
-
To check for an asynchronous message result:
-
threaded_peek(Object::Goal)
-
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/threaded_peek1_2.html b/Logtalk/manuals/refman/builtins/threaded_peek1_2.html deleted file mode 100644 index 986159278..000000000 --- a/Logtalk/manuals/refman/builtins/threaded_peek1_2.html +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - Logtalk built-in predicate: threaded_peek/1-2 - - - - - - -
Logtalk reference manual
-
Built-in predicate: threaded_peek/1-2
-
-
- - -

threaded_peek/1-2

- -

Description

- -
threaded_peek(Goal)
-threaded_peek(Goal, Tag)
-

-Checks if the result of proving Goal in a new thread is already available. This call succeeds or fails without blocking execution waiting for a reply to be available. -

-

-The argument of this predicate should be a variant of the argument of the corresponding threaded_call/1 call. When the predicate argument is subsumed by the threaded_call/1 call argument, the threaded_peek/1 call will succeed iff its argument unifies with an already available solution of the (more general) goal. -

-

-The variant threaded_peek/2 accepts a threaded call identifier tag generated by the calls to the threaded_call/2 and threaded_once/2 predicates. Tags shall be considered as an opaque term; users shall not rely on its type. -

- -

Template and modes

- -
threaded_peek(+callable)
-threaded_peek(+callable, +nonvar)
- -

Errors

- -
-
Goal is a variable:
-
instantiation_error
-
Goal is neither a variable nor a callable term:
-
type_error(callable, Goal)
-
Tag is a variable:
-
instantiation_error
-
- -

Examples

- -
-
To check for an asynchronous goal proof result:
-
threaded_peek(Goal)
-
To check for an asynchronous message to self result:
-
threaded_peek(::Goal)
-
To check for an asynchronous message result:
-
threaded_peek(Object::Goal)
-
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/threaded_race1.html b/Logtalk/manuals/refman/builtins/threaded_race1.html deleted file mode 100644 index 7ac296b65..000000000 --- a/Logtalk/manuals/refman/builtins/threaded_race1.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - Logtalk built-in predicate: threaded_race/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: threaded_race/1
-
-
- - -

threaded_race/1

- -

Description

- -
threaded_race((Goal; Goals))
-

-Allows a disjunction of goals to be interpreted as a set of competing goals, each one running on its own thread. This call always succeeds. When one of the goals succeeds, the other ones are aborted (i.e. their threads are terminated). The result (of the first goal to succeed) is sent back to the message queue of the object containing the call (this). The corresponding threaded_exit/1 goal must match all the goals in the disjunction. This is useful when you have a set of different methods to solve a problem without knowing a priori which one will lead to the fastest result. -

- -

Template and modes

- -
threaded_race(+callable)
- -

Errors

- -
-
One of the goals is a variable:
-
instantiation_error
-
One of the goals is neither a variable nor a callable term:
-
type_error(callable, Goal)
-
- -

Examples

- -
-
Prove a set of competing goals asynchronously, each one in its own thread:
-
threaded_race((Goal; Goals)
-
Prove a set of competing messages to self asynchronously, each one in its own thread:
-
threaded_race(::(Message; Messages))
-
Prove a set of competing messages to an object asynchronously, each one in its own thread:
-
threaded_race((Object::(Message; Messages))
-
- - - - - - diff --git a/Logtalk/manuals/refman/builtins/threaded_wait1.html b/Logtalk/manuals/refman/builtins/threaded_wait1.html deleted file mode 100644 index 3687a9f44..000000000 --- a/Logtalk/manuals/refman/builtins/threaded_wait1.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - Logtalk built-in predicate: threaded_wait/1 - - - - - - -
Logtalk reference manual
-
Built-in predicate: threaded_wait/1
-
-
- - -

threaded_wait/1

- -

Description

- -
threaded_wait(Term)
-threaded_wait([Term| Terms])
-

-Suspends the thread making the call until a notification is received that unifies with Term. The call must be made within the same object (this) containing the calls to the threaded_notify/1 predicate that will eventually send the notification. The argument may also be a list of notifications, [Term| Terms]. In this case, the thread making the call will suspend until all notifications in the list are received. -

- -

Template and modes

- -
threaded_wait(?term)
-threaded_wait(+list(term))
- -

Errors

- -
-

-(none) -

-
- -

Examples

- -
-
Wait until the data_available notification is received:
-
threaded_wait(data_available)
-
- - - - - - diff --git a/Logtalk/manuals/refman/control.header b/Logtalk/manuals/refman/control.header deleted file mode 100644 index fa224c8a3..000000000 --- a/Logtalk/manuals/refman/control.header +++ /dev/null @@ -1,2 +0,0 @@ - -

Control constructs

diff --git a/Logtalk/manuals/refman/control/context2.html b/Logtalk/manuals/refman/control/context2.html deleted file mode 100644 index 73c9977ea..000000000 --- a/Logtalk/manuals/refman/control/context2.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - Logtalk control construct: <</2 - - - - - - -
Logtalk reference manual
-
Control construct: <</2
-
-
- - -

<</2

- -

Description

- -
Object << Goal
-

-Calls a goal within the context of the specified object. Goal is called with the execution context (sender, this, and self) set to Object. Goal may need to be written within brackets to avoid parsing errors due to operator clashes. This control construct is mainly used for debugging and for writing object unit tests. -

- -

Template and modes

- -
+object_identifier << +callable
- -

Errors

- -
-
Either Object or Goal is a variable:
-
instantiation_error
-
Object is neither a variable nor a valid object identifier:
-
type_error(object_identifier, Object)
-
Goal is neither a variable nor a callable term:
-
type_error(callable, Goal)
-
Object does not contain a local definition for the Goal predicate:
-
existence_error(procedure, Goal)
-
Object does not exist:
-
existence_error(object, Object)
-
- -

Examples

- -
test(member) :-
-    list << member(1, [1]).
- - - - - - diff --git a/Logtalk/manuals/refman/control/direct1.html b/Logtalk/manuals/refman/control/direct1.html deleted file mode 100644 index 414bf485e..000000000 --- a/Logtalk/manuals/refman/control/direct1.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - Logtalk control construct: :/1 - - - - - - -
Logtalk reference manual
-
Control construct: :/1
-
-
- - -

:/1

- -

Description

- -
:Goal
-

-Calls an imported category predicate without using the message sending mechanisms. The category predicate is called with the same execution context (sender, this, and self) as the predicate whose body contains the call. The lookup for both the predicate declaration and the predicate definition begins in this instead of self. Furthermore, the lookup of the predicate definition is restricted to the imported categories. As a consequence, any redeclaration or redefinition of the predicate in a descendant of the object containing the call will be ignored. -

- -

Template and modes

- -
:+callable
- -

Errors

- -
-
Goal is a variable:
-
instantiation_error
-
Goal is neither a variable nor a callable term:
-
type_error(callable, Goal)
-
The object containing the call does not import any category:
-
existence_error(procedure, Goal)
-
- -

Examples

- -
:- object(bounded_point,
-    imports(bounded_coordinate),
-    instantiates(class),
-    specializes(point)).
-
-    move(X, Y) :-
-        :check_bounds(x, X),    % defined in the "bounded_coordinate" category
-        :check_bounds(y, Y),
-        ^^move(X, Y).
- - - - - - diff --git a/Logtalk/manuals/refman/control/external1.html b/Logtalk/manuals/refman/control/external1.html deleted file mode 100644 index 0a8fd831d..000000000 --- a/Logtalk/manuals/refman/control/external1.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - Logtalk control construct: {}/1 - - - - - - -
Logtalk reference manual
-
Control construct: {}/1
-
-
- - -

{}/1

- -

Description

- -
{Goal}
-

-Calls external Prolog code. Can be used to bypass the Logtalk compiler. The argument is called within the context of the pseudo-object user. -

- -

Template and modes

- -
{+callable}
- -

Errors

- -
-
Goal is a variable:
-
instantiation_error
-
Goal is neither a variable nor a callable term:
-
type_error(callable, Goal)
-
- -

Examples

- -
N1/D1 < N2/D2 :-
-    {N1*D2 < N2*D1}.
- - - - - - diff --git a/Logtalk/manuals/refman/control/to_object2.html b/Logtalk/manuals/refman/control/to_object2.html deleted file mode 100644 index 823ed9385..000000000 --- a/Logtalk/manuals/refman/control/to_object2.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - Logtalk control construct: ::/2 - - - - - - -
Logtalk reference manual
-
Control construct: ::/2
-
-
- - -

::/2

- -

Description

- -
Object::Predicate
-
-(Object1, Object2, ...)::Predicate
-
-(Object1; Object2; ...)::Predicate
-
-Object::(Predicate1, Predicate2, ...)
-
-Object::(Predicate1; Predicate2; ...)
-

-Sends a message to an object. The message argument must match a public predicate of the receiver object. We can also send the same message to a set of objects or a set of messages to the same object. The "," and ";" in the list have the usual Prolog meaning. -

- -

Template and modes

- -
+receivers::+messages
- -

Errors

- -
-
Either Object or Predicate is a variable:
-
instantiation_error
-
Predicate is declared private:
-
permission_error(access, private_predicate, Predicate)
-
Predicate is declared protected:
-
permission_error(access, protected_predicate, Predicate)
-
Predicate is not declared:
-
existence_error(predicate_declaration, Predicate)
-
Object does not exist:
-
existence_error(object, Object)
-
- -

Examples

- -
| ?- list::member(X, [1, 2, 3]).
-
-X = 1 ;
-X = 2 ;
-X = 3
-yes
- - - - - - diff --git a/Logtalk/manuals/refman/control/to_self1.html b/Logtalk/manuals/refman/control/to_self1.html deleted file mode 100644 index de19b130c..000000000 --- a/Logtalk/manuals/refman/control/to_self1.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - Logtalk control construct: ::/1 - - - - - - -
Logtalk reference manual
-
Control construct: ::/1
-
-
- - -

::/1

- -

Description

- -
::Predicate
-
-::(Predicate1, Predicate2, ...)
-
-::(Predicate1; Predicate2; ...)
-

- Send a message to self. Only used in the body of a predicate definition. The argument should match a public or protected predicate of self. It may also match a private predicate if the predicate is within the scope of the object where the method making the call is defined, if imported from a category, if used from inside a category, or when using private inheritance. We can also send a set of messages to self. The "," and ";" in the list have the usual Prolog meaning. -

- -

Template and modes

- -
::+messages
- -

Errors

- -
-
Predicate is a variable:
-
instantiation_error
-
Predicate is declared private:
-
permission_error(access, private_predicate, Predicate)
-
Predicate is not declared:
-
existence_error(predicate_declaration, Predicate)
-
- -

Examples

- -
area(Area) :-
-    ::width(Width),
-    ::height(Height),
-    Area is Width*Height.
- - - - - - diff --git a/Logtalk/manuals/refman/control/to_super1.html b/Logtalk/manuals/refman/control/to_super1.html deleted file mode 100644 index 67b3bbc0c..000000000 --- a/Logtalk/manuals/refman/control/to_super1.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - Logtalk control construct: ^^/1 - - - - - - -
Logtalk reference manual
-
Control construct: ^^/1
-
-
- - -

^^/1

- -

Description

- -
^^Predicate
-

-Calls a redefined/inherited definition for a message. Normally only used in the body of a predicate definition for the message. Predicate should match a public or protected predicate of self or be within the scope of this. -

- -

Template and modes

- -
^^+message
- -

Errors

- -
-
Predicate is a variable:
-
instantiation_error
-
Predicate is declared private:
-
permission_error(access, private_predicate, Predicate)
-
Predicate is not declared:
-
existence_error(predicate_declaration, Predicate)
-
Container of the inherited predicate definition is the same object that contains the ^^/1 call:
-
endless_loop(Predicate)
-
- -

Examples

- -
init :-
-    assertz(counter(0)),
-    ^^init.
- - - - - - diff --git a/Logtalk/manuals/refman/directives.header b/Logtalk/manuals/refman/directives.header deleted file mode 100644 index ed82a5a5b..000000000 --- a/Logtalk/manuals/refman/directives.header +++ /dev/null @@ -1,2 +0,0 @@ - -

Directives

diff --git a/Logtalk/manuals/refman/directives/alias3.html b/Logtalk/manuals/refman/directives/alias3.html deleted file mode 100644 index 431e6a95e..000000000 --- a/Logtalk/manuals/refman/directives/alias3.html +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - Logtalk predicate directive: alias/3 - - - - - - -
Logtalk reference manual
-
Predicate directive: alias/3
-
-
- - -

alias/3

- -

Description

- -
alias(Entity, Predicate, Alias)
-alias(Entity, NonTerminal, Alias)
-

-Declares predicate and grammar rule non-terminal aliases. A predicate (non-terminal) alias is an alternative name for a predicate (non-terminal) declared or defined in an implemented protocol, an imported category, an extended prototype, an instantiated class, or a specialized class. Predicate alias may be used to solve conflicts between imported or inherited predicates. This directive may be used in objects, protocols, and categories. -

- -

Template and modes

- -
alias(@entity_identifier, +predicate_indicator, +predicate_indicator)
-alias(@entity_identifier, +non_terminal_indicator, +non_terminal_indicator)
- - -

Examples

- -
:- alias(list, member/2, list_member/2).
-:- alias(set, member/2, set_member/2).
-
-:- alias(words, singular//0, peculiar//0).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/atomic1.html b/Logtalk/manuals/refman/directives/atomic1.html deleted file mode 100644 index fb5f29571..000000000 --- a/Logtalk/manuals/refman/directives/atomic1.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - Logtalk predicate directive: atomic/1 - - - - - - -
Logtalk reference manual
-
Predicate directive: atomic/1
-
-
- - -

atomic/1

- - -

Description

- -
atomic(Functor/Arity)
-atomic(Functor1/Arity1, Functor2/Arity2, ...)
-atomic([Functor1/Arity1, Functor2/Arity2, ...])
-
-atomic(Functor//Arity)
-atomic(Functor1//Arity1, Functor2//Arity2, ...)
-atomic([Functor1//Arity1, Functor2//Arity2, ...])
-

-Declares atomic predicates and atomic grammar rule non-terminals. The execution of an atomic predicate (or atomic non-terminal) is protected by a mutex in order to allow for thread synchronization when proving a call to the predicate (or non-terminal). -

- -

Template and modes

- -
atomic(+predicate_indicator_term)
-atomic(+non_terminal_indicator_term)
- - -

Examples

- -
:- atomic(db_update/1).
-
-:- atomic(write_stream/2, write_stream/2).
-
-:- atomic([add_to_queue/2, remove_from_queue/2]).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/calls1.html b/Logtalk/manuals/refman/directives/calls1.html deleted file mode 100644 index 403702f9d..000000000 --- a/Logtalk/manuals/refman/directives/calls1.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - Logtalk entity directive: calls/1 - - - - - - -
Logtalk reference manual
-
Entity directive: calls/1
-
-
- - -

calls/1

- -

Description

- -
calls(Protocol)
-calls(Protocol1, Protocol2, ...)
-calls([Protocol1, Protocol2, ...])
-

-Declares the protocol(s) that are called by predicates defined in an object or category. -

- -

Template and modes

- -
calls(+protocol_identifiers)
- - -

Examples

- -
:- calls(comparingp).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/category1_3.html b/Logtalk/manuals/refman/directives/category1_3.html deleted file mode 100644 index 6f8cb8dbf..000000000 --- a/Logtalk/manuals/refman/directives/category1_3.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - Logtalk entity directive: category/1-3 - - - - - - -
Logtalk reference manual
-
Entity directive: category/1-3
-
-
- - -

category/1-3

- -

Description

- -
category(Category)
-
-category(Category,
-    implements(Protocols))
-    
-category(Category,
-    imports(Categories))    
-    
-category(Category,
-    implements(Protocols),
-    imports(Categories))
-

- Starting category directive. -

- -

Template and modes

- -
category(+category_identifier)
-
-category(+category_identifier,
-    implements(+implemented_protocols))
-    
-category(+category_identifier,
-    imports(+imported_categories))
-
-category(+category_identifier,
-    implements(+implemented_protocols),
-    imports(+imported_categories))
- - -

Examples

- -
:- category(monitoring).
-
-:- category(monitoring,
-    implements(monitoringp)).
-
-:- category(attributes,
-    implements(protected::variables)).
-    
-:- category(extended,
-    imports(minimal)).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/discontiguous1.html b/Logtalk/manuals/refman/directives/discontiguous1.html deleted file mode 100644 index 9b109827d..000000000 --- a/Logtalk/manuals/refman/directives/discontiguous1.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - Logtalk predicate directive: discontiguous/1 - - - - - - -
Logtalk reference manual
-
Predicate directive: discontiguous/1
-
-
- - -

discontiguous/1

- -

Description

- -
discontiguous(Functor/Arity)
-discontiguous(Functor1/Arity1, Functor2/Arity2, ...)
-discontiguous([Functor1/Arity1, Functor2/Arity2, ...])
-
-discontiguous(Functor//Arity)
-discontiguous(Functor1//Arity1, Functor2//Arity2, ...)
-discontiguous([Functor1//Arity1, Functor2//Arity2, ...])
-

-Declares discontiguous predicates and discontiguous grammar rule non-terminals. The use of this directive should be avoided as not all Prolog compilers support discontiguous predicates. -

- -

Template and modes

- -
discontiguous(+predicate_indicator_term)
-discontiguous(+non_terminal_indicator_term)
- - -

Examples

- -
:- discontiguous(counter/1).
-
-:- discontiguous(lives/2, works/2).
-
-:- discontiguous([db/4, key/2, file/3]).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/dynamic0.html b/Logtalk/manuals/refman/directives/dynamic0.html deleted file mode 100644 index c085f6a12..000000000 --- a/Logtalk/manuals/refman/directives/dynamic0.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - Logtalk entity directive: dynamic/0 - - - - - - -
Logtalk reference manual
-
Entity directive: dynamic/0
-
-
- - -

dynamic/0

- -

Description

- -
dynamic
-

-Declares an entity and its contents as dynamic. Dynamic entities can be abolished at runtime. -

- -

Template and modes

- -
dynamic
- - -

Examples

- -
:- dynamic.
- - - - - - diff --git a/Logtalk/manuals/refman/directives/dynamic1.html b/Logtalk/manuals/refman/directives/dynamic1.html deleted file mode 100644 index 141cfcd13..000000000 --- a/Logtalk/manuals/refman/directives/dynamic1.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - Logtalk predicate directive: dynamic/1 - - - - - - -
Logtalk reference manual
-
Predicate directive: dynamic/1
-
-
- - -

dynamic/1

- -

Description

- -
dynamic(Functor/Arity)
-dynamic(Functor1/Arity1, Functor2/Arity2, ...)
-dynamic([Functor1/Arity1, Functor2/Arity2, ...])
-
-dynamic(Functor//Arity)
-dynamic(Functor1//Arity1, Functor2//Arity2, ...)
-dynamic([Functor1//Arity1, Functor2//Arity2, ...])
-

-Declares dynamic predicates and dynamic grammar rule non-terminals. Note that an object can be static and have both static and dynamic predicates/non-terminals. -

- -

Template and modes

- -
dynamic(+predicate_indicator_term)
-dynamic(+non_terminal_indicator_term)
- - -

Examples

- -
:- dynamic(counter/1).
-
-:- dynamic(lives/2, works/2).
-
-:- dynamic([db/4, key/2, file/3]).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/encoding1.html b/Logtalk/manuals/refman/directives/encoding1.html deleted file mode 100644 index a2dc1da3d..000000000 --- a/Logtalk/manuals/refman/directives/encoding1.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - Logtalk entity directive: encoding/1 - - - - - - -
Logtalk reference manual
-
Entity directive: encoding/1
-
-
- - -

encoding/1

- -

Description

- -
encoding(Encoding)
-

-Declares the source file text encoding. This is an experimental source file directive, which is only supported on some Prolog compilers. When used, this directive must be the first term in the source file. Currently recognized encodings include ascii, iso_8859_1, iso_latin_1 (an alias to the previous one), utf8, unicode_be, and unicode_le. -

- -

Template and modes

- -
encoding(+atom)
- - -

Examples

- -
:- encoding(utf8).
-
-:- encoding(iso_latin_1).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/end_category0.html b/Logtalk/manuals/refman/directives/end_category0.html deleted file mode 100644 index 2b0d1c9dd..000000000 --- a/Logtalk/manuals/refman/directives/end_category0.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - Logtalk entity directive: end_category/0 - - - - - - -
Logtalk reference manual
-
Entity directive: end_category/0
-
-
- - -

end_category/0

- -

Description

- -
end_category
-

- Ending category directive. -

- -

Template and modes

- -
end_category
- - -

Examples

- -
:- end_category.
- - - - - - diff --git a/Logtalk/manuals/refman/directives/end_object0.html b/Logtalk/manuals/refman/directives/end_object0.html deleted file mode 100644 index 5c3d3b430..000000000 --- a/Logtalk/manuals/refman/directives/end_object0.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - Logtalk entity directive: end_object/0 - - - - - - -
Logtalk reference manual
-
Entity directive: end_object/0
-
-
- - -

end_object/0

- -

Description

- -
end_object
-

- Ending object directive. -

- -

Template and modes

- -
end_object
- - -

Examples

- -
:- end_object.
- - - - - - diff --git a/Logtalk/manuals/refman/directives/end_protocol0.html b/Logtalk/manuals/refman/directives/end_protocol0.html deleted file mode 100644 index b7c24cc66..000000000 --- a/Logtalk/manuals/refman/directives/end_protocol0.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - Logtalk entity directive: end_protocol/0 - - - - - - -
Logtalk reference manual
-
Entity directive: end_protocol/0
-
-
- - -

end_protocol/0

- -

Description

- -
end_protocol
-

-Ending protocol directive. -

- -

Template and modes

- -
end_protocol
- - -

Examples

- -
:- end_protocol.
- - - - - - diff --git a/Logtalk/manuals/refman/directives/info1.html b/Logtalk/manuals/refman/directives/info1.html deleted file mode 100644 index 8253f8b2b..000000000 --- a/Logtalk/manuals/refman/directives/info1.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - Logtalk entity directive: info/1 - - - - - - -
Logtalk reference manual
-
Entity directive: info/1
-
-
- - -

info/1

- -

Description

- -
info(List)
-

- Documentation directive for objects, protocols, and categories. -

- -

Template and modes

- -
info(+info_list)
- - -

Examples

- -
:- info([
-    version is 1.0,
-    author is 'Paulo Moura',
-    date is 2000/4/20,
-    comment is 'List protocol.']).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/info2.html b/Logtalk/manuals/refman/directives/info2.html deleted file mode 100644 index cd533475e..000000000 --- a/Logtalk/manuals/refman/directives/info2.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - Logtalk predicate directive: info/2 - - - - - - -
Logtalk reference manual
-
Predicate directive: info/2
-
-
- - -

info/2

- -

Description

- -
info(Functor/Arity, List)
-info(Functor//Arity, List)
-

-Documentation directive for predicates and grammar rule non-terminals. -

- -

Template and modes

- -
info(+predicate_indicator, +info_list)
-info(+non_terminal_indicator, +info_list)
- -

Examples

- -
:- info(empty/1, [
-    comment is 'True if the argument is an empty list.',
-    argnames is ['List']]).
-    
-:- info(sentence//0, [
-    comment is 'Rewrites a sentence into a noun phrase and a verb phrase.']).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/initialization1.html b/Logtalk/manuals/refman/directives/initialization1.html deleted file mode 100644 index d2f5c2222..000000000 --- a/Logtalk/manuals/refman/directives/initialization1.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - Logtalk entity directive: initialization/1 - - - - - - -
Logtalk reference manual
-
Entity directive: initialization/1
-
-
- - -

initialization/1

- -

Description

- -
initialization(Goal)
-

- Sets a goal to be called immediately after the container entity has been loaded to memory. -

- -

Template and modes

- -
initialization(@goal)
- - -

Examples

- -
:- initialization(init).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/meta_predicate1.html b/Logtalk/manuals/refman/directives/meta_predicate1.html deleted file mode 100644 index a0ea276b7..000000000 --- a/Logtalk/manuals/refman/directives/meta_predicate1.html +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - Logtalk predicate directive: meta_predicate/1 - - - - - - -
Logtalk reference manual
-
Predicate directive: meta_predicate/1
-
-
- - -

meta_predicate/1

- -

Description

- -
meta_predicate(MetaPredicate)
-

-Declares meta-predicates, i.e., predicates that have arguments that will be called as goals. An argument may also be a closure instead of a goal if the meta-predicate uses the call/N Logtalk built-in methods to construct the actual goal from the closure and the additional arguments. -

-

-Meta-arguments which are goals are represented by the atom :: (for consistency with the message sending operators). Meta-arguments which are closures are represented by a positive integer, N, representing the number of additional arguments that will be appended to the closure in order to construct the corresponding meta-call. Normal arguments are represented by the atom *. -

- -

Template and modes

- -
meta_predicate(+meta_predicate_mode_indicator)
- - -

Examples

- -
:- meta_predicate(findall(*, ::, *)).
-
-:- meta_predicate(forall(::, ::)).
-
-:- meta_predicate(maplist(2, *, *))
- - - - - - diff --git a/Logtalk/manuals/refman/directives/metapredicate1.html b/Logtalk/manuals/refman/directives/metapredicate1.html deleted file mode 100644 index 2592cd939..000000000 --- a/Logtalk/manuals/refman/directives/metapredicate1.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - Logtalk predicate directive: metapredicate/1 - - - - - - -
Logtalk reference manual
-
Predicate directive: metapredicate/1
-
-
- - -

metapredicate/1

- - -

Description

- -
metapredicate(Metapredicate)
-

-Declares metapredicates, i.e., predicates that have arguments that will be called as goals. -

- -

Template and modes

- -
metapredicate(+metapredicate_predicate_term)
- - -

Examples

- -
:- metapredicate(findall(*, ::, *)).
-
-:- metapredicate(forall(::, ::)).
- - - - - diff --git a/Logtalk/manuals/refman/directives/mode2.html b/Logtalk/manuals/refman/directives/mode2.html deleted file mode 100644 index fe848ec1d..000000000 --- a/Logtalk/manuals/refman/directives/mode2.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - Logtalk predicate directive: mode/2 - - - - - - -
Logtalk reference manual
-
Predicate directive: mode/2
-
-
- - -

mode/2

- -

Description

- -
mode(Mode, Number_of_solutions)
-

-Most predicates can be used with several instantiations modes. This directive enables the specification of each instantiation mode and the corresponding number of solutions (not necessarily distinct). You may also use this directive for documenting grammar rule non-terminals. -

- -

Template and modes

- -
mode(+predicate_mode_term, +number_of_solutions)
-mode(+non_terminal_mode_term, +number_of_solutions)
- -

Examples

- -
:- mode(append(-, -, +), zero_or_more).
-
-:- mode(append(+list, +list, -list), zero_or_one).
-
-:- mode(var(@term), zero_or_one).
-
-:- mode(arg(-, -, +), error).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/object1_5.html b/Logtalk/manuals/refman/directives/object1_5.html deleted file mode 100644 index 3db059dcb..000000000 --- a/Logtalk/manuals/refman/directives/object1_5.html +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - - - Logtalk entity directive: object/1-5 - - - - - - -
Logtalk reference manual
-
Entity directive: object/1-5
-
-
- - -

object/1-5

- -

Description

- -

-Stand-alone objects (prototypes) -

-
object(Object)
-
-object(Object,
-    implements(Protocols))
-
-object(Object,
-    imports(Categories))
-
-object(Object,
-    implements(Protocols),
-    imports(Categories))
-

-Prototype extensions -

-
object(Object,
-    extends(Objects))
-
-object(Object,
-    implements(Protocols),
-    extends(Objects))
-
-object(Object,
-    imports(Categories),
-    extends(Objects))
-
-object(Object,
-    implements(Protocols),
-    imports(Categories),
-    extends(Objects))
-

- Class instances -

-
object(Object,
-    instantiates(Classes))
-
-object(Object,
-    implements(Protocols),
-    instantiates(Classes))
-
-object(Object,
-    imports(Categories),
-    instantiates(Classes))
-
-object(Object,
-    implements(Protocols),
-    imports(Categories),
-    instantiates(Classes))
-

- Classes -

-
object(Object,
-    specializes(Classes))
-
-object(Object,
-    implements(Protocols),
-    specializes(Classes))
-
-object(Object,
-    imports(Categories),
-    specializes(Classes))
-
-object(Object,
-    implements(Protocols),
-    imports(Categories),
-    specializes(Classes))
-

-Classes with metaclasses -

-
object(Object,
-    instantiates(Classes),
-    specializes(Classes))
-
-object(Object,
-    implements(Protocols),
-    instantiates(Classes),
-    specializes(Classes))
-
-object(Object,
-    imports(Categories),
-    instantiates(Classes),
-    specializes(Classes))
-
-object(Object,
-    implements(Protocols),
-    imports(Categories),
-    instantiates(Classes),
-    specializes(Classes))
-

-Starting object directive. -

- -

Template and modes

- -

-Stand-alone objects (prototypes) -

-
object(+object_identifier)
-
-object(+object_identifier,
-    implements(+implemented_protocols))
-
-object(+object_identifier,
-    imports(+imported_categories))
-
-object(+object_identifier,
-    implements(+implemented_protocols),
-    imports(+imported_categories))
-

-Prototype extensions -

-
object(+object_identifier,
-    extends(+extended_objects))
-
-object(+object_identifier,
-    implements(+implemented_protocols),
-    extends(+extended_objects))
-
-object(+object_identifier,
-    imports(+imported_categories),
-    extends(+extended_objects))
-
-object(+object_identifier,
-    implements(+implemented_protocols),
-    imports(+imported_categories),
-    extends(+extended_objects))
-

-Class instances -

-
object(+object_identifier,
-    instantiates(+instantiated_objects))
-
-object(+object_identifier,
-    implements(+implemented_protocols),
-    instantiates(+instantiated_objects))
-
-object(+object_identifier,
-    imports(+imported_categories),
-    instantiates(+instantiated_objects))
-
-object(+object_identifier,
-    implements(+implemented_protocols),
-    imports(+imported_categories),
-    instantiates(+instantiated_objects))
-

-Classes -

-
object(+object_identifier,
-    specializes(+specialized_objects))
-
-object(+object_identifier,
-    implements(+implemented_protocols),
-    specializes(+specialized_objects))
-
-object(+object_identifier,
-    imports(+imported_categories),
-    specializes(+specialized_objects))
-
-object(+object_identifier,
-    implements(+implemented_protocols),
-    imports(+imported_categories),
-    specializes(+specialized_objects))
-

- Class with metaclasses -

-
object(+object_identifier,
-    instantiates(+instantiated_objects),
-    specializes(+specialized_objects))
-
-object(+object_identifier,
-    implements(+implemented_protocols),
-    instantiates(+instantiated_objects),
-    specializes(+specialized_objects))
-
-object(+object_identifier,
-    imports(+imported_categories),
-    instantiates(+instantiated_objects),
-    specializes(+specialized_objects))
-
-object(+object_identifier,
-    implements(+implemented_protocols),
-    imports(+imported_categories),
-    instantiates(+instantiated_objects),
-    specializes(+specialized_objects))
- - -

Examples

- -
:- object(list).
-
-:- object(list,
-    implements(listp)).
-
-:- object(list,
-    extends(compound)).
-
-:- object(list,
-    implements(listp),
-    extends(compound)).
-
-:- object(object,
-    imports(initialization),
-    instantiates(class)).
-
-:- object(abstract_class,
-    instantiates(class),
-    specializes(object)).
-
-:- object(agent,
-    imports(private::attributes)).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/op3.html b/Logtalk/manuals/refman/directives/op3.html deleted file mode 100644 index 05d730c7d..000000000 --- a/Logtalk/manuals/refman/directives/op3.html +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - Logtalk entity directive: op/3 - - - - - - -
Logtalk reference manual
-
Entity directive: op/3
-
-
- - -

op/3

- -

Description

- -
op(Precedence, Associativity, Operator)
-

-Declares operators. Operators declared inside objects and categories have local scope. Global operators can be declared inside a source file by writing the respective directives before the entity opening directives. -

- -

Template and modes

- -
op(+integer, +associativity, +atom_or_atom_list)
- - -

Examples

- -
:- op(950, fx, +).
-:- op(950, fx, ?).
-:- op(950, fx, @).
-:- op(950, fx, -).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/private1.html b/Logtalk/manuals/refman/directives/private1.html deleted file mode 100644 index 6124e2974..000000000 --- a/Logtalk/manuals/refman/directives/private1.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - Logtalk predicate directive: private/1 - - - - - - -
Logtalk reference manual
-
Predicate directive: private/1
-
-
- - -

private/1

- -

Description

- -
private(Functor/Arity)
-private(Functor1/Arity1, Functor2/Arity2, ...)
-private([Functor1/Arity1, Functor2/Arity2, ...])
-
-private(Functor//Arity)
-private(Functor1//Arity1, Functor2//Arity2, ...)
-private([Functor1//Arity1, Functor2//Arity2, ...])
-

-Declares private predicates and private grammar rule non-terminals. A private predicate can only be called from the object containing the private directive. A private non-terminal can only be used in a call of the phrase/2 and phrase/3 methods from the object containing the private directive. -

- -

Template and modes

- -
private(+predicate_indicator_term)
-private(+non_terminal_indicator_term)
- -

Examples

- -
:- private(counter/1).
-
-:- private(init/1, free/1).
-
-:- private([data/3, key/1, keys/1]).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/protected1.html b/Logtalk/manuals/refman/directives/protected1.html deleted file mode 100644 index 357b6e134..000000000 --- a/Logtalk/manuals/refman/directives/protected1.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - Logtalk predicate directive: protected/1 - - - - - - -
Logtalk reference manual
-
Predicate directive: protected/1
-
-
- - -

protected/1

- -

Description

- -
protected(Functor/Arity)
-protected(Functor1/Arity1, Functor2/Arity2, ...)
-protected([Functor1/Arity1, Functor2/Arity2, ...])
-
-protected(Functor//Arity)
-protected(Functor1//Arity1, Functor2//Arity2, ...)
-protected([Functor1//Arity1, Functor2//Arity2, ...])
-

-Declares protected predicates and protected grammar rule non-terminals. A protected predicate can only be called from the object containing the directive or from an object that inherits the directive. A protected non-terminal can only be used as an argument in a phrase/2 and phrase/3 messages sent from the object containing the directive or from an object that inherits the directive. -

- -

Template and modes

- -
protected(+predicate_indicator_term)
-protected(+non_terminal_indicator_term)
- - -

Examples

- -
:- protected(init/1).
-
-:- protected(print/2, convert/4).
-
-:- protected([load/1, save/3]).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/protocol1_2.html b/Logtalk/manuals/refman/directives/protocol1_2.html deleted file mode 100644 index 22041483b..000000000 --- a/Logtalk/manuals/refman/directives/protocol1_2.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - Logtalk predicate directive: protocol/1-2 - - - - - - -
Logtalk reference manual
-
Predicate directive: protocol/1-2
-
-
- - -

protocol/1-2

- -

Description

- -
protocol(Protocol)
-
-protocol(Protocol,
-    extends(Protocols))
-

-Starting protocol directive. -

- -

Template and modes

- -
protocol(+protocol_identifier)
-
-protocol(+protocol_identifier,
-    extends(+extended_protocols))
- - -

Examples

- -
:- protocol(listp).
-
-:- protocol(listp,
-    extends(compoundp)).
-
-:- protocol(queuep,
-    extends(protected::listp)).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/public1.html b/Logtalk/manuals/refman/directives/public1.html deleted file mode 100644 index a3f7a5086..000000000 --- a/Logtalk/manuals/refman/directives/public1.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - Logtalk predicate directive: public/1 - - - - - - -
Logtalk reference manual
-
Predicate directive: public/1
-
-
- - -

public/1

- -

Description

- -
public(Functor/Arity)
-public(Functor1/Arity1, Functor2/Arity2, ...)
-public([Functor1/Arity1, Functor2/Arity2, ...])
-
-public(Functor//Arity)
-public(Functor1//Arity1, Functor2//Arity2, ...)
-public([Functor1//Arity1, Functor2//Arity2, ...])
-

-Declares public predicates and public grammar rule non-terminals. A public predicate can be called from any object. A public non-terminal can be used as an argument in phrase/2 and phrase/3 messages sent from any object. -

- -

Template and modes

- -
public(+predicate_indicator_term)
-public(+non_terminal_indicator_term)
- - -

Examples

- -
:- public(ancestor/1).
-
-:- public(instance/1, instances/1).
-
-:- public([leaf/1, leaves/1]).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/synchronized0.html b/Logtalk/manuals/refman/directives/synchronized0.html deleted file mode 100644 index aa83d1472..000000000 --- a/Logtalk/manuals/refman/directives/synchronized0.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - Logtalk entity directive: synchronized/0 - - - - - - -
Logtalk reference manual
-
Entity directive: synchronized/0
-
-
- - -

synchronized/0

- -

Description

- -
synchronized
-

-Declares that all object (or category) predicates and non-terminals will be synchronized (i.e. all predicates and non-terminals will use the same mutex for thread synchronization). Synchronized predicates and non-terminals are silently compiled as normal predicates and normal non-terminals when using back-end Prolog compilers that don't support multi-threading programming. -

- -

Template and modes

- -
synchronized
- - -

Examples

- -
:- synchronized.
- - - - - - diff --git a/Logtalk/manuals/refman/directives/synchronized1.html b/Logtalk/manuals/refman/directives/synchronized1.html deleted file mode 100644 index 22cfc9fda..000000000 --- a/Logtalk/manuals/refman/directives/synchronized1.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - Logtalk predicate directive: synchronized/1 - - - - - - -
Logtalk reference manual
-
Predicate directive: synchronized/1
-
-
- - -

synchronized/1

- -

Description

- -
synchronized(Functor/Arity)
-synchronized(Functor1/Arity1, Functor2/Arity2, ...)
-synchronized([Functor1/Arity1, Functor2/Arity2, ...])
-
-synchronized(Functor//Arity)
-synchronized(Functor1//Arity1, Functor2//Arity2, ...)
-synchronized([Functor1//Arity1, Functor2//Arity2, ...])
-

-Declares synchronized predicates and synchronized grammar rule non-terminals. A synchronized predicate (or synchronized non-terminal) is protected by a mutex in order to allow for thread synchronization when proving a call to the predicate (or non-terminal). All predicates declared in the same synchronized directive share the same mutex. In order to use a separate mutex for each predicate (so that they are independently synchronized), a per-predicate synchronized directive must be used. -

-

-Synchronized predicates are silently compiled as normal predicates when using back-end Prolog compilers that don't support multi-threading programming. -

- -

Template and modes

- -
synchronized(+predicate_indicator_term)
-synchronized(+non_terminal_indicator_term)
- - -

Examples

- -
:- synchronized(db_update/1).
-
-:- synchronized(write_stream/2, read_stream/2).
-
-:- synchronized([add_to_queue/2, remove_from_queue/2]).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/threaded0.html b/Logtalk/manuals/refman/directives/threaded0.html deleted file mode 100644 index 259e077f9..000000000 --- a/Logtalk/manuals/refman/directives/threaded0.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - Logtalk entity directive: threaded/0 - - - - - - -
Logtalk reference manual
-
Entity directive: threaded/0
-
-
- - -

threaded/0

- -

Description

- -
threaded
-

-Declares that an object supports concurrent calls and asynchronous messages. Any object containing calls to the built-in multi-threading predicates (or importing a category that contains such calls) must include this directive. -

- -

Template and modes

- -
threaded
- - -

Examples

- -
:- threaded.
- - - - - - diff --git a/Logtalk/manuals/refman/directives/uses1.html b/Logtalk/manuals/refman/directives/uses1.html deleted file mode 100644 index a7a3afcee..000000000 --- a/Logtalk/manuals/refman/directives/uses1.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - Logtalk entity directive: uses/1 - - - - - - -
Logtalk reference manual
-
Entity directive: uses/1
-
-
- - -

uses/1

- -

Description

- -
uses(Object)
-

-Declares an object that receives messages from predicates defined in the category or object containing the directive. In the current Logtalk version, this is a non-operational directive, which may be used for documentation. Nevertheless, the compiler will warn you of any unknown object referenced using this directive when an entity containing it is compiled. In a forthcoming release, this directive will likely be used to support object namespaces. -

- -

Template and modes

- -
uses(+object_identifier)
- - -

Examples

- -
:- uses(list).
- - - - - - diff --git a/Logtalk/manuals/refman/directives/uses2.html b/Logtalk/manuals/refman/directives/uses2.html deleted file mode 100644 index 252fbfc0e..000000000 --- a/Logtalk/manuals/refman/directives/uses2.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - Logtalk entity directive: uses/2 - - - - - - -
Logtalk reference manual
-
Entity directive: uses/2
-
-
- - -

uses/2

- -

Description

- -
uses(Object, Predicates)
-uses(Object, PredicatesAndAliases)
-

-Declares that all calls (made from predicates defined in the category or object containing the directive) to the specified predicates are to be interpreted as messages to the specified object. Thus, this directive may be used to simplify writing of predicate definitions by allowing the programmer to omit the Object:: prefix when using the predicates listed in the directive (as long as the predicate calls do not occur as arguments for user-defined meta-predicates or for non-standard Prolog meta-predicates not declared on the config files). -

-

-It is possible to specify a predicate alias using the notation Functor/Arity::Alias/Arity. Aliases may be used either for avoiding conflicts between predicates specificed in several uses/2 directives or for giving more meanfingul names considering the using context of the predicates. -

- -

Template and modes

- -
uses(+object_identifier, +predicate_indicator_list)
-uses(+object_identifier, +predicate_indicator_alias_list)
- - -

Examples

- -
:- uses(list, [append/3, member/2]).
-
-foo :-
-    ...,
-    findall(X, member(X, L), A),    % the same as: findall(X, list::member(X, L), A)
-    append(A, B, C),                % the same as: list::append(A, B, C)
-    ...
-

-Another example, using the extended notation that allows us to define predicate aliases: -

-
:- uses(btrees, [new/1::new_btree/1]).
-:- uses(queues, [new/1::new_queue/1]).
-
-btree_to_queue :-
-    ...,
-    new_btree(Tree),     % the same as: btrees::new(Tree)
-    new_queue(Queue),    % the same as: queues::new(Queue)
-    ...
- - - - - - diff --git a/Logtalk/manuals/refman/grammar.html b/Logtalk/manuals/refman/grammar.html deleted file mode 100644 index 31b25ae37..000000000 --- a/Logtalk/manuals/refman/grammar.html +++ /dev/null @@ -1,767 +0,0 @@ - - - - - - - - Logtalk reference manual: grammar - - - - - - -
Logtalk reference manual
-
Grammar
-
-
- - -

Grammar

- -

-The Logtalk grammar is here described using Backus-Naur Form syntax. Non-terminal symbols in italics have the definition found in the ISO Prolog Standard. Terminal symbols are represented in a fixed width font and between "". -

- - -

Compilation units

- -
-
entity ::=
-
object |
-
category |
-
protocol
-
- -

Object definition

- -
-
object ::=
-
begin_object_directive [object_directives] [clauses] end_object_directive.
-
-
-
begin_object_directive ::=
-
":- object(" object_identifier [ "," object_relations] ")."
-
-
-
end_object_directive ::=
-
":- end_object."
-
-
-
object_relations ::=
-
prototype_relations |
-
non_prototype_relations
-
-
-
prototype_relations ::=
-
prototype_relation |
-
prototype_relation "," prototype_relations
-
-
-
prototype_relation ::=
-
implements_protocols |
-
imports_categories |
-
extends_objects
-
-
-
non_prototype_relations ::=
-
non_prototype_relation |
-
non_prototype_relation "," non_prototype_relations
-
-
-
non_prototype_relation ::=
-
implements_protocols |
-
imports_categories |
-
instantiates_classes |
-
specializes_classes
-
- - -

Category definition

- -
-
category ::=
-
begin_category_directive [category_directives] [clauses] end_category_directive.
-
-
-
begin_category_directive ::=
-
":- category(" category_identifier [ "," category_relations] ")."
-
-
-
end_category_directive ::=
-
":- end_category."
-
-
-
category_relations ::=
-
category_relation |
-
category_relation "," category_relations
-
-
-
category_relation ::=
-
implements_protocols |
-
imports_categories
-
- - -

Protocol definition

- -
-
protocol ::=
-
begin_protocol_directive [protocol_directives] end_protocol_directive.
-
-
-
begin_protocol_directive ::=
-
":- protocol(" protocol_identifier [ "," extends_protocols] ")."
-
-
-
end_protocol_directive ::=
-
":- end_protocol."
-
- - -

Entity relations

- -
-
implements_protocols ::=
-
"implements(" implemented_protocols ")"
-
-
-
extends_protocols ::=
-
"extends(" extended_protocols ")"
-
-
-
imports_categories ::=
-
"imports(" imported_categories ")"
-
-
-
extends_objects ::=
-
"extends(" extended_objects ")"
-
-
-
instantiates_classes ::=
-
"instantiates(" instantiated_objects ")"
-
-
-
specializes_classes ::=
-
"specializes(" specialized_objects ")"
-
- -

Implemented protocols

-
-
implemented_protocols ::=
-
implemented_protocol |
-
implemented_protocol_sequence |
-
implemented_protocol_list
-
-
-
implemented_protocol ::=
-
protocol_identifier |
-
scope "::" protocol_identifier
-
-
-
implemented_protocol_sequence ::=
-
implemented_protocol |
-
implemented_protocol "," implemented_protocol_sequence
-
-
-
implemented_protocol_list ::=
-
"[" implemented_protocol_sequence "]"
-
- -

Extended protocols

-
-
extended_protocols ::=
-
extended_protocol |
-
extended_protocol_sequence |
-
extended_protocol_list
-
-
-
extended_protocol ::=
-
protocol_identifier |
-
scope "::" protocol_identifier
-
-
-
extended_protocol_sequence ::=
-
extended_protocol |
-
extended_protocol "," extended_protocol_sequence
-
-
-
extended_protocol_list ::=
-
"[" extended_protocol_sequence "]"
-
- -

Imported categories

-
-
imported_categories ::=
-
imported_category |
-
imported_category_sequence |
-
imported_category_list
-
-
-
imported_category ::=
-
category_identifier |
-
scope "::" category_identifier
-
-
-
imported_category_sequence ::=
-
imported_category |
-
imported_category "," imported_category_sequence
-
-
-
imported_category_list ::=
-
"[" imported_category_sequence "]"
-
- -

Extended objects

-
-
extended_objects ::=
-
extended_object |
-
extended_object_sequence |
-
extended_object_list
-
-
-
extended_object ::=
-
object_identifier |
-
scope "::" object_identifier
-
-
-
extended_object_sequence ::=
-
extended_object |
-
extended_object "," extended_object_sequence
-
-
-
extended_object_list ::=
-
"[" extended_object_sequence "]"
-
- -

Instantiated objects

-
-
instantiated_objects ::=
-
instantiated_object |
-
instantiated_object_sequence |
-
instantiated_object_list
-
-
-
instantiated_object ::=
-
object_identifier |
-
scope "::" object_identifier
-
-
-
instantiated_object_sequence ::=
-
instantiated_object
-
instantiated_object "," instantiated_object_sequence |
-
-
-
instantiated_object_list ::=
-
"[" instantiated_object_sequence "]"
-
- -

Specialized objects

-
-
specialized_objects ::=
-
specialized_object |
-
specialized_object_sequence |
-
specialized_object_list
-
-
-
specialized_object ::=
-
object_identifier |
-
scope "::" object_identifier
-
-
-
specialized_object_sequence ::=
-
specialized_object |
-
specialized_object "," specialized_object_sequence
-
-
-
specialized_object_list ::=
-
"[" specialized_object_sequence "]"
-
- -

Entity scope

-
-
scope ::=
-
"public" |
-
"protected" |
-
"private"
-
- - -

Entity identifiers

- -
-
entity_identifiers ::=
-
entity_identifier |
-
entity_identifier_sequence |
-
entity_identifier_list
-
-
-
entity_identifier ::=
-
object_identifier |
-
protocol_identifier |
-
category_identifier
-
-
-
entity_identifier_sequence ::=
-
entity_identifier |
-
entity_identifier "," entity_identifier_sequence
-
-
-
entity_identifier_list ::=
-
"[" entity_identifier_sequence "]"
-
- -

Object identifiers

-
-
object_identifiers ::=
-
object_identifier |
-
object_identifier_sequence |
-
object_identifier_list
-
-
-
object_identifier ::=
-
atom |
-
compound
-
-
-
object_identifier_sequence ::=
-
object_identifier |
-
object_identifier "," object_identifier_sequence
-
-
-
object_identifier_list ::=
-
"[" object_identifier_sequence "]"
-
- -

Category identifiers

-
-
category_identifiers ::=
-
category_identifier |
-
category_identifier_sequence |
-
category_identifier_list
-
-
-
category_identifier ::=
-
atom
-
-
-
category_identifier_sequence ::=
-
category_identifier |
-
category_identifier "," category_identifier_sequence
-
-
-
category_identifier_list ::=
-
"[" category_identifier_sequence "]"
-
- -

Protocol identifiers

-
-
protocol_identifiers ::=
-
protocol_identifier |
-
protocol_identifier_sequence |
-
protocol_identifier_list
-
-
- -
protocol_identifier ::=
-
atom
-
-
-
protocol_identifier_sequence ::=
-
protocol_identifier |
-
protocol_identifier "," protocol_identifier_sequence
-
-
-
protocol_identifier_list ::=
-
"[" protocol_identifier_sequence "]"
-
- - -

Source file names

- -
-
source_file_names ::=
-
source_file_name |
-
source_file_name_list
-
-
-
source_file_name ::=
-
atom |
-
library_source_file_name
-
-
-
library_source_file_name ::=
-
library_name "(" atom ")"
-
-
-
library_name ::=
-
atom
-
-
-
source_file_name_sequence ::=
-
source_file_name |
-
source_file_name "," source_file_name_sequence
-
-
-
source_file_name_list ::=
-
"[" source_file_name_sequence "]"
-
- - - -

Directives

- -

Source file directives

-
-
source_file_directives ::=
-
source_file_directive |
-
source_file_directive source_file_directives
-
-
-
source_file_directive ::=
-
":- encoding(" atom ")." |
-
initialization_directive |
-
operator_directive
-
- -

Object directives

-
-
object_directives ::=
-
object_directive |
-
object_directive object_directives
-
-
-
object_directive ::=
-
initialization_directive |
-
":- threaded." |
-
":- synchronized." |
-
":- dynamic." |
-
":- uses(" object_identifier ")." |
-
":- calls(" protocol_identifiers ")." |
-
":- info(" info_list ")." |
-
predicate_directives
-
- -

Category directives

-
-
category_directives ::=
-
category_directive |
-
category_directive category_directives
-
-
-
category_directive ::=
-
initialization_directive |
-
":- synchronized." |
-
":- dynamic." |
-
":- uses(" object_identifier ")." |
-
":- calls(" protocol_identifiers ")." |
-
":- info(" info_list ")." |
-
predicate_directives
-
- -

Protocol directives

-
-
protocol_directives ::=
-
protocol_directive |
-
protocol_directive protocol_directives
-
-
-
protocol_directive ::=
-
initialization_directive |
-
":- dynamic." |
-
":- info(" info_list ")." |
-
predicate_directives
-
- -

Predicate directives

-
-
predicate_directives ::=
-
predicate_directive |
-
predicate_directive predicate_directives
-
-
-
predicate_directive ::=
-
alias_directive |
-
synchronized_directive |
-
uses_directive |
-
scope_directive |
-
mode_directive |
-
meta_predicate_directive |
-
info_directive |
-
dynamic_directive |
-
discontiguous_directive |
-
operator_directive
-
-
-
alias_directive ::=
-
":- alias(" entity_identifier "," predicate_indicator "," predicate_indicator ")." |
-
":- alias(" entity_identifier "," non_terminal_indicator "," non_terminal_indicator ")."
-
-
-
synchronized_directive ::=
-
":- synchronized(" predicate_indicator ")." |
-
":- synchronized(" non_terminal_indicator ")."
-
-
-
uses_directive ::=
-
":- uses(" object_identifier "," predicate_indicator_alias_list ")."
-
-
-
scope_directive ::=
-
":- public(" predicate_indicator_term | non_terminal_indicator_term ")." |
-
":- protected(" predicate_indicator_term | non_terminal_indicator_term ")." |
-
":- private(" predicate_indicator_term | non_terminal_indicator_term ")."
-
-
-
mode_directive ::=
-
":- mode(" predicate_mode_term | non_terminal_mode_term "," number_of_solutions ")."
-
-
-
meta_predicate_directive ::=
-
":- meta_predicate(" meta_predicate_mode_indicator ")."
-
-
-
info_directive ::=
-
":- info(" predicate_indicator | non_terminal_indicator "," info_list ")."
-
-
-
dynamic_directive ::=
-
":- dynamic(" predicate_indicator_term | non_terminal_indicator_term ")." |
-
-
-
discontiguous_directive ::=
-
":- discontiguous(" predicate_indicator_term | non_terminal_indicator_term ")." |
-
-
-
predicate_indicator_term ::=
-
predicate_indicator |
-
predicate_indicator_sequence |
-
predicate_indicator_list
-
-
-
predicate_indicator_sequence ::=
-
predicate_indicator |
-
predicate_indicator "," predicate_indicator_sequence
-
-
-
predicate_indicator_list ::=
-
"[" predicate_indicator_sequence "]"
-
-
-
predicate_indicator_alias ::=
-
predicate_indicator |
-
predicate_indicator "::" predicate_indicator
-
-
-
predicate_indicator_alias_sequence ::=
-
predicate_indicator_alias |
-
predicate_indicator_alias "," predicate_indicator_alias_sequence
-
-
-
predicate_indicator_alias_list ::=
-
"[" predicate_indicator_alias_sequence "]"
-
-
-
non_terminal_indicator_term ::=
-
non_terminal_indicator |
-
non_terminal_indicator_sequence |
-
non_terminal_indicator_list
-
-
-
non_terminal_indicator_sequence ::=
-
non_terminal_indicator |
-
non_terminal_indicator "," non_terminal_indicator_sequence
-
-
-
non_terminal_indicator_list ::=
-
"[" non_terminal_indicator_sequence "]"
-
-
-
non_terminal_indicator ::=
-
functor "//" arity
-
-
-
predicate_mode_term ::=
-
atom "(" mode_terms ")"
-
-
-
non_terminal_mode_term ::=
-
atom "(" mode_terms ")"
-
-
-
mode_terms ::=
-
mode_term |
-
mode_term "," mode_terms
-
-
-
mode_term ::=
-
"@" [type] | "+" [type] | "-" [type] | "?" [type]
-
-
-
type ::=
-
prolog_type | logtalk_type | user_defined_type
-
-
-
prolog_type ::=
-
"term" | "nonvar" | "var" |
-
"compound" | "ground" | "callable" | "list" |
-
"atomic" | "atom" |
-
"number" | "integer" | "float"
-
-
-
logtalk_type ::=
-
"object" | "category" | "protocol" |
-
"event"
-
-
-
user_defined_type ::=
-
atom |
-
compound
-
-
-
number_of_solutions ::=
-
"zero" | "zero_or_one" | "zero_or_more" | "one" | "one_or_more" | "error"
-
-
-
meta_predicate_mode_indicator ::=
-
atom "(" meta_predicate_terms ")"
-
-
-
meta_predicate_terms ::=
-
meta_predicate_term |
-
meta_predicate_term "," meta_predicate_terms
-
-
-
meta_predicate_term ::=
-
"::" | "*" | integer
-
-
-
info_list ::=
-
"[]" |
-
"[" info_item "is" nonvar "|" info_list "]"
-
-
-
info_item ::=
-
"comment" | "remarks" |
-
"author" | "version" | "date" |
-
"copyright" | "license" |
-
"parameters" | "parnames" |
-
"arguments" | "argnames" |
-
"definition" | "redefinition" | "allocation" |
-
"examples" | "exceptions" |
-
atom
-
- - -

Clauses and goals

- -
-
goal ::=
-
message_call |
-
external_call |
-
callable
-
-
-
message_call ::=
-
message_to_object |
-
message_to_self |
-
message_to_super
-
-
-
message_to_object ::=
-
receivers "::" messages
-
-
-
message_to_self ::=
-
"::" messages
-
-
-
message_to_super ::=
-
"^^" message
-
-
-
messages ::=
-
message |
-
"(" message "," messages ")" |
-
"(" message ";" messages ")"
-
-
-
message ::=
-
callable |
-
variable
-
-
-
receivers ::=
-
receiver |
-
"(" receiver "," receivers ")" |
-
"(" receiver ";" receivers ")"
-
-
-
receiver ::=
-
object_identifier |
-
variable
-
-
-
external_call ::=
-
"{" callable "}"
-
- -

Entity properties

- -
-
category_property ::=
-
"static" |
-
"dynamic" |
-
"built_in" |
-
"synchronized"
-
-
-
object_property ::=
-
"static" |
-
"dynamic" |
-
"built_in" |
-
"synchronized" |
-
"threaded"
-
-
-
protocol_property ::=
-
"static" |
-
"dynamic" |
-
"built_in"
-
- - -

Predicate properties

- -
-
predicate_property ::=
-
"static" |
-
"dynamic" |
-
"private" |
-
"protected" |
-
"public" |
-
"synchronized" |
-
"built_in" |
-
"declared_in(" entity_identifier ")" |
-
"defined_in(" object_identifier | category_identifier ")" |
-
"meta_predicate(" meta_predicate_mode_indicator ")" |
-
"alias(" callable ")" |
-
"non_terminal(" non_terminal_indicator ")"
-
- - - - - - diff --git a/Logtalk/manuals/refman/index.html b/Logtalk/manuals/refman/index.html deleted file mode 100644 index a1fb6f537..000000000 --- a/Logtalk/manuals/refman/index.html +++ /dev/null @@ -1,320 +0,0 @@ - - - - - - - - Logtalk reference manual: index - - - - - - -
Logtalk reference manual
-
Glossary
-
-
- - -

Reference Manual

- -

Grammar

- -
-
Compilation units
-
Object definition
-
Category definition
-
Protocol definition
-
- -
-
Entity relations
-
Implemented protocols
-
Extended protocols
-
Imported categories
-
Extended objects
-
Instantiated objects
-
Specialized objects
-
Entity scope
-
- -
-
Entity identifiers
-
Object identifiers
-
Category identifiers
-
Protocol identifiers
-
- -
-
Source file names
-
- -
-
Directives
-
Object directives
-
Category directives
-
Protocol directives
-
Predicate directives
-
- -
-
Clauses
-
- -
-
Entity properties
-
- -
-
Predicate properties
-
- -

Directives

- -

Source file directives

- -
-
encoding/1
-
- -

Entity directives

- -
-
calls/1
-
category/1-3
-
dynamic/0
-
end_category/0
-
end_object/0
-
end_protocol/0
-
info/1
-
initialization/1
-
object/1-5
-
protocol/1-2
-
synchronized/0
-
threaded/0
-
uses/1
-
- -

Predicate directives

- -
-
alias/3
-
discontiguous/1
-
dynamic/1
-
info/2
-
meta_predicate/1
-
mode/2
-
op/3
-
private/1
-
protected/1
-
public/1
-
synchronized/1
-
uses/2
-
- -

Built-in predicates

- -

Enumerating objects, categories and protocols

- -
-
current_category/1
-
current_object/1
-
current_protocol/1
-
- -

Enumerating objects, categories and protocols properties

- -
-
category_property/2
-
object_property/2
-
protocol_property/2
-
- -

Creating new objects, categories and protocols

- -
-
create_category/4
-
create_object/4
-
create_protocol/3
-
- -

Abolishing objects, categories and protocols

- -
-
abolish_category/1
-
abolish_object/1
-
abolish_protocol/1
-
- -

Objects, categories and protocols relations

- -
-
extends_object/2-3
-
extends_protocol/2-3
-
implements_protocol/2-3
-
imports_category/2-3
-
instantiates_class/2-3
-
specializes_class/2-3
-
- -

Event handling

- -
-
abolish_events/5
-
current_event/5
-
define_events/5
-
- -

Multi-threading meta-predicates

- -
-
threaded/1
-
-
-
threaded_call/1-2
-
threaded_once/1-2
-
threaded_ignore/1
-
-
-
threaded_exit/1-2
-
threaded_peek/1-2
-
-
-
threaded_wait/1
-
threaded_notify/1
-
- -

Compiling and loading objects, categories and protocols

- -
-
logtalk_compile/1
-
logtalk_compile/2
-
logtalk_load/1
-
logtalk_load/2
-
logtalk_library_path/2
-
- -

Flags

- -
-
current_logtalk_flag/2
-
set_logtalk_flag/2
-
- -

Others

- -
-
forall/2
-
retractall/1
-
- -

Built-in methods

- -

Execution context methods

- -
-
parameter/2
-
self/1
-
sender/1
-
this/1
-
- -

Reflection methods

- -
-
current_predicate/1
-
predicate_property/2
-
- -

Database methods

- -
-
abolish/1
-
asserta/1
-
assertz/1
-
clause/2
-
retract/1
-
retractall/1
-
- -

Meta-call methods

- -
-
call/N
-
- -

All solutions methods

- -
-
bagof/3
-
findall/3
-
forall/2
-
setof/3
-
- -

Event handler methods

- -
-
before/3
-
after/3
-
- -

DCG rules parsing methods

- -
-
phrase/2
-
phrase/3
-
- -

Term expansion methods

- -
-
expand_term/2
-
term_expansion/2
-
- -

Control constructs

- -

Message sending

- -
-
::/2
-
::/1
-
^^/1
-
- -

Calling external code

- -
-
{}/1
-
- -

Context-switching calls

- -
-
<</2
-
- -

Direct calls of category predicates

- -
-
:/1
-
- - - - - - diff --git a/Logtalk/manuals/refman/methods.header b/Logtalk/manuals/refman/methods.header deleted file mode 100644 index 7def820aa..000000000 --- a/Logtalk/manuals/refman/methods.header +++ /dev/null @@ -1,2 +0,0 @@ - -

Built-in methods

diff --git a/Logtalk/manuals/refman/methods/abolish1.html b/Logtalk/manuals/refman/methods/abolish1.html deleted file mode 100644 index 898ac8eae..000000000 --- a/Logtalk/manuals/refman/methods/abolish1.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - Logtalk built-in method: abolish/1 - - - - - - -
Logtalk reference manual
-
Built-in method: abolish/1
-
-
- - -

abolish/1

- -

Description

- -
abolish(Predicate)
-abolish(Functor/Arity)
-

-Removes a runtime declared dynamic predicate from an object database. -

- -

Template and modes

- -
abolish(+predicate_indicator)
- -

Errors

- -
-
Predicate is a variable:
-
instantiation_error
-
Functor is a variable:
-
instantiation_error
-
Arity is a variable:
-
instantiation_error
-
Predicate is neither a variable nor a valid predicate indicator:
-
type_error(predicate_indicator, Predicate)
-
Functor is neither a variable nor an atom:
-
type_error(atom, Functor)
-
Arity is neither a variable nor an integer:
-
type_error(integer, Arity)
-
Predicate is statically declared:
-
permission_error(modify, predicate_declaration, Functor/Arity)
-
Predicate is a private predicate:
-
permission_error(modify, private_predicate, Functor/Arity)
-
Predicate is a protected predicate:
-
permission_error(modify, protected_predicate, Functor/Arity)
-
Predicate is a static predicate:
-
permission_error(modify, static_predicate, Functor/Arity)
-
Predicate is not declared for the object receiving the message:
-
existence_error(predicate_declaration, Functor/Arity)
-
- -

Examples

- -
-
To abolish any dynamic predicate in this:
-
abolish(Predicate)
-
To abolish a public or protected dynamic predicate in self:
-
::abolish(Predicate)
-
To abolish a public dynamic predicate in an object:
-
Object::abolish(Predicate)
-
- - - - - - diff --git a/Logtalk/manuals/refman/methods/after3.html b/Logtalk/manuals/refman/methods/after3.html deleted file mode 100644 index a352d33e8..000000000 --- a/Logtalk/manuals/refman/methods/after3.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - Logtalk built-in method: after/3 - - - - - - -
Logtalk reference manual
-
Built-in method: after/3
-
-
- - -

after/3

- -

Description

- -
after(Object, Message, Sender)
-

-User-defined public method for handling after events. This method is declared in the monitoring built-in protocol. -

- -

Template and modes

- -
after(?object_identifier, ?callable, ?object_identifier)
- -

Errors

- -
-

- (none) -

-
- -

Examples

- -
after(Object, Message, Sender) :-
-    writeq(Object), write('::'), writeq(Message),
-    write(' from '), writeq(Sender), nl.
- - - - - - - diff --git a/Logtalk/manuals/refman/methods/asserta1.html b/Logtalk/manuals/refman/methods/asserta1.html deleted file mode 100644 index 0a36fded1..000000000 --- a/Logtalk/manuals/refman/methods/asserta1.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - Logtalk built-in method: asserta/1 - - - - - - -
Logtalk reference manual
-
Built-in method: asserta/1
-
-
- - -

asserta/1

- -

Description

- -
asserta(Head)
-asserta((Head:-Body))
-

- Asserts a clause as the first one for an object's dynamic predicate. If the predicate is not already declared, then a dynamic predicate declaration is added to the object. -

- -

Template and modes

- -
asserta(+clause)
- -

Errors

- -
-
Head is a variable:
-
instantiation_error
-
Head is a neither a variable nor a callable term:
-
type_error(callable, Head)
-
Body cannot be converted to a goal:
-
type_error(callable, Body)
-
The predicate indicator of Head is that of a private predicate:
-
permission_error(modify, private_predicate, Head)
-
The predicate indicator of Head is that of a protected predicate:
-
permission_error(modify, protected_predicate, Head)
-
The predicate indicator of Head is that of a static predicate:
-
permission_error(modify, static_predicate, Head)
-
- -

Examples

- -
-
To assert a clause as the first one for any dynamic predicate in this:
-
asserta(Clause)
-
To assert a clause as the first one for any public or protected dynamic predicate in self:
-
::asserta(Clause)
-
To assert a clause as the first one for any public dynamic predicate in an object:
-
Object::asserta(Clause)
-
- - - - - - diff --git a/Logtalk/manuals/refman/methods/assertz1.html b/Logtalk/manuals/refman/methods/assertz1.html deleted file mode 100644 index 8ecf329d2..000000000 --- a/Logtalk/manuals/refman/methods/assertz1.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - Logtalk built-in method: assertz/1 - - - - - - -
Logtalk reference manual
-
Built-in method: assertz/1
-
-
- - -

assertz/1

- -

Description

- -
assertz(Head)
-assertz((Head:-Body))
-

- Asserts a clause as the last one for an object's dynamic predicate. If the predicate is not already declared, then a dynamic predicate declaration is added to the object. -

- -

Template and modes

- -
assertz(+clause)
- -

Errors

- -
-
Head is a variable:
-
instantiation_error
-
Head is a neither a variable nor a callable term:
-
type_error(callable, Head)
-
Body cannot be converted to a goal:
-
type_error(callable, Body)
-
The predicate indicator of Head is that of a private predicate:
-
permission_error(modify, private_predicate, Head)
-
The predicate indicator of Head is that of a protected predicate:
-
permission_error(modify, protected_predicate, Head)
-
The predicate indicator of Head is that of a static predicate:
-
permission_error(modify, static_predicate, Head)
-
- -

Examples

- -
-
To assert a clause as the last one for any dynamic predicate in this:
-
assertz(Clause)
-
To assert a clause as the last one for any public or protected dynamic predicate in self:
-
::assertz(Clause)
-
To assert a clause as the last one for any public dynamic predicate in an object:
-
Object::assertz(Clause)
-
- - - - - - diff --git a/Logtalk/manuals/refman/methods/bagof3.html b/Logtalk/manuals/refman/methods/bagof3.html deleted file mode 100644 index 7b6da6906..000000000 --- a/Logtalk/manuals/refman/methods/bagof3.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - Logtalk built-in method: bagof/3 - - - - - - -
Logtalk reference manual
-
Built-in method: bagof/3
-
-
- - -

bagof/3

- -

Description

- -
bagof(Term, Goal, List)
-

- (see the Prolog ISO standard definition) -

- -

Template and modes

- -
bagof(@term, +callable, -list)
- -

Errors

- -
-

- (see the Prolog ISO standard) -

-
- -

Examples

- -
-
To find all solutions in this:
-
bagof(Term, Goal, List)
-
To find all solutions in self:
-
bagof(Term, ::Goal, List)
-
To find all solutions in an object:
-
bagof(Term, Object::Goal, List)
-
- - - - - - diff --git a/Logtalk/manuals/refman/methods/before3.html b/Logtalk/manuals/refman/methods/before3.html deleted file mode 100644 index e6d681681..000000000 --- a/Logtalk/manuals/refman/methods/before3.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - Logtalk built-in method: before/3 - - - - - - -
Logtalk reference manual
-
Built-in method: before/3
-
-
- - -

before/3

- -

Description

- -
before(Object, Message, Sender)
-

-User-defined public method for handling before events. This method is declared in the monitoring built-in protocol. -

- -

Template and modes

- -
before(?object_identifier, ?callable, ?object_identifier)
- -

Errors

- -
-

- (none) -

-
- -

Examples

- -
before(Object, Message, Sender) :-
-    writeq(Object), write('::'), writeq(Message),
-    write(' from '), writeq(Sender), nl.
- - - - - - diff --git a/Logtalk/manuals/refman/methods/call1.html b/Logtalk/manuals/refman/methods/call1.html deleted file mode 100644 index b07f23324..000000000 --- a/Logtalk/manuals/refman/methods/call1.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - Logtalk built-in method: call/N - - - - - - -
Logtalk reference manual
-
Built-in method: call/N
-
-
- - -

call/N

- -

Description

- -
call(Closure, Arg)
-call(Closure, Arg1, Arg2)
-...
-

-Calls a goal constructed by appending additional arguments to a closure. The upper limit for N depends on the upper limit for the arity of a compound term of the back-end Prolog compiler. -

- -

Template and modes

- -
call(+callable, ?term)
-call(+callable, ?term, ?term)
-...
- -

Errors

- -
-
Closure is a variable:
-
instantiation_error
-
Closure is neither a variable nor a callable term:
-
type_error(callable, Closure)
-
- -

Examples

- -
-
Call a goal in this constructed by appending addtional arguments to a closure:
-
call(Closure, Arg1, Arg2, ...)
-
Call a goal in self constructed by appending addtional arguments to a closure:
-
::call(Closure, Arg1, Arg2, ...)
-
Call a goal in an object constructed by appending addtional arguments to a closure:
-
Object::call(Closure, Arg1, Arg2, ...)
-
- - - - - - diff --git a/Logtalk/manuals/refman/methods/clause2.html b/Logtalk/manuals/refman/methods/clause2.html deleted file mode 100644 index c505a2d50..000000000 --- a/Logtalk/manuals/refman/methods/clause2.html +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - Logtalk built-in method: clause/2 - - - - - - -
Logtalk reference manual
-
Built-in method: clause/2
-
-
- - -

clause/2

- -

Description

- -
clause(Head, Body)
-

-Enumerates, by backtracking, the clauses of an object's dynamic predicates. -

- -

Template and modes

- -
clause(+callable, ?body)
- -

Errors

- -
-
Head is a variable:
-
instantiation_error
-
Head is a neither a variable nor a callable term:
-
type_error(callable, Head)
-
Body is a neither a variable nor a callable term:
-
type_error(callable, Body)
-
The predicate indicator of Head is that of a private predicate:
-
permission_error(access, private_predicate, Head)
-
The predicate indicator of Head is that of a protected predicate:
-
permission_error(access, protected_predicate, Head)
-
The predicate indicator of Head is that of a static predicate:
-
permission_error(access, static_predicate, Head)
-
Head is not a declared predicate:
-
existence_error(predicate_declaration, Head)
-
- -

Examples

- -
-
To retrieve a matching clause of any dynamic predicate in this:
-
clause(Head, Body)
-
To retrieve a matching clause of a public or protected dynamic predicate in self:
-
::clause(Head, Body)
-
To retrieve a matching clause of a public dynamic predicate in an object:
-
Object::clause(Head, Body)
-
- - - - - - diff --git a/Logtalk/manuals/refman/methods/current_predicate1.html b/Logtalk/manuals/refman/methods/current_predicate1.html deleted file mode 100644 index 14ffed1a5..000000000 --- a/Logtalk/manuals/refman/methods/current_predicate1.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - Logtalk built-in method: current_predicate/1 - - - - - - -
Logtalk reference manual
-
Built-in method: current_predicate/1
-
-
- - -

current_predicate/1

- -

Description

- -
current_predicate(Predicate)
-

- Enumerates, by backtracking, the visible user predicates for an object. -

- -

Template and modes

- -
current_predicate(?predicate_indicator)
- -

Errors

- -
-
Predicate is neither a variable nor a valid predicate indicator:
-
type_error(predicate_indicator, Predicate)
-
- -

Examples

- -
-
To enumerate, by backtracking, the user predicates visible in this:
-
current_predicate(Predicate)
-
To enumerate, by backtracking, the public and protected user predicates visible in self:
-
::current_predicate(Predicate)
-
To enumerate, by backtracking, the public user predicates visible for an object:
-
Object::current_predicate(Predicate)
-
- - - - - - diff --git a/Logtalk/manuals/refman/methods/expand_term2.html b/Logtalk/manuals/refman/methods/expand_term2.html deleted file mode 100644 index d75687c40..000000000 --- a/Logtalk/manuals/refman/methods/expand_term2.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - Logtalk built-in method: expand_term/2 - - - - - - -
Logtalk reference manual
-
Built-in method: expand_term/2
-
-
- - -

expand_term/2

- -

Description

- -
expand_term(Term, Expansion)
-

-Expands a term. The most common use is to expand a grammar rule into a clause. Users may override the default Logtalk grammar rule translator by defining clauses for the predicate term_expansion/2. -

-

-The expansion works as follows: if the first argument is a variable, then it is unified with the second argument; if the first argument is not a variable and clauses for the term_expansion/2 predicate are within scope, then this predicate is called to provide an expansion that is then unified with the second argument; if the term_expansion/2 predicate is not used and the first argument is a compound term with functor -->/2 then the default Logtalk grammar rule translator is used, with the resulting clause being unified with the second argument; when the translator is not used, the two arguments are unified. -

-

-This built-in method may be used to expand a grammar rule into a clause for use with the built-in database methods. -

- -

Template and modes

- -
expand_term(?term, ?term)
- -

Errors

- -
-
(none)
-
- -

Examples

- -
-
(none)
-
- - - - - - diff --git a/Logtalk/manuals/refman/methods/findall3.html b/Logtalk/manuals/refman/methods/findall3.html deleted file mode 100644 index 61fd559a4..000000000 --- a/Logtalk/manuals/refman/methods/findall3.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - Logtalk built-in method: findall/3 - - - - - - -
Logtalk reference manual
-
Built-in method: findall/3
-
-
- - -

findall/3

- -

Description

- -
findall(Term, Goal, List)
-

-(see the Prolog ISO standard definition) -

- -

Template and modes

- -
findall(@term, +callable, -list)
- -

Errors

- -
-

- (see the Prolog ISO standard) -

-
- -

Examples

- -
-
To find all solutions in this:
-
findall(Term, Goal, List)
-
To find all solutions in self:
-
findall(Term, ::Goal, List)
-
To find all solutions in an object:
-
findall(Term, Object::Goal, List)
-
- - - - - - diff --git a/Logtalk/manuals/refman/methods/forall2.html b/Logtalk/manuals/refman/methods/forall2.html deleted file mode 100644 index 369c4d30e..000000000 --- a/Logtalk/manuals/refman/methods/forall2.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - Logtalk built-in method: forall/2 - - - - - - -
Logtalk reference manual
-
Built-in method: forall/2
-
-
- - -

forall/2

- -

Description

- -
forall(Generator, Test)
-

- For all solutions of Generator, Test is true. -

- -

Template and modes

- -
forall(+callable, +callable)
- -

Errors

- -
-
Either Generator or Test is a variable:
-
instantiation_error
-
Generator is neither a variable nor a callable term:
-
type_error(callable, Generator)
-
Test is neither a variable nor a callable term:
-
type_error(callable, Test)
-
- -

Examples

- -
-
To call both goals in this:
-
forall(Generator, Test)
-
To call both goals in self:
-
forall(::Generator, ::Test)
-
To call both goals in an object:
-
forall(Object::Generator, Object::Test)
-
- - - - - - diff --git a/Logtalk/manuals/refman/methods/parameter2.html b/Logtalk/manuals/refman/methods/parameter2.html deleted file mode 100644 index a20cc9469..000000000 --- a/Logtalk/manuals/refman/methods/parameter2.html +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - Logtalk built-in method: parameter/2 - - - - - - -
Logtalk reference manual
-
Built-in method: parameter/2
-
-
- - -

parameter/2

- -

Description

- -
parameter(Number, Term)
-

-Normally used only in parametric objects, this method returns parameter values by using the parameter position in the object identifier. Note that this predicate implies an unification between its second argument and the corresponding implicit context argument in the predicate containing the call. This unification occurs at the clause head, not at the clause body. See also this/1. -

- -

Template and modes

- -
parameter(+integer, ?term)
- -

Errors

- -
-
Number is a variable:
-
instantiation_error
-
Number is neither a variable nor an integer value:
-
type_error(integer, Number)
-
Object identifier is not a compound term:
-
type_error(compound, Object)
-
Number is a negative integer value:
-
domain_error(not_less_than_zero, Number)
-
- -

Examples

- -
:- object(box(_color, _weight)).
-
-    ...
-    
-    color(Color) :-              % this clause is translated into a fact
-        parameter(1, Color).     % upon compilation 
-
-    heavy :-
-        parameter(2, Weight),    % after compilation, the >/2 call will be
-        Weight > 10.             % the first condition on the clause body
-
-    ...
- - - - - - diff --git a/Logtalk/manuals/refman/methods/phrase2.html b/Logtalk/manuals/refman/methods/phrase2.html deleted file mode 100644 index 2be47ff27..000000000 --- a/Logtalk/manuals/refman/methods/phrase2.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - Logtalk built-in method: phrase/2 - - - - - - -
Logtalk reference manual
-
Built-in method: phrase/2
-
-
- - -

phrase/2

- -

Description

- -
phrase(NonTerminal, Input)
-

-True if the list Input can be parsed using the specified non-terminal NonTerminal. This method also accepts grammar rule bodies in the first argument (with the limitation that cuts are only supported in local calls). -

- -

Template and modes

- -
phrase(+callable, ?list)
- -

Errors

- -
-
NonTerminal is a variable:
-
instantiation_error
-
NonTerminal is neither a variable nor a callable term:
-
type_error(callable, NonTerminal)
-
Input is neither a partial list nor a list:
-
type_error(list, Input)
-
The grammar rule non-terminal NonTerminal is private:
-
permission_error(access, private_non_terminal, NonTerminal)
-
The grammar rule non-terminal NonTerminal is protected:
-
permission_error(access, protected_non_terminal, NonTerminal)
-
The grammar rule non-terminal NonTerminal is not declared:
-
existence_error(non_terminal_declaration, NonTerminal)
-
- -

Examples

- -
| ?- sentence::phrase(sentence, [the, girl, likes, the, boy]).
-
-yes
-
-
-| ?- calculator::phrase(expr(Value), "1+2-3*4").
-
-Value = -9
-yes
- - - - - - diff --git a/Logtalk/manuals/refman/methods/phrase3.html b/Logtalk/manuals/refman/methods/phrase3.html deleted file mode 100644 index aa9a5c536..000000000 --- a/Logtalk/manuals/refman/methods/phrase3.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - Logtalk built-in method: phrase/3 - - - - - - -
Logtalk reference manual
-
Built-in method: phrase/3
-
-
- - -

phrase/3

- -

Description

- -
phrase(NonTerminal, Input, Rest)
-

- True if the list Input can be parsed using the specified non-terminal NonTerminal. The list Rest is what remains of the list Input after parsing succeeded. This method also accepts grammar rule bodies in the first argument (with the limitation that cuts are only supported in local calls). -

- -

Template and modes

- -
phrase(+callable, ?list, ?list)
- -

Errors

- -
-
NonTerminal is a variable:
-
instantiation_error
-
NonTerminal is neither a variable nor a callable term:
-
type_error(callable, NonTerminal)
-
Input is neither a partial list nor a list:
-
type_error(list, Input)
-
Rest is neither a partial list nor a list:
-
type_error(list, Rest)
-
The grammar rule non-terminal NonTerminal is private:
-
permission_error(access, private_non_terminal, NonTerminal)
-
The grammar rule non-terminal NonTerminal is protected:
-
permission_error(access, protected_non_terminal, NonTerminal)
-
The grammar rule non-terminal NonTerminal is not declared:
-
existence_error(non_terminal_declaration, NonTerminal)
-
- -

Examples

- -
| ?- sentence::phrase(noun_phrase, [the, girl, likes, the, boy], Rest).
-
-Rest = [likes, the, boy]
-yes
- - - - - - diff --git a/Logtalk/manuals/refman/methods/predicate_property2.html b/Logtalk/manuals/refman/methods/predicate_property2.html deleted file mode 100644 index 2fc96fa26..000000000 --- a/Logtalk/manuals/refman/methods/predicate_property2.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - Logtalk built-in method: predicate_property/2 - - - - - - -
Logtalk reference manual
-
Built-in method: predicate_property/2
-
-
- - -

predicate_property/2

- -

Description

- -
predicate_property(Predicate, Property)
-

-Enumerates, by backtracking, the properties of a visible predicate. -

- -

Template and modes

- -
predicate_property(+callable, ?predicate_property)
- -

Errors

- -
-
Predicate is a variable:
-
instantiation_error
-
Predicate is neither a variable nor a callable term:
-
type_error(callable, Predicate)
-
Property is neither a variable nor a valid predicate property:
-
domain_error(predicate_property, Property)
-
- -

Examples

- -
-
To enumerate, by backtracking, the properties of a predicate visible in this:
-
predicate_property(foo(_), Property)
-
To enumerate, by backtracking, the properties of a public or protected predicate visible in self:
-
::predicate_property(foo(_), Property)
-
To enumerate, by backtracking, the properties of a public predicate visible in an object:
-
Object::predicate_property(foo(_), Property)
-
- - - - - - diff --git a/Logtalk/manuals/refman/methods/retract1.html b/Logtalk/manuals/refman/methods/retract1.html deleted file mode 100644 index 40cc93528..000000000 --- a/Logtalk/manuals/refman/methods/retract1.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - Logtalk built-in method: retract/1 - - - - - - -
Logtalk reference manual
-
Built-in method: retract/1
-
-
- - -

retract/1

- -

Description

- -
retract(Clause)
-retract((Head:-Body))
-

- Retracts a dynamic clause from an object. -

- -

Template and modes

- -
retract(+clause)
- -

Errors

- -
-
Head is a variable:
-
instantiation_error
-
Head is neither a variable nor a callable term:
-
type_error(callable, Head)
-
The predicate indicator of Head is that of a private predicate:
-
permission_error(modify, private_predicate, Head)
-
The predicate indicator of Head is that of a protected predicate:
-
permission_error(modify, protected_predicate, Head)
-
The predicate indicator of Head is that of a static predicate:
-
permission_error(modify, static_predicate, Head)
-
The predicate indicator of Head is not declared:
-
existence_error(predicate_declaration, Head)
-
- -

Examples

- -
-
To retract a matching clause of any dynamic predicate in this:
-
retract(Clause)
-
To retract a matching clause of a public or protected dynamic predicate in self:
-
::retract(Clause)
-
To retract a matching clause of a public dynamic predicate in an object:
-
Object::retract(Clause)
-
- - - - - - diff --git a/Logtalk/manuals/refman/methods/retractall1.html b/Logtalk/manuals/refman/methods/retractall1.html deleted file mode 100644 index bb59562f9..000000000 --- a/Logtalk/manuals/refman/methods/retractall1.html +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - Logtalk built-in method: retractall/1 - - - - - - -
Logtalk reference manual
-
Built-in method: retractall/1
-
-
- - -

retractall/1

- -

Description

- -
retractall(Head)
-

-Retracts all matching predicates from an object. -

- -

Template and modes

- -
retractall(+callable)
- -

Errors

- -
-
Head is a variable:
-
instantiation_error
-
Head is neither a variable nor a callable term:
-
type_error(callable, Head)
-
The predicate indicator of Head is that of a private predicate:
-
permission_error(modify, private_predicate, Head)
-
The predicate indicator of Head is that of a protected predicate:
-
permission_error(modify, protected_predicate, Head)
-
The predicate indicator of Head is that of a static predicate:
-
permission_error(modify, static_predicate, Head)
-
The predicate indicator of Head is not declared:
-
existence_error(predicate_declaration, Head)
-
- -

Examples

- -
-
To retract all matching predicate definitions in this:
-
retractall(Head)
-
To retract all matching public or protected predicate definitions in self:
-
::retractall(Head)
-
To retract all matching public predicate definitions in an object:
-
Object::retractall(Head)
-
- - - - - - diff --git a/Logtalk/manuals/refman/methods/self1.html b/Logtalk/manuals/refman/methods/self1.html deleted file mode 100644 index e9f80ed94..000000000 --- a/Logtalk/manuals/refman/methods/self1.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - Logtalk built-in method: self/1 - - - - - - -
Logtalk reference manual
-
Built-in method: self/1
-
-
- - -

self/1

- -

Description

- -
self(Self)
-

- Returns the object that has received the message under processing. Note that this predicate implies an instantiation between its argument and the corresponding implicit context argument in the predicate containing the call. This instantiation occurs at the clause head, not at the clause body. -

- -

Template and modes

- -
self(?object_identifier)
- -

Errors

- -
-

- (none) -

-
- -

Examples

- -
test :-
-    self(Self),                                   % after compilation, the write/1
-    write('executing a method in behalf of '),    % call will be the first goal on
-    writeq(Self), nl.                             % the clause body
- - - - - - diff --git a/Logtalk/manuals/refman/methods/sender1.html b/Logtalk/manuals/refman/methods/sender1.html deleted file mode 100644 index 8fd5683a0..000000000 --- a/Logtalk/manuals/refman/methods/sender1.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - Logtalk built-in method: sender/1 - - - - - - -
Logtalk reference manual
-
Built-in method: sender/1
-
-
- - -

sender/1

- -

Description

- -
sender(Sender)
-

- Returns the object that has sent the message under processing. Note that this predicate implies an instantiation between its argument and the corresponding implicit context argument in the predicate containing the call. This instantiation occurs at the clause head, not at the clause body. -

- -

Template and modes

- -
sender(?object_identifier)
- -

Errors

- -
-

- (none) -

-
- -

Examples

- -
% after compilation, the write/1 call will be the first goal on the clause body:
-
-test :-
-    sender(Sender),
-    write('executing a method to answer a message sent by '),
-    writeq(Sender), nl.
- - - - - - diff --git a/Logtalk/manuals/refman/methods/setof3.html b/Logtalk/manuals/refman/methods/setof3.html deleted file mode 100644 index a9e30bb78..000000000 --- a/Logtalk/manuals/refman/methods/setof3.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - Logtalk built-in method: setof/3 - - - - - - -
Logtalk reference manual
-
Built-in method: setof/3
-
-
- - -

setof/3

- -

Description

- -
setof(Term, Goal, List)
-

- (see the Prolog ISO standard definition) -

- -

Template and modes

- -
setof(@term, +callable, -list)
- -

Errors

- -
-

- (see the Prolog ISO standard) -

-
- -

Examples

- -
-
To find all solutions in this:
-
setof(Term, Goal, List)
-
To find all solutions in self:
-
setof(Term, ::Goal, List)
-
To find all solutions in an object:
-
setof(Term, Object::Goal, List)
-
- - - - - - diff --git a/Logtalk/manuals/refman/methods/term_expansion2.html b/Logtalk/manuals/refman/methods/term_expansion2.html deleted file mode 100644 index bc5749acd..000000000 --- a/Logtalk/manuals/refman/methods/term_expansion2.html +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - Logtalk built-in method: term_expansion/2 - - - - - - -
Logtalk reference manual
-
Built-in method: term_expansion/2
-
-
- - -

term_expansion/2

- -

Description

- -
term_expansion(Term, Expansion)
-

-Defines an expansion for a term. This predicate, when defined, is automatically called by the expand_term/2 method. Use of this predicate by the expand_term/2 method may be restricted by using a scope directive for it. The term_expansion/2 clauses are only used by the expand_term/2 method if they are within the scope of the sender. When that is not the case, the expand_term/2 method only uses the default expansions. -

- -

Template and modes

- -
term_expansion(?term, ?term)
- -

Errors

- -
-
(none)
-
- -

Examples

- -
-
(none)
-
- - - - - - diff --git a/Logtalk/manuals/refman/methods/this1.html b/Logtalk/manuals/refman/methods/this1.html deleted file mode 100644 index 60deb47e2..000000000 --- a/Logtalk/manuals/refman/methods/this1.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - Logtalk built-in method: this/1 - - - - - - -
Logtalk reference manual
-
Built-in method: this/1
-
-
- - -

this/1

- -

Description

- -
this(This)
-

- Unifies its argument with the identifier of the object that contains the predicate clause that is being used. Note that this predicate implies an instantiation between its argument and the corresponding implicit context argument in the predicate containing the call. This instantiation occurs at the clause head, not at the clause body. This method is useful in avoiding problems when an object is renamed or when using parametric objects. Can also be used to retrieve runtime parametric object parameters through unification (see also parameter/2). -

- -

Template and modes

- -
this(?object_identifier)
- -

Errors

- -
-

- (none) -

-
- -

Examples

- -
% after compilation, the write/1 call will be the first goal on the clause body:
-
-test :-
-    this(This),
-    write('executing a definition contained in '),
-    writeq(This), nl.
- - - - - - diff --git a/Logtalk/manuals/refman/refman.body b/Logtalk/manuals/refman/refman.body deleted file mode 100644 index 643604c3f..000000000 --- a/Logtalk/manuals/refman/refman.body +++ /dev/null @@ -1,4 +0,0 @@ - - - -
diff --git a/Logtalk/manuals/refman/refman.footer b/Logtalk/manuals/refman/refman.footer deleted file mode 100644 index 087168854..000000000 --- a/Logtalk/manuals/refman/refman.footer +++ /dev/null @@ -1,6 +0,0 @@ - -
- - - - diff --git a/Logtalk/manuals/refman/refman.header b/Logtalk/manuals/refman/refman.header deleted file mode 100644 index c000e3d3c..000000000 --- a/Logtalk/manuals/refman/refman.header +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - Logtalk: Reference Manual - - - - - - -
-
- -
Logtalk reference manual
-
Contents
-
-
- -
Logtalk reference manual
-
-
-
- -
-

Logtalk 2.30.7

-

Reference Manual

-

Copyright © Paulo Moura

-

- pmoura@logtalk.org -
- http://logtalk.org/ -

-

Last updated on October 24, 2007

-
- -
diff --git a/Logtalk/manuals/refman/refman.sh b/Logtalk/manuals/refman/refman.sh deleted file mode 100755 index 8b0649c08..000000000 --- a/Logtalk/manuals/refman/refman.sh +++ /dev/null @@ -1,228 +0,0 @@ -#!/bin/bash - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -css2xslfo=/Applications/XML/CSSToXSLFO/css2xslfo1_5_1.jar - -xslt_proc=xsltproc -# xslt_proc=xalan -# xslt_proc=sabcmd - -#fo_proc=fop -fo_proc=xep -# fo_proc=xinc - -# rm -f refman.fo refman.html -rm -f *.section directives/*.section builtins/*.section methods/*.section control/*.section - -eval $xslt_proc -o index.section refman.xsl index.html -eval $xslt_proc -o grammar.section refman.xsl grammar.html -eval $xslt_proc -o directives/encoding1.section refman.xsl directives/encoding1.html -eval $xslt_proc -o directives/calls1.section refman.xsl directives/calls1.html -eval $xslt_proc -o directives/category1_3.section refman.xsl directives/category1_3.html -eval $xslt_proc -o directives/dynamic0.section refman.xsl directives/dynamic0.html -eval $xslt_proc -o directives/end_category0.section refman.xsl directives/end_category0.html -eval $xslt_proc -o directives/end_object0.section refman.xsl directives/end_object0.html -eval $xslt_proc -o directives/end_protocol0.section refman.xsl directives/end_protocol0.html -eval $xslt_proc -o directives/info1.section refman.xsl directives/info1.html -eval $xslt_proc -o directives/initialization1.section refman.xsl directives/initialization1.html -eval $xslt_proc -o directives/object1_5.section refman.xsl directives/object1_5.html -eval $xslt_proc -o directives/protocol1_2.section refman.xsl directives/protocol1_2.html -eval $xslt_proc -o directives/synchronized0.section refman.xsl directives/synchronized0.html -eval $xslt_proc -o directives/threaded0.section refman.xsl directives/threaded0.html -eval $xslt_proc -o directives/uses1.section refman.xsl directives/uses1.html -eval $xslt_proc -o directives/alias3.section refman.xsl directives/alias3.html -eval $xslt_proc -o directives/discontiguous1.section refman.xsl directives/discontiguous1.html -eval $xslt_proc -o directives/dynamic1.section refman.xsl directives/dynamic1.html -eval $xslt_proc -o directives/info2.section refman.xsl directives/info2.html -eval $xslt_proc -o directives/meta_predicate1.section refman.xsl directives/meta_predicate1.html -eval $xslt_proc -o directives/mode2.section refman.xsl directives/mode2.html -eval $xslt_proc -o directives/op3.section refman.xsl directives/op3.html -eval $xslt_proc -o directives/private1.section refman.xsl directives/private1.html -eval $xslt_proc -o directives/protected1.section refman.xsl directives/protected1.html -eval $xslt_proc -o directives/public1.section refman.xsl directives/public1.html -eval $xslt_proc -o directives/synchronized1.section refman.xsl directives/synchronized1.html -eval $xslt_proc -o directives/uses2.section refman.xsl directives/uses2.html -eval $xslt_proc -o builtins/current_category1.section refman.xsl builtins/current_category1.html -eval $xslt_proc -o builtins/current_object1.section refman.xsl builtins/current_object1.html -eval $xslt_proc -o builtins/current_protocol1.section refman.xsl builtins/current_protocol1.html -eval $xslt_proc -o builtins/category_property2.section refman.xsl builtins/category_property2.html -eval $xslt_proc -o builtins/object_property2.section refman.xsl builtins/object_property2.html -eval $xslt_proc -o builtins/protocol_property2.section refman.xsl builtins/protocol_property2.html -eval $xslt_proc -o builtins/create_category4.section refman.xsl builtins/create_category4.html -eval $xslt_proc -o builtins/create_object4.section refman.xsl builtins/create_object4.html -eval $xslt_proc -o builtins/create_protocol3.section refman.xsl builtins/create_protocol3.html -eval $xslt_proc -o builtins/abolish_category1.section refman.xsl builtins/abolish_category1.html -eval $xslt_proc -o builtins/abolish_object1.section refman.xsl builtins/abolish_object1.html -eval $xslt_proc -o builtins/abolish_protocol1.section refman.xsl builtins/abolish_protocol1.html -eval $xslt_proc -o builtins/extends_object2_3.section refman.xsl builtins/extends_object2_3.html -eval $xslt_proc -o builtins/extends_protocol2_3.section refman.xsl builtins/extends_protocol2_3.html -eval $xslt_proc -o builtins/implements_protocol2_3.section refman.xsl builtins/implements_protocol2_3.html -eval $xslt_proc -o builtins/imports_category2_3.section refman.xsl builtins/imports_category2_3.html -eval $xslt_proc -o builtins/instantiates_class2_3.section refman.xsl builtins/instantiates_class2_3.html -eval $xslt_proc -o builtins/specializes_class2_3.section refman.xsl builtins/specializes_class2_3.html -eval $xslt_proc -o builtins/abolish_events5.section refman.xsl builtins/abolish_events5.html -eval $xslt_proc -o builtins/current_event5.section refman.xsl builtins/current_event5.html -eval $xslt_proc -o builtins/define_events5.section refman.xsl builtins/define_events5.html -eval $xslt_proc -o builtins/threaded1.section refman.xsl builtins/threaded1.html -eval $xslt_proc -o builtins/threaded_call1_2.section refman.xsl builtins/threaded_call1_2.html -eval $xslt_proc -o builtins/threaded_once1_2.section refman.xsl builtins/threaded_once1_2.html -eval $xslt_proc -o builtins/threaded_ignore1.section refman.xsl builtins/threaded_ignore1.html -eval $xslt_proc -o builtins/threaded_exit1_2.section refman.xsl builtins/threaded_exit1_2.html -eval $xslt_proc -o builtins/threaded_peek1_2.section refman.xsl builtins/threaded_peek1_2.html -eval $xslt_proc -o builtins/threaded_wait1.section refman.xsl builtins/threaded_wait1.html -eval $xslt_proc -o builtins/threaded_notify1.section refman.xsl builtins/threaded_notify1.html -eval $xslt_proc -o builtins/logtalk_compile1.section refman.xsl builtins/logtalk_compile1.html -eval $xslt_proc -o builtins/logtalk_compile2.section refman.xsl builtins/logtalk_compile2.html -eval $xslt_proc -o builtins/logtalk_load1.section refman.xsl builtins/logtalk_load1.html -eval $xslt_proc -o builtins/logtalk_load2.section refman.xsl builtins/logtalk_load2.html -eval $xslt_proc -o builtins/logtalk_library_path2.section refman.xsl builtins/logtalk_library_path2.html -eval $xslt_proc -o builtins/current_logtalk_flag2.section refman.xsl builtins/current_logtalk_flag2.html -eval $xslt_proc -o builtins/set_logtalk_flag2.section refman.xsl builtins/set_logtalk_flag2.html -eval $xslt_proc -o builtins/forall2.section refman.xsl builtins/forall2.html -eval $xslt_proc -o builtins/retractall1.section refman.xsl builtins/retractall1.html -eval $xslt_proc -o methods/parameter2.section refman.xsl methods/parameter2.html -eval $xslt_proc -o methods/self1.section refman.xsl methods/self1.html -eval $xslt_proc -o methods/sender1.section refman.xsl methods/sender1.html -eval $xslt_proc -o methods/this1.section refman.xsl methods/this1.html -eval $xslt_proc -o methods/current_predicate1.section refman.xsl methods/current_predicate1.html -eval $xslt_proc -o methods/predicate_property2.section refman.xsl methods/predicate_property2.html -eval $xslt_proc -o methods/abolish1.section refman.xsl methods/abolish1.html -eval $xslt_proc -o methods/asserta1.section refman.xsl methods/asserta1.html -eval $xslt_proc -o methods/assertz1.section refman.xsl methods/assertz1.html -eval $xslt_proc -o methods/clause2.section refman.xsl methods/clause2.html -eval $xslt_proc -o methods/retract1.section refman.xsl methods/retract1.html -eval $xslt_proc -o methods/retractall1.section refman.xsl methods/retractall1.html -eval $xslt_proc -o methods/call1.section refman.xsl methods/call1.html -eval $xslt_proc -o methods/bagof3.section refman.xsl methods/bagof3.html -eval $xslt_proc -o methods/findall3.section refman.xsl methods/findall3.html -eval $xslt_proc -o methods/forall2.section refman.xsl methods/forall2.html -eval $xslt_proc -o methods/setof3.section refman.xsl methods/setof3.html -eval $xslt_proc -o methods/before3.section refman.xsl methods/before3.html -eval $xslt_proc -o methods/after3.section refman.xsl methods/after3.html -eval $xslt_proc -o methods/phrase2.section refman.xsl methods/phrase2.html -eval $xslt_proc -o methods/phrase3.section refman.xsl methods/phrase3.html -eval $xslt_proc -o methods/expand_term2.section refman.xsl methods/expand_term2.html -eval $xslt_proc -o methods/term_expansion2.section refman.xsl methods/term_expansion2.html -eval $xslt_proc -o control/to_object2.section refman.xsl control/to_object2.html -eval $xslt_proc -o control/to_self1.section refman.xsl control/to_self1.html -eval $xslt_proc -o control/to_super1.section refman.xsl control/to_super1.html -eval $xslt_proc -o control/external1.section refman.xsl control/external1.html -eval $xslt_proc -o control/context2.section refman.xsl control/context2.html -eval $xslt_proc -o control/direct1.section refman.xsl control/direct1.html - -cat -s \ - refman.header \ - index.section \ - refman.body \ - grammar.section \ - directives.header \ - directives/encoding1.section \ - directives/calls1.section \ - directives/category1_3.section \ - directives/dynamic0.section \ - directives/end_category0.section \ - directives/end_object0.section \ - directives/end_protocol0.section \ - directives/info1.section \ - directives/initialization1.section \ - directives/object1_5.section \ - directives/protocol1_2.section \ - directives/synchronized0.section \ - directives/threaded0.section \ - directives/uses1.section \ - directives/alias3.section \ - directives/discontiguous1.section \ - directives/dynamic1.section \ - directives/info2.section \ - directives/meta_predicate1.section \ - directives/mode2.section \ - directives/op3.section \ - directives/private1.section \ - directives/protected1.section \ - directives/public1.section \ - directives/synchronized1.section \ - directives/uses2.section \ - builtins.header \ - builtins/current_category1.section \ - builtins/current_object1.section \ - builtins/current_protocol1.section \ - builtins/category_property2.section \ - builtins/object_property2.section \ - builtins/protocol_property2.section \ - builtins/create_category4.section \ - builtins/create_object4.section \ - builtins/create_protocol3.section \ - builtins/abolish_category1.section \ - builtins/abolish_object1.section \ - builtins/abolish_protocol1.section \ - builtins/extends_object2_3.section \ - builtins/extends_protocol2_3.section \ - builtins/implements_protocol2_3.section \ - builtins/imports_category2_3.section \ - builtins/instantiates_class2_3.section \ - builtins/specializes_class2_3.section \ - builtins/abolish_events5.section \ - builtins/current_event5.section \ - builtins/define_events5.section \ - builtins/threaded1.section \ - builtins/threaded_call1_2.section \ - builtins/threaded_once1_2.section \ - builtins/threaded_ignore1.section \ - builtins/threaded_exit1_2.section \ - builtins/threaded_peek1_2.section \ - builtins/threaded_wait1.section \ - builtins/threaded_notify1.section \ - builtins/logtalk_compile1.section \ - builtins/logtalk_compile2.section \ - builtins/logtalk_load1.section \ - builtins/logtalk_load2.section \ - builtins/logtalk_library_path2.section \ - builtins/current_logtalk_flag2.section \ - builtins/set_logtalk_flag2.section \ - builtins/forall2.section \ - builtins/retractall1.section \ - methods.header \ - methods/parameter2.section \ - methods/self1.section \ - methods/sender1.section \ - methods/this1.section \ - methods/current_predicate1.section \ - methods/predicate_property2.section \ - methods/abolish1.section \ - methods/asserta1.section \ - methods/assertz1.section \ - methods/clause2.section \ - methods/retract1.section \ - methods/retractall1.section \ - methods/call1.section \ - methods/bagof3.section \ - methods/findall3.section \ - methods/forall2.section \ - methods/setof3.section \ - methods/before3.section \ - methods/after3.section \ - methods/phrase2.section \ - methods/phrase3.section \ - methods/expand_term2.section \ - methods/term_expansion2.section \ - control.header \ - control/to_object2.section \ - control/to_self1.section \ - control/to_super1.section \ - control/external1.section \ - control/context2.section \ - control/direct1.section \ - refman.footer \ - > refman.html - -java -jar $css2xslfo refman.html -fo refman.fo -eval $fo_proc -fo refman.fo -pdf refman.pdf - -# rm refman.fo refman.html -rm -f *.section directives/*.section builtins/*.section methods/*.section control/*.section diff --git a/Logtalk/manuals/refman/refman.xsl b/Logtalk/manuals/refman/refman.xsl deleted file mode 100644 index e919aa450..000000000 --- a/Logtalk/manuals/refman/refman.xsl +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/Logtalk/manuals/screen.css b/Logtalk/manuals/screen.css deleted file mode 100644 index 3cb27fa19..000000000 --- a/Logtalk/manuals/screen.css +++ /dev/null @@ -1,89 +0,0 @@ -body { - color: #353535; - font-size: 11pt; - font-family: verdana, arial, sans-serif; - background: #eee; - margin: 12pt; -} - -.navtop { - font-size: 9pt; - text-align: right; - border-color: #000000; - border-width: 1pt 0pt 0pt 0pt; - border-style: solid; - padding: 3pt 0pt 12pt 0pt; -} - -.toc-top-left, .toc-top-right, .toc-bottom-left, .toc-bottom-right { - display: none; -} - -.top-left, .top-right, .bottom-left, .bottom-right { - display: none; -} - -.footer { - font-size: 9pt; - margin-top: 24pt; - padding: 3pt 0pt 18pt 0pt; - border-width: 1pt 0pt 0pt 0pt; - border-style: solid; -} - -.navbottom { - text-align: right; - float: right; - position: relative; - width: 50%; -} - -.copyright { - text-align: left; - float: left; - position: relative; - width: 50%; -} - -.toc { -} - -.toc-entries { -} - -.leader { - display: none; -} - -.page-ref { - display: none; -} - -a { - text-decoration: none; - color: navy; - outline: none; -} - -a:hover { - text-decoration: underline; - color: blue; -} - -pre, code, .code, .codenp { - color: maroon; - font-family: Monaco, 'Courier New', Courier, monospace; -} - -code { - font-size: 10pt; -} - -pre { - font-size: 10pt; - padding: 6pt 24pt 6pt 24pt; -} - -dl { - padding-left: 2em; -} diff --git a/Logtalk/manuals/styles.css b/Logtalk/manuals/styles.css deleted file mode 100644 index b89ef9736..000000000 --- a/Logtalk/manuals/styles.css +++ /dev/null @@ -1,88 +0,0 @@ -body { - color: #353535; - font-size: 10pt; - font-family: verdana, arial, sans-serif; - background: #ddd; - margin: 12pt -} - -.title { - color: maroon; - font-size: 24pt; - font-family: "Trebuchet MS", Arial, Verdana, Helvetica, sans-serif; - text-align: center; - padding: 0pt 0pt 6pt 0pt; -} - -.topictitle { - color: maroon; - font-size: 12pt; - font-family: "Trebuchet MS", Arial, Verdana, Helvetica, sans-serif; - text-align: left; -} - -.topic { - padding: 0pt 0pt 0pt 24pt; -} - -.spacer { -} - -.navbottom { - font-size: 9pt; - text-align: right; - border-width: 0pt 0pt 1pt 0pt; - border-style: solid; - padding: 12pt 0pt 3pt 0pt; -} - -.navtop { - text-align: right; - font-size: 9pt; - border-color: #000000; - border-width: 1pt 0pt 0pt 0pt; - border-style: solid; - padding: 3pt 0pt 12pt 0pt; -} - -.copyright { - text-align: center; - font-size: 9pt; - padding: 9pt 0pt 9pt 0pt; -} - -.footer { - clear: left; - text-align: right; - font-size: 9pt; - border-color: #000000; - border-width: 1pt 0pt 0pt 0pt; - border-style: solid; - padding: 0pt 0pt 9pt 0pt; -} - -a { - text-decoration: none; - color: navy; - outline: none; -} - -a:hover { - text-decoration: underline; - color: blue; -} - -.bleft { - float: left; - position: relative; -} - -.bright { - float: right; - position: relative; -} - -code, pre { - color: maroon; - font-family: courier, monospace; -} \ No newline at end of file diff --git a/Logtalk/manuals/tutorial/attributes.html b/Logtalk/manuals/tutorial/attributes.html deleted file mode 100644 index c1b738000..000000000 --- a/Logtalk/manuals/tutorial/attributes.html +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - - - Logtalk tutorial: dynamic object attributes - - - - - - -
Logtalk tutorial
-
Dynamic object attributes
-
-
- - -

Dynamic object attributes

- -

-In this example, we will illustrate the use of: -

-
    -
  • categories
  • -
  • category predicates
  • -
  • dynamic predicates
  • -
-

-by defining a category that implements a set of predicates for handling dynamic object attributes. -

- -

Defining a category

- -

-We want to define a set of predicates to handle dynamic object attributes. We need public predicates to set, get, and delete attributes, and a private dynamic predicate to store the attributes values. Let us name these predicates set_attribute/2 and get_attribute/2, for getting and setting an attribute value, del_attribute/2 and del_attributes/2, for deleting attributes, and attribute_/2, for storing the attributes values. -

-

-We do not want to encapsulate these predicates in an object. Why? Because they are a set of useful, closely related, predicates that may be used by several, unrelated, objects. If defined at an object level, we would be constrained to use inheritance in order to have the predicates available to other objects. Furthermore, this could force us to use multi-inheritance or to have some kind of generic root object containing all kinds of possible useful predicates. -

-

-For this kind of situation, Logtalk enables the programmer to encapsulate the predicates in a category, so that they can be used in any object. A category is a Logtalk entity, at the same level as objects and protocols. It can contain predicates directives and/or definitions. Category predicates can be imported by any object, without code duplication and without resorting to inheritance. -

-

-When defining category predicates, we need to remember that a category can be imported by more than one object. Because of that, the calls to the built-in methods that handle the private dynamic predicate (like assertz/1 or retract/1) must be made using the message to self control structure, ::/1. This way, we ensure that when we call one of the attribute predicates on an object, the object own definition of attribute_/2 will be used. The predicates definitions are straightforward: -

-
:- category(attributes).
-
-    :- public(set_attribute/2).
-    :- mode(set_attribute(+nonvar, +nonvar), one).
-
-    :- public(get_attribute/2).
-    :- mode(get_attribute(?nonvar, ?nonvar), zero_or_more).
-
-    :- public(del_attribute/2).
-    :- mode(del_attribute(?nonvar, ?nonvar), zero_or_more).
-
-    :- public(del_attributes/2).
-    :- mode(del_attributes(@term, @term), one).
-
-    :- private(attribute_/2).
-    :- mode(attribute_(?nonvar, ?nonvar), zero_or_more).
-    :- dynamic(attribute_/2).
-
-    set_attribute(Attribute, Value):-
-        ::retractall(attribute_(Attribute, _)),
-        ::assertz(attribute_(Attribute, Value)).
-
-    get_attribute(Attribute, Value):-
-        ::attribute_(Attribute, Value).
-
-    del_attribute(Attribute, Value):-
-        ::retract(attribute_(Attribute, Value)).
-
-    del_attributes(Attribute, Value):-
-        ::retractall(attribute_(Attribute, Value)).
-
-:- end_category.
-

-We have two new directives, category/1 and end_category/0, that encapsulate the category code. If needed, we can put the predicates directives inside a protocol that will be implemented by the category: -

-
:- category(attributes,
-    implements(attributes_protocol)).
-
-    ...
-
-:- end_category.
-

-Any protocol can be implemented by either an object, a category, or both. -

- -

Importing the category

- -

-We reuse a category's predicates by importing them into an object: -

-
:- object(person,
-    imports(attributes)).
-
-    ...
-
-:- end_object.
-

-After compiling and loading this object and our category, we can now try queries like: -

-
| ?- person::set_attribute(name, paulo).
-
-yes
-
-| ?- person::set_attribute(gender, male).
-
-yes
-
-| ?- person::get_attribute(Attribute, Value).
-
-Attribute = name, Value = paulo ;
-Attribute = gender, Value = male ;
-no
- -

Summary

- -
    -
  • Categories are similar to objects: we just write our predicate directives and definitions bracketed by opening and ending category directives.
  • -
-
    -
  • An object reuses a category by importing it. The imported predicates behave as if they have been defined in the object itself.
  • -
-
    -
  • When do we use a category instead of an object? Whenever we have a set of closely related predicates that we want to reuse in several, unrelated, objects. Categories can be interpreted as object building components.
  • -
- - - - - - diff --git a/Logtalk/manuals/tutorial/index.html b/Logtalk/manuals/tutorial/index.html deleted file mode 100644 index 1536fc059..000000000 --- a/Logtalk/manuals/tutorial/index.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - Logtalk tutorial: index - - - - - - -
Logtalk tutorial
-
Index
-
-
- - -

Tutorial

- -

List predicates

- -
-
Defining a list object
-
Defining a list protocol
-
Summary
-
- -

Dynamic object attributes

- -
-
Defining a category
-
Importing the category
-
Summary
-
- - -

A reflective class-based system

- -
-
Defining the base classes
-
Summary
-
- -

Profiling programs

- -
-
Messages as events
-
Profilers as monitors
-
Summary
-
- - - - - - diff --git a/Logtalk/manuals/tutorial/lists.html b/Logtalk/manuals/tutorial/lists.html deleted file mode 100644 index 0a369b819..000000000 --- a/Logtalk/manuals/tutorial/lists.html +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - - - Logtalk tutorial: list predicates - - - - - - -
Logtalk tutorial
-
List predicates
-
-
- - -

List predicates

- -

-In this example, we will illustrate the use of: -

-
    -
  • objects
  • -
  • protocols
  • -
-

-by using common list utility predicates. -

- -

Defining a list object

- -

-We will start by defining an object, list, containing predicate definitions for some common list predicates like append/3, length/2 and member/2: -

-
:- object(list).
-
-    :- public(append/3).
-    :- public(length/2).
-    :- public(member/2).
-
-    append([], List, List).
-    append([Head| Tail], List, [Head| Tail2]) :-
-        append(Tail, List, Tail2).
-
-    length(List, Length) :-
-        length(List, 0, Length).
-
-    length([], Length, Length).
-    length([_| Tail], Acc, Length) :-
-        Acc2 is Acc + 1,
-        length(Tail, Acc2, Length).
-
-    member(Element, [Element| _]).
-    member(Element, [_| List]) :-
-        member(Element, List).
-
-:- end_object.
-

-What is different here from a regular Prolog program? The definitions of the list predicates are the usual ones. We have two new directives, object/1 and end_object/0, that encapsulate the object's code. In Logtalk, by default, all object predicates are private; therefore, we have to explicitly declare all predicates that we want to be public, that is, that we want to call from outside the object. This is done using the public/1 scope directive. -

-

-After we copy the object code to a text file and saved it under the name list.lgt, we need to change the Prolog working directory to the one used to save our file (consult your Prolog compiler reference manual). Then, after starting Logtalk (see the Installing and running Logtalk session on the User Manual), we can compile and load the object using the logtalk_load/1 Logtalk built-in predicate: -

-
| ?- logtalk_load(list).
-
-object list loaded
-yes
-

-We can now try goals like: -

-
| ?- list::member(X, [1, 2, 3]).
-
-X = 1;
-X = 2;
-X = 3;
-no
-

-or: -

-
| ?- list::length([1, 2, 3], L).
-
-L = 3
-yes
-

-The infix operator ::/2 is used in Logtalk to send a message to an object. The message must match a public object predicate. If we try to call a non-public predicate such as the length/3 auxiliary predicate an exception will be generated: -

-
| ?- list::length([1, 2, 3], 0, L).
-
-uncaught exception:
-    error(
-        existence_error(predicate_declaration, length([1, 2, 3], 0, L)),
-        list::length([1, 2, 3], 0, L),
-        user)
-

-The error term describes the type of error, the message that caused the exception, and the sender of the message (in this case, the pseudo-object user because we are sending the message from the top-level interpreter). -

- -

Defining a list protocol

- -

-As we saw in the above example, a Logtalk object may contain predicate directives and predicate definitions (clauses). The set of predicate directives defines what we call the object's protocol 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 implementation by defining a new Logtalk entity known as a protocol. Logtalk protocols are compilations units, at the same level as objects and categories. That said, let us define a listp protocol: -

-
:- protocol(listp).
-
-    :- public(append/3).
-    :- public(length/2).
-    :- public(member/2).
-
-:- end_protocol.
-

-Similar to what we have done for objects, we use the directives protocol/1 and end_protocol/0 to encapsulate the predicate directives. We can improve this protocol by documenting the call/return modes and the number of solutions of each predicate using the mode/2 directive: -

-
:- protocol(listp).
-
-    :- public(append/3).
-    :- mode(append(?list, ?list, ?list), zero_or_more).
-
-    :- public(length/2).
-    :- mode(length(?list, ?integer), zero_or_more).
-
-    :- public(member/2).
-    :- mode(member(?term, ?list), zero_or_more).
-
-:- end_protocol.
-

-We now need to change our definition of the list object by removing the predicate directives and by declaring that the object implements the listp protocol: -

-
:- object(list,
-	implements(listp)).
-
-    append([], List, List).
-    append([Head| Tail], List, [Head| Tail2]) :-
-        append(Tail, List, Tail2).
-
-    ...
-
-:- end_object.
-

-The protocol declared in listp may now be alternatively implemented using difference lists by defining a new object, difflist: -

-
:- object(difflist,
-    implements(listp).
-
-    append(L1-X, X-L2, L1-L2).
-    ...
-
-:- end_object.
- -

Summary

- -
    -
  • 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.
  • -
-
    -
  • 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.
  • -
- - - - - - diff --git a/Logtalk/manuals/tutorial/profiling.html b/Logtalk/manuals/tutorial/profiling.html deleted file mode 100644 index a37aa5768..000000000 --- a/Logtalk/manuals/tutorial/profiling.html +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - - - Logtalk tutorial: profiling programs - - - - - - -
Logtalk tutorial
-
Profiling programs
-
-
- - -

Profiling programs

- -

-In this example, we will illustrate the use of: -

-
    -
  • events
  • -
  • monitors
  • -
-

-by defining a simple profiler that prints the starting and ending time for processing a message sent to an object. -

- -

Messages as events

- -

-In a pure object-oriented system, all computations start by sending messages to objects. We can thus define an event as the sending of a message to an object. An event can then be specified by the tuple (Object, Message, Sender). This definition can be refined by interpreting the sending of a message and the return of the control to the object that has sent the message as two distinct events. We call these events respectively before and after. Therefore, we end up by representing an event by the tuple (Event, Object, Message, Sender). For instance, if we send the message: -

-
| ?- foo::bar(X).
-
-X = 1
-yes
-

-the two corresponding events will be: -

-
(before, foo, bar(X), user)
-(after, foo, bar(1), user)
-

-Note that the second event is only generated if the message succeeds. If the message as a goal have multiple solutions, then one after event will be generated for each solution. -

-

-Events are automatically generated by the message sending mechanisms for each public message sent using the ::/2 operator. -

- -

Profilers as monitors

- -

-A monitor is an object that reacts whenever a spied event occurs. The monitor actions are defined by two event handlers: before/3 for before events and after/3 for after events. These predicates are automatically called by the message sending mechanisms when an event registered for the monitor occurs. These event handlers are declared as public predicates in the monitoring built-in protocol. -

-

-In our example, we need a way to get the current time before and after we process a message. We will assume that we have a time object implementing a cpu_time/1 predicate that returns the current CPU time for the Prolog session: -

-
:- object(time).
-
-    :- public(cpu_time/1).
-    :- mode(cpu_time(-number), one).
-
-    ...
-
-:- end_object.
-

-Our profiler will be named stop_watch. It must define event handlers for the before and after events that will print the event description (object, message, and sender) and the current time: -

-
:- object(stop_watch,
-    implements(monitoring)).    % event handler predicate declarations
-
-    :- uses(time).
-
-    before(Object, Message, Sender) :-
-        write(Object), write(' <-- '), writeq(Message),
-        write(' from '), write(Sender), nl, write('STARTING at '),
-        time::cpu_time(Seconds), write(Seconds), write(' seconds'), nl.
-
-    after(Object, Message, Sender) :-
-        write(Object), write(' <-- '), writeq(Message),
-        write(' from '), write(Sender), nl, write('ENDING at '),
-        time::cpu_time(Seconds), write(Seconds), write(' seconds'), nl.
-
-:- end_object.
-

-After compiling and loading the stop_watch object (and the objects that we want to profile), we can use the define_events/5 built-in predicate to set up our profiler. For example, to profile all messages that are sent to the object foo, we need to call the goal: -

-
| ?- define_events(_, foo, _, _, stop_watch).
-
-yes
-

-This call will register stop_watch as a monitor to all messages sent to object foo, for both before and after events. Note that we say "as a monitor", not "the monitor": we can have any number of monitors over the same events. -

-

-From now on, every time we sent a message to foo, the stop_watch monitor will print the starting and ending times for the message execution. For instance: -

-
| ?- foo::bar(X).
-
-foo <-- bar(X) from user
-STARTING at 12.87415 seconds
-foo <-- bar(1) from user
-ENDING at 12.87419 seconds
-
-X = 1
-yes
-

-To stop profiling the messages sent to foo we use the abolish_events/5 -built-in predicate: -

-
| ?- abolish_events(_, foo, _, _, stop_watch).
-
-yes
-

-This call will abolish all events defined over the object foo assigned to the stop_watch monitor. -

- -

Summary

- -
    -
  • An event is defined as the sending of a (public) message to an object.
  • -
-
    -
  • There are two kinds of events: before events, generated before a message is processed, and after events, generated after the message processing completed successfully.
  • -
-
    -
  • Any object can be declared as a monitor to any event. A monitor shall reference the monitoring built-in protocol in the object opening directive.
  • -
-
    -
  • A monitor defines event handlers, the predicates before/3 and after/3, that are automatically called by the runtime engine when a spied event occurs.
  • -
- - - - - - - diff --git a/Logtalk/manuals/tutorial/reflection.html b/Logtalk/manuals/tutorial/reflection.html deleted file mode 100644 index 521a163ed..000000000 --- a/Logtalk/manuals/tutorial/reflection.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - Logtalk tutorial: a reflective class-based system - - - - - - -
Logtalk tutorial
-
A reflective class-based system
-
-
- - -

A reflective class-based system

- -

-When compiling an object, Logtalk distinguishes prototypes from instance or classes by examining the object relations. If an object instantiates and/or specializes another object, then it is compiled as an instance or class, otherwise it is compiled as a prototype. A consequence of this is that, in order to work with instance or classes, we always have to define root objects for the instantiation and specialization hierarchies (however, we are not restricted to a single hierarchy). The best solution is often to define a reflective class-based system [Maes 87], where every class is also an object and, as such, an instance of some class. -

-

-In this example, we are going to define the basis for a reflective class-based system, based on an extension of the ideas presented in [Cointe 87]. This extension provides, along with root objects for the instantiation and specialization hierarchies, explicit support for abstract classes [Moura 94]. -

- -

Defining the base classes

- -

-We will start by defining three classes: object, abstract_class, and class. The class object will contain all predicates common to all objects. It will be the root of the inheritance graph: -

-
:- object(object,
-    instantiates(class)).
-
-    % predicates common to all objects
-
-:- end_object.
-

-The class abstract_class specializes object by adding predicates common to all classes. It will be the default meta-class for abstract classes: -

-
:- object(abstract_class,
-    instantiates(class),
-    specializes(object)).
-
-    % predicates common to all classes
-
-:- end_object.
-

-The class class specializes abstract_class by adding predicates common to all instantiable classes. It will be the root of the instantiation graph and the default meta-class for instantiable classes: -

-
:- object(class,
-    instantiates(class),
-    specializes(abstract_class)).
-
-    % predicates common to all instantiable classes
-
-:- end_object.
-

-Note that all three objects are instances of class class. The instantiation and specialization relationships are chosen so that each object may use the predicates defined in itself and in the other two objects, with no danger of method lookup endless loops. -

- -

Summary

- -
    -
  • An object that does not instantiate or specialize other objects is always compiled as a prototype.
  • -
-
    -
  • An instance must instantiate at least one object (its class). Similarly, a class must at least specialize or instantiate other object.
  • -
-
    -
  • The distinction between abstract classes and instantiable classes is an operational one, depending on the class inherited methods. A class is instantiable if inherits methods for creating instances. Conversely, a class is abstract if does not inherit any instance creation method.
  • -
- - - - - diff --git a/Logtalk/manuals/userman/categories.html b/Logtalk/manuals/userman/categories.html deleted file mode 100644 index a8c59f09b..000000000 --- a/Logtalk/manuals/userman/categories.html +++ /dev/null @@ -1,332 +0,0 @@ - - - - - - - - Logtalk user manual: categories - - - - - - -
Logtalk user manual
-
Categories
-
-
- - -

Categories

- -

-Categories provide a way to encapsulate a set of related predicate declarations and definitions that do not represent an object and that only make sense when composed with other predicates. Categories may also be used to break a complex object in functional units. A category can be imported by several objects (without code duplication), including objects participating in prototype or class-based hierarchies. This concept of categories shares some ideas with Smalltalk-80 functional categories [Goldberg 83], Flavors mix-ins [Moon 86] (without necessarily implying multi-inheritance) and Objective-C categories [Cox 86]. -

-

-There are no pre-defined categories in Logtalk. -

- -

Defining a new category

- -

-We can define a new object in the same way we write Prolog code: by using a text editor. Logtalk source files may contain one or more objects, categories, or protocols. If you prefer to define each entity in its own source file, it is recommended that the file be named after the category. By default, all Logtalk source files use the extension .lgt but this is optional and can be set in the configuration files. Intermediate Prolog source files (generated by the Logtalk compiler) have, by default, a .pl extension. Again, this can be set to match the needs of a particular Prolog compiler in the corresponding configuration file. For instance, we may define a category named documenting and save it in a documenting.lgt source file that will be compiled to a documenting.pl Prolog file. -

-

-Category names must be atoms. Objects, categories, and protocols share the same name space: we cannot have a category with the same name as an object or a protocol. -

-

-Category code (directives and predicates) is textually encapsulated by using two Logtalk directives: category/1-3 and end_category/0. The most simple category will be one that is self-contained, not depending on any other Logtalk entity: -

-
:- category(Category).
-    ...
-:- end_category.
-

-If a category implements one or more protocols then the opening directive will be: -

-
:- category(Category,
-    implements(Protocol)).
-    ...
-:- end_category.
-

-A category may be defined as a composition of other categories by writing: -

-
:- category(Component,
-    imports(Category1, Category2, ...)).
-    ...
-:- end_category.
-

-This feature should only be used when extending a category without breaking its functional cohesion (for example, when a modified version of a category is needed for importing on several unrelated objects). The prefered way of composing several categories is by importing them into an object. -

-

-Categories cannot inherit from objects. In addition, categories cannot contain clauses for dynamic predicates. This restriction applies because a category can be imported by several objects and because we cannot use the database handling built-in methods with categories (messages can only be sent to objects). However, categories may contain declarations for dynamic predicates and they can contain predicates which handle dynamic predicates. For example: -

-
:- category(attributes).
-
-    :- public(attribute/2).
-    :- public(set_attribute/2).
-    :- public(del_attribute/2).
-
-    :- private(attribute_/2).
-    :- dynamic(attribute_/2).
-
-    attribute(Attribute, Value) :-
-        ::attribute_(Attribute, Value).
-
-    set_attribute(Attribute, Value) :-
-        ::retractall(attribute_(Attribute, _)),
-        ::assertz(attribute_(Attribute, Value)).
-
-    del_attribute(Attribute, Value) :-
-        ::retract(attribute_(Attribute, Value)).
-
-:- end_category.
-

-Each object importing this category will have its own attribute_/2 private, dynamic predicate. The predicates attribute/2, set_attribute/2, and del_attribute/2 always access and modify the dynamic predicate contained in the object receiving the corresponding messages. -

- -

Finding defined categories

- -

-We can find, by backtracking, all defined categories by using the current_category/1 Logtalk built-in predicate with an uninstantiated variable: -

-
| ?- current_category(Category).
-

-This predicate can also be used to test if a category is defined by calling it with a valid category identifier (an atom or a compound term). -

- -

Creating a new category in runtime

- -

-A category can be dynamically created at runtime by using the create_category/4 built-in predicate: -

-
| ?- create_category(Category, Relations, Directives, Clauses).
-

-The first argument, the name of the new category - a Prolog atom - should not match with an existing entity name. The remaining three arguments correspond to the relations described in the opening category directive and to the category code contents (directives and clauses). -

-

-For instance, the call: -

-
| ?- create_category(ccc,
-                     [implements(ppp)],
-                     [private(bar/1)],
-                     [(foo(X):-bar(X)), bar(1), bar(2)]).
-

-is equivalent to compiling and loading the category: -

-
:- category(ccc,
-    implements(ppp)).
-
-    :- dynamic.
-
-    :- private(bar/1).
-
-    foo(X) :-
-        bar(X).
-
-    bar(1).
-    bar(2).
-
-:- end_category.
-

-If we need to create a lot of (dynamic) categories at runtime, then is best to to define a metaclass or a prototype with a predicate that will call this built-in predicate in order to provide more sophisticated behavior. -

- -

Abolishing an existing category

- -

-Dynamic categories can be abolished using the abolish_category/1 built-in predicate: -

-
| ?- abolish_category(Category).
-

-The argument must be an identifier of a defined dynamic category, otherwise an error will be thrown. -

- -

Category directives

- -

-Category directives are used to set initialization goals and category properties and to document a category dependencies on other Logtalk entities. -

- -

Category initialization

- -

-We can define a goal to be executed as soon as a category is (compiled and) loaded to memory with the initialization/1 directive: -

-
:- initialization(Goal).
-

-The argument can be any valid Prolog or Logtalk goal, including a message sending call. -

- -

Dynamic categories

- -

-As usually happens with Prolog code, a category can be either static or dynamic. A category created during the execution of a program is always dynamic. A category defined in a file can be either dynamic or static. Dynamic categories are declared by using the dynamic/0 directive in the category source code: -

-
:- dynamic.
-

-The directive must precede any predicate directives or clauses. Please be aware that using dynamic code implies a performance hit when compared to static code. We should only use dynamic categories when these need to be abolished during program execution. -

- -

Category dependencies

- -

-Besides the relations declared in the category opening directive, the predicate definitions contained in the category may imply other dependencies. This can be documented by using the calls/1 and the uses/1 directives. -

-

-The calls/1 directive can be used when a predicate definition sends a message that is declared in a specific protocol: -

-
:- calls(Protocol).
-

-If a predicate definition sends a message to a specific object, this dependence can be declared with the uses/1 directive: -

-
:- uses(Object).
-

-These two directives can be used by the Logtalk runtime to ensure that all needed entities are loaded when running an application. -

- -

Category documentation

- -

-A category can be documented with arbitrary user-defined information by using the info/1 directive: -

-
:- info(List).
-

-See the documenting Logtalk programs session for details. -

- -

Category relationships

- -

-Logtalk provides two sets of built-in predicates that enable us to query the system about the possible relationships that a category can have with other entities. -

-

-The built-in predicates implements_protocol/2 and implements_protocol/3 find which categories implements which protocols: -

-
| ?- implements_protocol(Category, Protocol).
-

-or, if we want to know the implementation scope: -

-
| ?- implements_protocol(Category, Protocol, Scope).
-

-Note that, if we use an uninstantiated variable for the first argument, we will need to use the current_category/1 built-in predicate to ensure that the returned entity is a category and not an object. -

-

-To find which objects (or categories) import which categories we can use the -imports_category/2 or imports_category/3 built-in predicates: -

-
| ?- imports_category(Object, Category).
-
-| ?- imports_category(Category1, Category2).
-

-or, if we want to know the importation scope: -

-
| ?- imports_category(Object, Category, Scope).
-
-| ?- imports_category(Category1, Category2, Scope).
-

-Note that a category may be imported by several objects (or other categories). -

- -

Category properties

- -

-We can find the properties of defined categories by calling the built-in predicate category_property/2: -

-
| ?- category_property(Category, Property).
-

-A category may have the property static, dynamic, or built_in. Dynamic categories can be abolished in runtime by calling the abolish_category/1 built-in predicate. A category may also have the property synchronized, which is related to multi-threading programming. -

- -

Importing categories

- -

-Any number of objects can import a category. In addition, an object may import any number of categories. The syntax is very simple: -

-
:- object(Object,
-    imports(Category1, Category2, ...)).
-    ...
-:- end_object.
-

-To make all public predicates imported via a category protected or to make all public and protected predicates private we prefix the category's name with the corresponding keyword: -

-
:- object(Object,
-    imports(private::Category)).
-    ...
-:- end_object.
-

-or: -

-
:- object(Object,
-    imports(protected::Category)).
-    ...
-:- end_object.
-

-Omitting the scope keyword is equivalent to writing: -

-
:- object(Object,
-    imports(public::Category)).
-    ...
-:- end_object.
- -

Using category predicates

- -

-Category predicates can be called from within an object using either the message sending mechanisms or a direct call. Consider the following category: -

-
:- category(output).
-
-    :- public(out/1).
-
-    out(X) :-
-        writeq(X), nl.
-
-:- end_category.
-

-Using the message sending mechanisms, the predicate out/1 can be called from within an object importing the category by simply sending a message to self. For example: -

-
:- object(worker,
-    imports(output)).
-
-    ...
-    do(Task) :-
-        execute(Task, Result),
-        ::out(Result).
-    ...
-
-:- end_object.
-

-This is the recommended way of calling category predicates as it supports the specialization/redefinition of the category predicate in a descendant object (as the predicate declaration and definition lookups will start from self). Messages to self usually imply the use of dynamic binding as the actual object that will receive the message is only known at runtime. This translates to a small performance penalty when compared with calls to local object predicates. -

-

-It is also possible to call category predicates such that the predicate declaration and definition lookups will start from this instead of self by using the :/1 control construct. For example: -

-
:- object(worker,
-    imports(output)).
-
-    ...
-    do(Task) :-
-        execute(Task, Result),
-        :out(Result).
-    ...
-
-:- end_object.
-

-This alternative should only be used when the user knows a priori that the category predicates will not be specialized or redefined by descendant objects of the object importing the category. Its advantage is that, whenever possible, the Logtalk compiler will optimize the calls by using static binding (implies separate loading of the categories using the reload(skip) compiler flag). However, when static binding is not possible due to the lack of sufficient information at compilation time, the performance may be worse than calling the category predicate using a message to self due to the lack of a caching mechanism. -

- - - - - - diff --git a/Logtalk/manuals/userman/configuration.html b/Logtalk/manuals/userman/configuration.html deleted file mode 100644 index 701ec4f70..000000000 --- a/Logtalk/manuals/userman/configuration.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - Logtalk user manual: logtalk configuration - - - - - - - -

Logtalk configuration

- -

-The Logtalk system is entirely written in Prolog, without resorting to other programming languages. In spite of that, the fact that the ISO standard [ISO 95] has only recently been approved causes a lot of problems when we try to ensure compatibility with most of the existing Prolog compilers [Moura 99]. If most syntax problems can be easily solved, the same does not happen when we talk about built-in predicates, where we face several difficulties. In the first place, many compilers do not implement the total of the predicates defined in ISO standard, which can be considered quite minimalist in this respect. Sometimes they implement those predicates in a way that does not match the standard or other compilers, thus concurring to the existence of subtle errors quite difficult to detect. To make things worse, it is not possible to replace some of the absent predicates and directives with our own definitions, due to the very nature of those predicates and directives. Consequently, some of the Logtalk system features (e.g., error handling) may not work in some compilers. -

-

-The adopted solution consists on developing a universal Logtalk version, linked to a given compiler through the definition of a small set of predicates and operators, assembled in a configuration file. These predicates can be divided in two groups. The first group contains Logtalk specific predicates. The second group tries to implement predicates that, although they are defined in the approved ISO Prolog Standard, are not available in the specific compiler we want to use. This manual session explains how to build a configuration file for a Prolog compiler. -

- -

Hardware & software requirements

- -

Computer and operating system

- -

-Logtalk is compatible with almost any machine/operating system with a modern Prolog compiler available. Currently, my main development environment is an upgraded Apple PowerMacintosh 7600 running Mac OS 9 and LinuxPPC; most used compilers are the Mac port of GNU Prolog and, under Linux, YAP and SWI Prolog. Being written in Prolog and distributed in source form, the only issue regarding operating system compatibility are the end-of-line codes in the source text files! Most example source file names do not fit in the 8+3 MS-DOS file length limitation, so this may prevent those examples from running under this operating system (or in any other system with similar limitations). -

- -

Prolog compiler

- -

-In writing Logtalk I have tried to follow the recently approved Prolog ISO standard whenever possible. Capabilities needed by Logtalk that are not defined in the ISO standard are: -

-
    -
  • access to predicate properties (dynamic, static, built_in)
  • -
-

-Logtalk needs access to the predicate propertybuilt_in to properly compile objects and categories that contain Prolog built-in predicates calls. In addition, some Logtalk built-ins need to know the dynamic/static status of predicates to ensure correct application. The ISO standard for Prolog modules defines a predicate_property/2 predicate that is already implemented by most Prolog compilers. Note that if these capabilities are not built-in the user cannot easily define them.

-

-For optimal performance, Logtalk requires that the Prolog compiler supports first-argument indexing for both static and dynamic code (most modern compilers support this feature). -

-

-Because most Prolog implementers are slowly moving toward more ISO compliant compilers, it is advisable that you try to use the most recent version of your favorite Prolog compiler. -

- -

Configuration files

- -

-Configuration files provide the glue code between the Logtalk preprocessor/runtime and a Prolog compiler. Each configuration file contains two sets of predicates: ISO Prolog standard predicates and directives not built-in in the target Prolog compiler and Logtalk-specific predicates. -

-

-Logtalk already includes ready to use configuration files for most Prolog compilers. However, you may need to write your own configuration file if one is not available for your Prolog compiler. In most cases, you can borrow code from some of the predefined configuration files. If you send me your configuration file, with a reference to the target Prolog compiler, maybe I can include it in the next release of Logtalk. -

-

-Start by making a copy of the file configs/template.config. Carefully check (or complete if needed) each listed definition. If your Prolog compiler conforms to the ISO standard, this task should only take you a few minutes. -

-

-If you are unsure that your Prolog compiler provides all the ISO predicates needed by Logtalk, try to run the system by setting the unknown predicate error handler to report as an error any call to a missing predicate. Better yet, switch to a modern, ISO compliant, Prolog compiler. -

- - - - - - - - diff --git a/Logtalk/manuals/userman/documenting.html b/Logtalk/manuals/userman/documenting.html deleted file mode 100644 index b11528bdb..000000000 --- a/Logtalk/manuals/userman/documenting.html +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - - Logtalk user manual: documenting programs - - - - - - -
Logtalk user manual
-
Documenting programs
-
-
- - -

Documenting Logtalk programs

- -

-Logtalk automatically generates a documentation file for each compiled entity (object, protocol, or category) in XML format. Contents of the XML file include the entity name, type, and compilation mode (static or dynamic), the entity relations with other entities, and a description of any declared predicates (name, compilation mode, scope, ...). -

-

-The XML documentation files can be enriched with arbitrary user-defined information, either about an entity or about its predicates, by using the two directives described below. -

- -

Documenting directives

- -

-Logtalk supports two documentation directives for providing arbitrary user-defined information about an entity or a predicate. These two directives complement other Logtalk directives that also provide important documentation information like uses/1, calls/1, or mode/2. -

- -

Entity directives

- -

-Arbitrary user-defined entity information can be represented using the info/1 directive: -

-
:- info([
-    Key1 is Value1,
-    Key2 is Value2,
-    ...]).
-

-In this pattern, keys should be atoms and values should be ground terms. The following keys are pre-defined and may be processed specially by Logtalk: -

-
-
comment
-
Comment describing entity purpose (an atom).
-
author
-
Entity author(s) (an atom or a compound term {entity} where entity is the name of a XML entity defined in the custom.ent file).
-
version
-
Version number (a number).
-
date
-
Date of last modification (formatted as Year/Month/Day).
-
parameters
-
Parameter names and descriptions for parametric entities (a list of key-values where both keys and values are atoms).
-
parnames
-
Parameter names for parametric entities (a list of atoms; a simpler version of the previous key, used when parameter descriptions are deemed unnecessary).
-
copyright
-
Copyright notice for the entity source code (an atom or a compound term {entity} where entity is the name of a XML entity defined in the custom.ent file).
-
license
-
License terms for the entity source code; usually, just the license name (an atom or a compound term {entity} where entity is the name of a XML entity defined in the custom.ent file).
-
remarks
-
List of general remarks about the entity using the format Topic - Text. Both the topic and the text must be atoms.
-
-

-For example: -

-
:- info([
-    version is 2.1,
-    author is 'Paulo Moura',
-    date is 2000/4/20,
-    comment is 'Building representation.',
-    diagram is 'UML Class Diagram #312']).
-

-Use only the keywords that make sense for your application and remember that you are free to invent your own keywords. -

- -

Predicate directives

- -

-Arbitrary user-defined predicate information can be represented using the -info/2 directive: -

-
:- info(Functor/Arity, [
-    Key1 is Value1,
-    Key2 is Value2,
-    ...]).
-

-Keys should be atoms and values should be ground terms. The following keys are pre-defined and may be processed specially by Logtalk: -

-
-
comment
-
Comment describing predicate purpose (an atom).
-
arguments
-
Names and descriptions of predicate arguments for pretty print output (a list of key-values where both keys and values are atoms).
-
argnames
-
Names of predicate arguments for pretty print output (a list of atoms; a simpler version of the previous key, used when argument descriptions are deemed unnecessary).
-
allocation
-
Objects where we should define the predicate. Some possible values are container, descendants, instances, classes, subclasses, and any.
-
redefinition
-
Describes if the predicate can be redefined and, if so, in what way. Some possible values are never, free, specialize, call_super_first, call_super_last.
-
exceptions
-
List of possible exceptions throw by the predicate using the format Description - Exception term. The description must be an atom. The exception term must be a non-variable term.
-
examples
-
List of typical predicate call examples using the format Description - Predicate call - Variable bindings. The description must be an atom. The predicate call term must be a non-variable term. The variable bindings term uses the format {Variable=Term, ...}. When there are no variable bindings, the success or failure of the predicate call should be represented by the terms {yes} or {no}, respectively.
-
-

-For example: -

-
:- info(color/1, [
-    comment is 'Table of defined colors.',
-    argnames is ['Color'],
-    constraint is 'Only a maximum of four visible colors allowed.']).
-

-Use only the keywords that make sense for your application and remember that you are free to invent your own keywords. -

- -

Processing and viewing documenting files

- -

-The XML documenting files are (by default) automatically generated when you compile a Logtalk entity. For example, assuming the default filename extensions, compiling a trace object and a sort(_) parametric object contained in a source file will result in trace_0.xml and sort_1.xml XML files. -

-

-Each XML file contains references to two other files, a XML specification file and a XSL style-sheet file. The XML specification file can be either a DTD file (logtalk.dtd) or a XML Scheme file (logtalk.xsd). The XSL style-sheet file is responsible for converting the XML files to some desired format such as HTML or PDF. The default names for the XML specification file and the XSL style-sheet file are defined in the configuration files. The xml sub-directory in the Logtalk installation directory contains the XML specification files described above, along with several sample XSL style-sheet files and sample scripts for converting XML documenting files to several formats. Please read the NOTES file included in the directory for details. You may use the supplied sample files as a starting point for generating the documentation of your Logtalk applications. -

-

-The Logtalk DTD file, logtalk.dtd, contains a reference to a user-customizable file, custom.ent, which declares XML entities for source code author names, license terms, and copyright string. After editing the custom.ent file to reflect your personal data, you may use the XML entities on info/1 documenting directives. For example, assuming that the XML entities are named author, license, and copyright we may write: -

-
:- info([
-    version is 1.1,
-    author is {author},
-    license is {license},
-    copyright is {copyright}).
-

-The entity references are replaced by the value of the corresponding XML entity when the XML documenting files are processed (not when they are generated; this notation is just a shortcut to take advantage of XML entities). -

-

-There is a set of compilers options, used with the Logtalk logtalk_load/2 or the logtalk_compile/2 built-in predicates, that can be used to control the generation of the XML documentation files. Please see the Running Logtalk section of this manual for details. -

- - - - - - diff --git a/Logtalk/manuals/userman/errors.html b/Logtalk/manuals/userman/errors.html deleted file mode 100644 index f9c0a179e..000000000 --- a/Logtalk/manuals/userman/errors.html +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - - - Logtalk user manual: error handling - - - - - - -
Logtalk user manual
-
Error handling
-
-
- - -

Error handling

- -

-All error/exception handling is done in Logtalk by using the ISO defined catch/3 and throw/1 predicates [ISO 95]. Some Prolog compilers do not implement these predicates or, if they do, the implementation is not compatible with the standard. Furthermore, the nature of these predicates does not allow their definition by the user. For these reasons, we should check our Prolog compiler before trying to add error handling code to your Logtalk applications. -

-

-Errors thrown by Logtalk defined built-in predicates have the following format: -

-
error(Error, Call)
-

-For example: -

-
error(type_error(object_identifier, 33), current_object(33))
-

-Errors thrown while processing a message have the following format: -

-
error(Error, Message, Sender)
-

-For example: -

-
error(permission_error(modify, private_predicate, p(_)), foo::abolish(p/1), user)
- -

Compiler warnings and errors

- -

-The current Logtalk compiler uses the read_term/3 ISO Prolog defined built-in predicate to read and process a Logtalk source file. One consequence of this is that invalid Prolog terms or syntax errors may abort the compilation process with limited information given to the user (due to the inherent limitations of the read_term/3 predicate). -

-

-If all the terms in a source file are valid, then there is a set of errors or potential errors, described below, that the compiler will try to detect and report, depending on the used compiler flags (see the Installing and running Logtalk section of this manual for details). -

- -

Unknown entities

- -

-The Logtalk compiler will warn us of any referenced entity that is not currently loaded. The warning may reveal a misspell entity name or just an entity that it will be loaded next. -

- -

Singleton variables

- -

-Singleton variables in a clause are often misspell variables and, as such, one of the most common errors when programming in Prolog. If your Prolog compiler complies with the Prolog ISO standard or at least supports the ISO predicate read_term/3 called with the option singletons(S), then the Logtalk compiler will warn us of any singleton it finds while compiling a Logtalk entity. -

- -

Redefinition of Prolog built-in predicates

- -

-The Logtalk compiler will warn us of any redefinition of a Prolog built-in predicate inside an object or category. Sometimes the redefinition is intended. In other cases, the user may not be aware that the subjacent Prolog compiler may already provide the predicate as a built-in or we may want to ensure code portability among several Prolog compilers with different sets of built-in predicates. -

- -

Redefinition of Logtalk built-in predicates

- -

-Similar to the redefinition of Prolog built-in predicates, the Logtalk compiler will warn us if we try to redefine a Logtalk built-in. The redefinition will probably be an error in almost all (if not all) cases. -

- -

Redefinition of Logtalk built-in methods

- -

-An error will be thrown if we attempt to redefine a Logtalk built-in method inside an entity. The default behavior is to report the error and abort the compilation of the offending entity. -

- -

Misspell calls of local predicates

- -

-A warning will be reported if Logtalk finds (in the body of a predicate definition) a call to a local predicate that is not defined, built-in (either in Prolog or in Logtalk) or declared dynamic. In most cases these calls are simple misspell errors. -

- -

Portability warnings

- -

-A warning will be reported if a predicate clause contains a call to a non-ISO defined built-in predicate. -

- -

Other warnings and errors

- -

-The Logtalk compiler will throw an error if it finds a predicate clause or a directive that cannot be parsed. The default behavior is to report the error and abort the compilation of the offending entity. -

- -

Runtime errors

- -

-This session briefly describes runtime errors that result from misuse of Logtalk built-in predicates, built-in methods or from message sending. For a complete and detailed description of runtime errors please consult the Reference Manual. -

- -

Logtalk built-in predicates

- -

-All Logtalk built-in predicates checks the type and mode of the calling arguments, throwing an exception in case of misuse. -

- -

Logtalk built-in methods

- -

-Every Logtalk built-in method checks the type and mode of the calling arguments, throwing an exception in case of misuse. -

- -

Message sending

- -

-The message sending mechanisms always check if the receiver of a message is a defined object and if the message corresponds to a declared predicate within the scope of the sender. -

- - - - - - - diff --git a/Logtalk/manuals/userman/events.html b/Logtalk/manuals/userman/events.html deleted file mode 100644 index 23999d438..000000000 --- a/Logtalk/manuals/userman/events.html +++ /dev/null @@ -1,249 +0,0 @@ - - - - - - - - Logtalk user manual: event-driven programming - - - - - - -
Logtalk user manual
-
Event-driven programming
-
-
- - -

Event-driven programming

- -

-The addition of event-driven programming capacities to the Logtalk language [Moura 94] is based on a simple but powerful idea: -

- -
-

-The computations must result, not only from message sending, but also from the observation of message sending. -

-
- -

-The need to associate computations to the occurrence of events was very early recognized in several knowledge representation languages, in some programming languages [Stefik 86, Moon 86], and in the implementation of operative systems [Tanenbaum 87] and graphical user interfaces. -

-

-With the integration between object-oriented and event-driven programming, we intend to achieve the following goals: -

-
    -
  • Minimize the coupling between objects. An object should only contain what is intrinsic to it. If an object observes another object, that means that it should depend only on the (public) protocol of the object observed, and not on the implementation of that same protocol.
  • -
-
    -
  • Provide a mechanism for building reflexive systems in Logtalk based on the dynamic behavior of objects in complement to the reflective information of the object's contents and relations.
  • -
-
    -
  • Provide a mechanism for easily defining method pre- and post-conditions that can be toggled using the events compiler option. The pre- and post-conditions may be defined in the same object containing the methods or distributed between several objects acting as method monitors.
  • -
- -

Definitions

- -

-The words event and monitor have multiple meanings in computer science, so, to avoid misunderstandings, it is advisable that we start by defining them in the Logtalk context. -

- -

Event

- -

-In an object-oriented system, all computations start through message sending. It thus becomes quite natural to declare that the only event that can occur in this kind of system is precisely the sending of a message. An event can thus be represented by the ordered tuple (Object, Message, Sender). -

-

-If we consider message processing an indivisible activity, we can interpret the sending of a message and the return of the control to the object that has sent the message as two distinct events. This distinction allows us to have a more precise control over a system dynamics. In Logtalk, these two types of events have been named before and after, respectively for message sending and returning. Therefore, we end up by representing an event by the ordered tuple (Event, Object, Message, Sender). -

-

-The implementation of the event notion in Logtalk enjoys the following properties: -

-
-
Independence between the two types of events
-
We can choose to watch only one event type or to process each one of the events associated to a message sending in an independent way.
-
All events are automatically generated by the message sending mechanism
-
The task of generating events is accomplished, in a transparent way, by the message sending mechanism. The user just defines which are the events in which he is interested in.
-
The events watched at any moment can be dynamically changed during program execution
-
The notion of event allows the user not only to have the possibility of observing, but also of controlling and modifying an application behavior, namely by dynamically changing the observed events during program execution. It is our goal to provide the user with the possibility of modeling the largest possible number of situations.
-
- -

Monitor

- -

-Complementary to the notion of event is the notion of monitor. A monitor is an object that is automatically notified by the message sending mechanisms whenever certain events occur. A monitor should naturally define the actions to be carried out whenever a monitored event occurs. -

-

-The implementation of the monitor notion in Logtalk enjoys the following properties: -

-
-
Any object can act as a monitor
-
The monitor status is a role that any object can perform during its existence. The minimum protocol necessary is declared in the built-in protocol monitoring. Strictly speaking, the reference to this protocol is only needed when specializing event handlers. Nevertheless, it is considered good programming practice to always refer the protocol when defining event handlers.
-
Unlimited number of monitors for each event
-
Several monitors can observe the same event because of distinct reasons. Therefore, the number of monitors per event is bounded only by the available computing resources.
-
The monitor status of an object can be dynamically changed in runtime
-
This property does not imply that an object must be dynamic to act as a monitor (the monitor status of an object is not stored in the object).
-
The execution of actions, defined in a monitor, associated to each event, never affects the term that denotes the message involved
-
In other words, if the message contains uninstantiated variables, these are not affected by the acting of monitors associated to the event.
-
- -

Event generation

- -

-For each message that is sent (using the ::/2 message sending mechanism) the runtime system automatically generates two events. The first — before event — is generated when the message is sent. The second — after event — is generated after the message has successfully been executed. -

- -

Communicating events to monitors

- -

-Whenever a spied event occurs, the message sending mechanisms call the corresponding event handlers directly for all registered monitors. These calls are made bypassing the message sending primitives in order to avoid potential endless loops. The event handlers consist in user definitions for the public predicates declared in the monitoring built-in protocol (one for each event kind; see below for more details). -

- -

Performance concerns

- -

-Ideally, the existence of monitored messages should not affect the processing of the remaining messages. On the other hand, for each message that has been sent, the system must verify if its respective event is monitored. Whenever possible, this verification should be performed in constant time and independently from the number of monitored events. The events representation takes advantage of the first argument indexing performed by most Prolog compilers, which ensure — in the general case — an access in constant time. -

-

-Event-support can be turned off on a per-object (or per-category) basis using the compiler flag events/1. With event-support turned off, Logtalk uses optimized code for processing message sending calls that skips the checking of monitored events, resulting in a small but measurable performance improvement. -

- -

Monitor semantics

- -

-The established semantics for monitors actions consists on considering its success as a necessary condition so that a message can succeed: -

-
    -
  • All actions associated to events of type before must succeed, so that the message processing can start.
  • -
-
    -
  • All actions associated to events of type after also have to succeed so that the message itself succeeds. The failure of any action associated to an event of type after forces backtracking over the message execution (the failure of a monitor never causes backtracking over the preceding monitor actions).
  • -
-

-Note that this is the most general choice. If we wish a transparent presence of monitors in a message processing, we just have to define the monitor actions in such a way that they never fail (which is very simple to accomplish). -

- -

Activation order of monitors

- -

-Ideally, whenever there are several monitors defined for the same event, the calling order should not interfere with the result. However, this is not always possible. In the case of an event of type before, the failure of a monitor prevents a message from being sent and prevents the execution of the remaining monitors. In case of an event of type after, a monitor failure will force backtracking over message execution. Different orders of monitor activation can therefore lead to different results if the monitor actions imply object modifications unrecoverable in case of backtracking. Therefore, the order for monitor activation must be always taken as arbitrary. In effect, to suppose or to try to impose a specific sequence implies a global knowledge of an application dynamics, which is not always possible. Furthermore, that knowledge can reveal itself as incorrect if there is any changing in the execution conditions. Note that, given the independence between monitors, it does not make sense that a failure forces backtracking over the actions previously executed. -

- -

Event handling

- -

-Logtalk provides three built-in predicates for event handling. These predicates enable you to find what events are defined, to define new events and to abolish events when they are no longer needed. If you plan to use events extensively in your application, then you should probably define a set of objects that use the built-in predicates described below to implement more sophisticated and high-level behavior. -

- -

Finding defined events

- -

-The events that are currently defined can be retrieved using the Logtalk built-in predicate current_event/5: -

-
| ?- current_event(Event, Object, Message, Sender, Monitor).
-

-Note that this predicate will return a set of matching events if some of the returned arguments are free variables or contain free variables. -

- -

Defining new events

- -

-New events can be defined using the Logtalk built-in predicate define_events/5: -

-
| ?- define_events(Event, Object, Message, Sender, Monitor).
-

-Note that if any of the arguments is a free variable or contains free variables, this call will define the set of matching events. -

- -

Abolishing defined events

- -

-Events that are no longer needed may be abolished using the abolish_events/5 built-in predicate: -

-
| ?- abolish_events(Event, Object, Message, Sender, Monitor).
-

-If called with free variables, this goal will remove all matching events. -

- -

Defining event handlers

- -

-The monitoring built-in protocol declares two public predicates, before/3 and after/3, that are automatically called to handle before and after events. Any object that plays the role of monitor should define one or both of these event handler methods: -

-
before(Object, Message, Sender) :-
-    ... .
-
-after(Object, Message, Sender) :-
-    ... .
-

-The arguments in both methods are instantiated by the message sending mechanisms when a spied event occurs. For example, assume that we want to define a monitor called tracer that will track any message sent to an object by printing a describing text to the standard output. Its definition could be something like:

-
:- object(tracer,
-    implements(monitoring)).
-
-    before(Object, Message, Sender) :-
-        write('call: '), writeq(Object), write(' <-- '), writeq(Message),
-        write(' from '), writeq(Sender), nl.
-
-    after(Object, Message, Sender) :-
-        write('exit: '), writeq(Object), write(' <-- '), writeq(Message),
-        write(' from '), writeq(Sender), nl.
-
-:- end_object.
-

-Assume that we also have the following object: -

-
:- object(any).
-
-    :- public(bar/1) .
-    :- public(foo/1) .
-
-    bar(bar).
-
-    foo(foo).
-
-:- end_object.
-

-After compiling and loading both objects, we can start tracing every message sent to any object by calling the define_events/5 built-in predicate: -

-
| ?- define_events(_, _, _, _, tracer).
-
-yes
-

-From now on, every message sent to any object will be traced to the standard output stream: -

-
| ?- any::bar(X).
-
-call: any <-- bar(X) from user
-exit: any <-- bar(bar) from user
-X = bar
-
-yes
-

-To stop tracing, we can use the abolish_events/5 built-in predicate: -

-
| ?- abolish_events(_, _, _, _, tracer).
-
-yes
-

-The monitoring protocol declares the event handlers as public predicates. If necessary, protected or private implementation of the protocol may be used in order to change the scope of the event handler predicates. Note that the message sending processing mechanisms are able to call the event handlers irrespective of their scope. Nevertheless, the scope of the event handlers may be restricted in order to prevent other objects from calling them. -

- - - - - - diff --git a/Logtalk/manuals/userman/features.html b/Logtalk/manuals/userman/features.html deleted file mode 100644 index 2b6fa5afd..000000000 --- a/Logtalk/manuals/userman/features.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - - - Logtalk user manual: main features - - - - - - -
Logtalk user manual
-
Logtalk main features
-
-
- - -

Logtalk main features

- -

-Some years ago, I decided that the best way to learn object-oriented programming was to build my own object-oriented language. Prolog always being my favorite language, I chose to extend it with object-oriented capabilities. Eventually this work has lead to the Logtalk system. The first public release of Logtalk 1.x occurred in February of 1995. Based on feedback by users and on the author subsequent work, the second major version went public in July of 1998. -

-

-Although this version of Logtalk shares many ideas and goals with previous 1.x versions, programs written for one version are not compatible with the other (however, conversion from previous versions can easily be accomplished in most cases). This is a consequence of the desire to have a more friendly system, with a very smooth learning curve, bringing Logtalk programming closer to traditional Prolog programming. There are, of course, also other important changes, that result in a more powerful and funnier system. Logtalk 2.x development provides the following features: -

- -

Integration of logic and object-oriented programming

- -
-

-Logtalk tries to bring together the main advantages of these two programming paradigms. On one hand, the object orientation allows us to work with the same set of entities in the successive phases of application development, giving us a way of organizing and encapsulating the knowledge of each entity within a given domain. On the other hand, logic programming allows us to represent, in a declarative way, the knowledge we have of each entity. Together, these two advantages allow us to minimize the distance between an application and its problem domain, turning the writing and maintenance of programming easier and more productive. -

-

-In a more pragmatically view, Logtalk objects provide Prolog with the possibility of defining several namespaces, instead of the traditional Prolog single database, addressing some of the needs of large software projects. -

-
- -

Integration of event-driven and object-oriented programming

- -
-

-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 [Rumbaugh 87, Rumbaugh 88, Fornarino 89, Razek 92]. Other common uses are reflective applications like code debugging or profiling [Maes 87]. -

-
- -

Support for component-based programming

- -
-

-Predicates can be encapsulated inside categories 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. -

-
- -

Support for both prototype and class-based systems

- -
-

-Almost any (if not all) object-oriented languages available today are either class-based or prototype-based [Lieberman 86], with a strong predominance of class-based languages. Logtalk provides support for both hierarchy types. That is, we can have both prototype and class hierarchies in the same application. Prototypes solve a problem of class-based systems where we sometimes have to define a class that will have only one instance in order to reuse a piece of code. Classes solves a dual problem in prototype based systems where it is not possible to encapsulate some code to be reused by other objects but not by the encapsulating object. Stand-alone objects, that is, objects that do not belong to any hierarchy, are a convenient solution to encapsulate code that will be reused by several unrelated objects. -

-
- -

Support for multiple object hierarchies

- -
-

-Languages like Smalltalk-80 [Goldberg 83], Objective-C [Cox 86] and Java [Joy et al. 00] define a single hierarchy rooted in a class usually named Object. This makes it easy to ensure that all objects share a common behavior but also tends to result in lengthy hierarchies where it is difficult to express objects which represent exceptions to default behavior. In Logtalk we can have multiple, independent, object hierarchies. Some of them can be prototype-based while others can be class-based. Furthermore, stand-alone objects provide a simple way to encapsulate utility predicates that do not need or fit in an object hierarchy. -

-
- -

Separation between interface and implementation

- -
-

-This is an expected (should we say standard ?) feature of almost any modern programming language. Logtalk provides support for separating interface from implementation in a flexible way: protocol directives can be contained in an object, a category or a protocol (first-order entities in Logtalk) or can be spread in both objects, categories and protocols. -

-
- -

Private, protected and public inheritance

- -
-

-Logtalk supports private, protected and public inheritance in a similar way to C++ [Stroustrup 86], enabling us to restrict the scope of inherited, imported or implemented predicates (by default inheritance is public). -

-
- -

Private, protected and public object predicates

- -
-

-Logtalk supports data hiding by implementing private, protected and public object predicates in a way similar to C++ [Stroustrup 86]. Private predicates can only be called from the container object. Protected predicates can be called by the container object or by the container descendants. Public predicates can be called from any object. -

-
- -

Parametric objects

- -
-

-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 L&O [McCabe 92], OL(P) [Fromherz 93] or SICStus Objects [SICStus 95]. However, access to parameter values is done via a built-in method instead of making the parameters scope global over the whole object. -

-
- -

High level multi-threading programming support

- -
-

-High level multi-threading programming is available when running Logtalk with selected back-end Prolog compilers, allowing objects to support both synchronous and asynchronous messages. Logtalk allows programmers to take advantage of modern multi-processor and multi-core computers without bothering with the details of creating and destroying threads, implement thread communication, or synchronizing threads. -

-
- -

Smooth learning curve

- -
-

-Logtalk has a smooth learning curve, by adopting standard Prolog syntax and by enabling an incremental learning and use of most of its features. -

-
- -

Compatibility with most Prologs and the ISO standard

- -
-

-The Logtalk system has been designed to be compatible with most Prolog compilers and, in particular, with the ISO Prolog standard [ISO 95]. It runs in almost any computer system with a modern Prolog compiler. -

-
- -

Performance

- -
-

-The current Logtalk implementation works as a pre-processor: Logtalk source files are first compiled to Prolog source files, which are then compiled by the chosen Prolog compiler. Therefore, Logtalk performance necessarily depends on the back-end Prolog compiler. The Logtalk pre-processor respects the programmers choices when writing efficient code that takes advantage of tail recursion and first-argument indexing. -

-

-As an object-oriented language, Logtalk uses both static binding and dynamic binding for matching messages and methods. Furthermore, Logtalk entities (objects, protocols, and categories) are independently compiled, allowing for a very flexible programming development. Entities can be edited, compiled, and loaded at runtime, without necessarily implying recompilation of all related entities. -

-

-When dynamic binding is used, the Logtalk runtime engine implements caching of method lookups (including messages to self and super calls), ensuring a performance level close to what could be achieved when using static binding. -

-
- - - - - - diff --git a/Logtalk/manuals/userman/index.html b/Logtalk/manuals/userman/index.html deleted file mode 100644 index 21e12f54f..000000000 --- a/Logtalk/manuals/userman/index.html +++ /dev/null @@ -1,312 +0,0 @@ - - - - - - - - Logtalk user manual: index - - - - - - -
Logtalk user manual
-
Index
-
-
- - -

User Manual

- -
-
Logtalk features
-
Logtalk nomenclature
-
-
-
Message sending
-
Objects
-
Protocols
-
Categories
-
Predicates
-
Inheritance
-
Event-driven programming
-
Multi-threading programming
-
Error handling
-
-
-
Documenting Logtalk programs
-
-
-
Installing Logtalk
-
Running and debugging Logtalk programs
-
Programming in Logtalk
-
- -

Logtalk features

- -
-
Integration of logic and object-oriented programming
-
Integration of event-driven and object-oriented programming
-
Support for component-based programming
-
Support for both prototype and class-based systems
-
Support for multiple object hierarchies
-
Separation between interface and implementation
-
Private, protected, and public inheritance
-
Private, protected, and public object predicates
-
Parametric objects
-
High level multi-threading programming support
-
Smooth learning curve
-
Compatibility with most Prologs and the ISO standard
-
Performance
-
- -

Logtalk nomenclature

- -
-
C++ nomenclature
-
Java nomenclature
-
- -

Message sending

- -
-
Operators used in message sending
-
Sending a message to an object
-
Broadcasting
-
Sending a message to self
-
Calling an overridden predicate definition
-
Message sending and event generation
-
Message sending performance
-
- -

Objects

- -
-
Objects, prototypes, classes, and instances
-
Prototypes
-
Classes
-
Defining a new object
-
Parametric objects
-
Finding defined objects
-
Creating a new object in runtime
-
Abolishing an existing object
-
Object directives
-
Object initialization
-
Synchronized objects
-
Dynamic objects
-
Object dependencies
-
Object documentation
-
Object relationships
-
Object properties
-
Built-in objects
-
The built-in pseudo-object user
-
The built-in object debugger
-
The built-in object logtalk
-
- -

Protocols

- -
-
Defining a new protocol
-
Finding defined protocols
-
Creating a new protocol in runtime
-
Abolishing an existing protocol
-
Protocol directives
-
Protocol initialization
-
Dynamic protocols
-
Protocol documentation
-
Protocol relationships
-
Protocol properties
-
Implementing protocols
-
Built-in protocols
-
The built-in protocol monitoring
-
- -

Categories

- -
-
Defining a new category
-
Finding defined categories
-
Creating a new category in runtime
-
Abolishing an existing category
-
Category directives
-
Category initialization
-
Dynamic categories
-
Category dependencies
-
Category documentation
-
Category relationships
-
Category properties
-
Importing categories
-
Using category predicates
-
- -

Predicates

- -
-
Declaring predicates
-
Scope directives
-
Mode directive
-
Meta-predicate directive
-
Discontiguous directive
-
Dynamic directive
-
Operator directive
-
Uses directive
-
Alias directive
-
Documenting directive
-
Defining predicates
-
Object predicates
-
Category predicates
-
Meta-predicates
-
Definite clause grammars
-
Built-in object predicates (methods)
-
Execution context methods
-
Database methods
-
Meta-call methods
-
All solutions methods
-
Reflection methods
-
Definite clause grammar parsing methods
-
Term expansion methods
-
Predicate properties
-
Finding declared predicates
-
Calling Prolog built-in predicates
-
Calling Prolog non-standard meta-predicates
-
- -

Inheritance

- -
-
Protocol inheritance
-
Search order for prototype hierarchies
-
Search order for class hierarchies
-
Implementation inheritance
-
Search order for prototype hierarchies
-
Search order for class hierarchies
-
Inheritance versus predicate redefinition
-
Public, protected, and private inheritance
-
Composition versus multiple inheritance
-
- -

Event-driven programming

- -
-
Definitions
-
Event
-
Monitor
-
Event generation
-
Communicating events to monitors
-
Performance concerns
-
Monitor semantics
-
Activation order of monitors
-
Event handling
-
Finding defined events
-
Defining new events
-
Abolishing defined events
-
Defining event handlers
-
- -

Multi-threading programming

- -
-
Enabling multi-threading support
-
Enabling objects to make multi-threading calls
-
Multi-threading built-in predicates
-
Proving goals concurrently using threads
-
Proving goals asynchronously using threads
-
One-way asynchronous calls
-
Asynchronous calls and synchronized predicates
-
Synchronizing threads through notifications
-
- -

Error handling

- -
-
Compiler warnings and errors
-
Unknown entities
-
Singleton variables
-
Redefinition of Prolog built-in predicates
-
Redefinition of Logtalk built-in predicates
-
Redefinition of Logtalk built-in methods
-
Misspell calls of local predicates
-
Portability warnings
-
Other warnings and errors
-
Runtime errors
-
Logtalk built-in predicates
-
Logtalk built-in methods
-
Message sending
-
- -

Documenting Logtalk programs

- -
-
Documenting directives
-
Entity directives
-
Predicate directives
-
Processing and viewing documenting files
-
- -

Installing Logtalk

- -
-
Installing Logtalk
-
Hardware & software requirements
-
Computer and operating system
-
Prolog compiler
-
Logtalk installers
-
Source distribution
-
Directories and files organization
-
Configuration files
-
Logtalk compiler and runtime
-
Library
-
Examples
-
Logtalk source files
-
- -

Running and debugging Logtalk programs

- -
-
Running a Logtalk session
-
Starting Logtalk
-
Compiling and loading your programs
-
Compiler flags
-
Realoding and smart compilation of source files
-
Using Logtalk for batch processing
-
Debugging Logtalk programs
-
Compiling objects in debug mode
-
Logtalk Procedure Box model
-
Defining spy points
-
Tracing program execution
-
Debugging using spy points
-
Debugging commands
-
Context-switching calls
-
- -

Programming in Logtalk

- -
-
Writing programs
-
Source files
-
Loader utility files
-
Libraries of source files
-
Portable programs
-
Avoiding common errors
-
Coding style guidlines
-
Logtalk scope
-
- - - - - - diff --git a/Logtalk/manuals/userman/inheritance.html b/Logtalk/manuals/userman/inheritance.html deleted file mode 100644 index cca1f0e9d..000000000 --- a/Logtalk/manuals/userman/inheritance.html +++ /dev/null @@ -1,263 +0,0 @@ - - - - - - - - Logtalk user manual: inheritance - - - - - - -
Logtalk user manual
-
Inheritance
-
-
- - -

Inheritance

- -

-The inheritance mechanisms found on object-oriented programming languages allow us the specialization of previously defined objects, avoiding the unnecessary repetition of code. In the context of logic programming, we can interpret inheritance as a form of theory extension: an object will virtually contain, besides its own predicates, all the predicates inherited from other objects that are not redefined by itself. -

- -

Protocol inheritance

- -

-Protocol inheritance refers to the inheritance of predicate declarations (scope directives). These can be contained in objects, in protocols, or in categories. Logtalk supports single and multi-inheritance of protocols: an object or a category may implement several protocols and a protocol may extend several protocols. -

- -

Search order for prototype hierarchies

- -

-The search order for predicate declarations is first the object, second the implemented protocols (and the protocols that these may extend), third the imported categories (and the protocols that they may implement), and last the objects that the object extends. This search is performed in a depth-first way. When an object inherits two different declarations for the same predicate, by default only the first one will be considered. -

- -

Search order for class hierarchies

- -

-The search order for predicate declarations starts in the object classes. Following the classes declaration order, the search starts in the classes implemented protocols (and the protocols that these may extend), third the classes imported categories (and the protocols that they may implement), and last the superclasses of the object classes. This search is performed in a depth-first way. If the object inherits two different declarations for the same predicate, by default only the first one will be considered. -

- -

Implementation inheritance

- -

-Implementation inheritance refers to the inheritance of predicate definitions. These can be contained in objects or in categories. Logtalk supports multi-inheritance of implementation: an object may import several categories or extend, specialize, or instantiate several objects. -

- -

Search order for prototype hierarchies

- -

-The search order for predicate definitions is similar to the search for predicate declarations except that implemented protocols are ignored (they can only contain predicate directives). -

- -

Search order for class hierarchies

- -

-The search order for predicate definitions is similar to the search for predicate declarations except that implemented protocols are ignored (they can only contain predicate directives). -

- -

Inheritance versus predicate redefinition

- -

-When we define a predicate that is already inherited from other object, the inherited definitions are hidden by the new definitions. This is called overriding inheritance: a local definition overrides any inherited ones. For example, assume that we have the following two objects: -

-
:- object(root).
-
-    :- public(bar/1).
-    :- public(foo/1).
-
-    bar(root).
-
-    foo(root).
-
-:- end_object.
-
-
-:- object(descendant,
-    extends(root)).
-
-    foo(descendant).
-
-:- end_object.
-

-After compiling and loading these objects, we can check the overriding behavior by trying the following queries: -

-
| ?- root::(bar(Bar), foo(Foo)).
-
-Bar = root
-Foo = root
-yes
-
-
-| ?- descendant::(bar(Bar), foo(Foo)).
-
-Bar = root
-Foo = descendant
-yes
-

-However, we can explicitly program other behaviors. Let us see a few examples. -

- -

Specialization inheritance

- -

-Specialization of inherited definitions: the new definition uses the inherited definitions, adding to this new code. This is accomplished by calling the ^^/1 operator in the new definition. -

-
:- object(root).
-
-    :- public(init/0).
-
-    init :-
-        write('root init'), nl.
-
-:- end_object.
-
-
-:- object(descendant,
-    extends(root)).
-
-    init :-
-        write('descendant init'), nl,
-        ^^init.
-
-:- end_object.
-
-
-| ?- descendant::init.
-
-descendant init
-root init
-
-yes
- -

Union inheritance

- -

-Union of the new with the inherited definitions: all the definitions are taken into account, the calling order being defined by the inheritance mechanisms. This can be accomplished by writing a clause that just calls, using the ^^/1 operator, the inherited definitions. The relative position of this clause among the other definition clauses sets the calling order for the local and inherited definitions. -

-
:- object(root).
-
-    :- public(foo/1).
-
-    foo(1).
-    foo(2).
-
-:- end_object.
-
-
-:- object(descendant,
-    extends(root)).
-
-    foo(3).
-    foo(Foo) :-
-        ^^foo(Foo).
-
-:- end_object.
-
-
-| ?- descendant::foo(Foo).
-
-Foo = 3 ;
-Foo = 1 ;
-Foo = 2 ;
-
-no
- -

Selective inheritance

- -

-Hiding some of the inherited definitions, or differential inheritance: this form of inheritance is normally used in the representation of exceptions to generic definitions. Here we will need to use the ^^/1 operator to test and possibly reject some of the inherited definitions. -

-
:- object(bird).
-
-    :- public(mode/1).
-
-    mode(walks).
-    mode(flies).
-
-:- end_object.
-
-
-:- object(penguin,
-    extends(bird)).
-
-    mode(swims).
-    mode(Mode) :-
-        ^^mode(Mode),
-        Mode \= flies.
-
-:- end_object.
-
-
-| ?- penguin::mode(Mode).
-
-Mode = swims ;
-Mode = walks ;
-
-no
- -

Public, protected, and private inheritance

- -

-To make all public predicates declared via implemented protocols, importeds categories, or inherited objects protected or to make all public and protected predicates private we prefix the entity's name with the corresponding keyword. For instance: -

-
:- object(Object,
-    implements(private::Protocol)).       % all the Protocol public and protected
-    ...                                   % predicates become Object's private
-:- end_object.                            % predicates
-

-or: -

-
:- object(Class,
-    specializes(protected::Superclass)).  % all the Superclass public predicates
-    ...                                   % become Object's protected predicates
-:- end_object.
-

-Omitting the scope keyword is equivalent to using the public scope keyword. For example: -

-
:- object(Object,
-    imports(public::Category)).
-    ...
-:- end_object.
-

-This is the same as: -

-
:- object(Object,
-    imports(Category)).
-    ...
-:- end_object.
-

-This way we ensure backward compatibility with older Logtalk versions and a simplified syntax when protected or private inheritance are not used. -

- -

Composition versus multiple inheritance

- -

-It is not possible to discuss inheritance mechanisms without referring to the long and probably endless debate on single versus multiple inheritance. The single inheritance mechanism can be implemented in an very efficient way, but it imposes several limitations on reusing, even if the multiple characteristics we intend to inherit are orthogonal. On the other hand, the multiple inheritance mechanisms are attractive in their apparent capability of modeling complex situations. However, they include a potential for conflict between inherited definitions whose variety does not allow a single and satisfactory solution for all the cases. -

-

-Until now, no solution that we might consider satisfactory for all the problems presented by the multiple inheritance mechanisms has been found. From the simplicity of some extensions that use the Prolog search strategy like [McCabe 92] or [Moss 94] and to the sophisticated algorithms of CLOS [Bobrow 88], there is no adequate solution for all the situations. Besides, the use of multiple inheritance carries some complex problems in the domain of software engineering, particularly in the reuse and maintenance of the applications. All these problems are substantially reduced if we preferably use in our software development composition mechanisms instead of specialization mechanisms [Taenzer 89]. Multiple inheritance can and should be seen more as a useful analysis and project abstraction, than as an implementation technique [Shan 93]. Logtalk provides first-class support for software composition using categories. -

-

-Nevertheless, Logtalk supports multi-inheritance by enabling an object to extend, instantiate, or specialize more than one object. The current Logtalk release provides a predicate directive, alias/3, which may be used to solve some multi-inheritance conflicts. Lastly, it should be noted that the multi-inheritance support does not compromise performance when we use single-inheritance. -

- - - - - - diff --git a/Logtalk/manuals/userman/installing.html b/Logtalk/manuals/userman/installing.html deleted file mode 100644 index b7dced7c3..000000000 --- a/Logtalk/manuals/userman/installing.html +++ /dev/null @@ -1,233 +0,0 @@ - - - - - - - - Logtalk user manual: installing - - - - - - -
Logtalk user manual
-
Installing Logtalk
-
-
- - -

Installing Logtalk

- -

-This page provides an overview of Logtalk installation requirements and instructions and a description of the files contained on the Logtalk distribution. For detailed, up-to-date installation and configuration instructions, please see the README.txt, INSTALL.txt, and CUSTOMIZE.txt files distributed with Logtalk. The broad compatibility of Logtalk, both with Prolog compilers and operating-systems, together with all the possible user scenarios, means that installation can vary from very simple by running an installer or a couple of scripts to the need of patching both Logtalk and Prolog compilers to workaround the lack of strong Prolog standards. -

-

-The preferred installation scenario is to have Logtalk installed in a system-wide location, thus available for all users, and a local copy of user-modifiable files on each user home directory (even when you are the single user of your computer). This scenario allows each user to independently customize Logtalk and to freely modify the provided programming examples. Logtalk installers, installation shell scripts, and Prolog integration scripts favor this installation scenario, although alternative installation scenarios are always possible. -

- -

Hardware & software requirements

- -

Computer and operating system

- -

-Logtalk is compatible with almost any computer/operating-system with a modern Prolog compiler available. Currently, the main development environment is an Apple MacBook Pro running MacOS X. Being written in Prolog and distributed in source form, the only issue regarding operating system compatibility are the end-of-line codes in the source text files! -

- -

Prolog compiler

- -

-In writing Logtalk I have tried to follow the current ISO Prolog Part 1 standard whenever possible. Capabilities needed by Logtalk that are not defined in the ISO standard are: -

-
    -
  • access to predicate properties (dynamic, static, built_in)
  • -
-

-Logtalk needs access to the predicate property built_in to properly compile objects and categories that contain Prolog built-in predicates calls. In addition, some Logtalk built-ins need to know the dynamic/static status of predicates to ensure correct application. The ISO standard for Prolog modules defines a predicate_property/2 predicate that is already implemented by most Prolog compilers. Note that if these capabilities are not built-in the user cannot easily define them.

-

-For optimal performance, Logtalk requires that the Prolog compiler supports first-argument indexing for both static and dynamic code (most modern compilers support this feature). -

-

-Since most Prolog compilers are moving closer to the ISO Prolog standard [ISO 95], it is advisable that you try to use the most recent version of your favorite Prolog compiler. -

- -

Logtalk installers

- -

-Logtalk installers are available for MacOS X, Linux, and Microsoft Windows 2000/XP/2003. Depending on the chosen installer, some tasks (e.g. setting environment variables or integrating Logtalk with some Prolog compilers) may need to be performed manually. -

- -

Source distribution

- -

-Logtalk sources are available in a tar archive compressed with gzip, lgt2xxx.tgz. You may expand the archive by using a decompressing utility or by typing the following commands at the command-line: -

-
% tar -zxvf lgt2xxx.tgz
-

-This will create a sub-directory named lgt2xxx in your current directory. Almost all files in the Logtalk distribution are text files. Different operating-systems use different end-of-line codes for text files. Ensure that your decompressing utility convert the end-of-lines of all text files to match your operating system. -

- -

Directories and files organization

- -

-In the Logtalk installation directory, you will find the following files and directories: -

-
-
BIBLIOGRAPHY.bib - Logtalk bibliography in BibTeX format
-
CUSTOMIZE.txt - Logtalk end-user customization instructions
-
INSTALL.txt - Logtalk installation instructions
-
LICENSE.txt - Logtalk user license
-
QUICK_START.txt - Quick start instructions for those that do not like to read manuals
-
README.txt - several useful information
-
RELEASE_NOTES.txt - release notes for this version
-
UPGRADING.txt - instructions on how to upgrade your programs to the current Logtalk version
-
-
-
compiler
-
NOTES.txt - notes on the current status of the compiler
-
... - compiler source files
-
-
-
configs
-
NOTES.txt - notes on the provided configuration files
-
template.config - template configuration file
-
... - specific configuration files
-
-
-
contributions
-
NOTES.txt - notes on the user-contributed code
-
... - user-contributed code files
-
-
-
examples
-
NOTES.txt - short description of the provided examples
-
bricks
-
-
NOTES.txt - example description and other notes
-
SCRIPT.txt - step by step example tutorial
-
loader.lgt - loader utility file for the example objects
-
... - bricks example source files
-
-
... - other examples
-
-
-
integration
-
NOTES.txt - notes on scripts for Logtalk integration with Prolog compilers
-
... - Prolog integration scripts
-
-
-
libpaths
-
NOTES.txt - description on how to setup library and examples paths
-
libpaths.pl - default library and example paths
-
-
-
library
-
NOTES.txt - short description of the library contents
-
all_loader.lgt - loader utility file for all library entities
-
... - library source files
-
-
-
manuals
-
NOTES.txt - notes on the provided documentation
-
bibliography.html - bibliography
-
glossary.html - glossary
-
index.html - root document for all documentation
-
... - other documentation files
-
-
-
scripts
-
NOTES.txt - notes on scripts for Logtalk user setup, packaging, and installation
-
... - packaging, installation, and setup scripts
-
-
-
wenv
-
NOTES.txt - notes on the text editor syntax configuration files providing syntax coloring for editing Logtalk source files
-
... - syntax coloring configuration files
-
-
-
xml
-
NOTES.txt - notes on the automatic generation of XML documentation files
-
logtalk.css - cascade style sheet file for the HTML output of the XSLT conversion of the XML files
-
logtalk.dtd - Document Type Description file describing the structure of the XML files
-
lgthtml.xsl - transformation style sheet to output HTML code from the XML files
-
... - other XSL files
-
lgt2html.sh - shell script for converting XML documenting files to (X)HTML files
-
... - other script files
-
- -

Configuration files

- -

-Configuration files provide the glue code between the Logtalk compiler/runtime and a Prolog compiler. Each configuration file contains two sets of predicates: ISO Prolog standard predicates and directives not built-in in the target Prolog compiler and Logtalk-specific predicates. -

-

-Logtalk already includes ready to use configuration files for most academic and commercial Prolog compilers. If a configuration file is not available for the compiler that you intend to use, then you need to build a new one, starting from the included template.config file. Start by making a copy of the template file. Carefully check (or complete if needed) each listed definition. If your Prolog compiler conforms to the ISO standard, this task should only take you a few minutes. In most cases, you can borrow code from some of the predefined configuration files. If you are unsure that your Prolog compiler provides all the ISO predicates needed by Logtalk, try to run the system by setting the unknown predicate error handler to report as an error any call to a missing predicate. Better yet, switch to a modern, ISO compliant, Prolog compiler. If you send me your configuration file, with a reference to the target Prolog compiler, maybe I can include it in the next release of Logtalk. -

-

-The configuration files specifies default values for all the Logtalk compiler flags. Most of these compiler flags are described in the next section. A few of these flags have read-only values which cannot be changed at runtime. These are: -

-
-
startup_message
-
Controls the messages printed by Logtalk at startup. Possible flag values are flags(verbose) (the usual default; prints the Logtalk banner and a list of all default compiler flags), flags(compact) (a more compact listing of the default compiler flags), banner (prints only the Logtalk banner), and none (suppress all startup messages; useful for batch processing).
-
-
-
altdirs
-
Allows the use of alternative directories for storing the Prolog files and the XML documenting files resulting from entity compilation. This flag can only be set for Prolog compilers providing the necessary operating-system access predicates for implementing this feature (specifically, a built-in predicate for creating new directories). Possible option values are on and off (the usual default). The names of the alternative directories are specified using the compiler flags tmpdir and xmldir, which are also defined in the configuration files. Make sure the directory names are valid for your operating system before setting this flag on.
-
-
-
break_predicate
-
Informs Logtalk if the Prolog compiler supports a break/0 predicate (which can be used by the Logtalk built-in debugger). Possible flag values are true and false.
-
-
-
encoding_directive
-
Informs Logtalk if the Prolog compiler supports the encoding/1 directive. This directive is used for declaring the text encoding of source files. Possible flag values are unsupported, full (used in both Logtalk source files and compiler generated Prolog files), and source (used only in Logtalk source files).
-
-
-
threads
-
Informs Logtalk if the Prolog compiler provides suitable multi-threading programming support. Possible flag values are unsupported, on, and off. The default flag vale for compatible Prolog compilers is off, i.e. multi-threading programming support is disabled by default.
-
-
-
context_switching_calls
-
Allows context switching calls (<</2) to be either allowed or forbidden. Possible flag values are allow and forbid. The default flag vale is allow.
-
- -

Logtalk compiler and runtime

- -

-The compiler sub-directory contains the Prolog source file(s) that implement the Logtalk compiler and the Logtalk runtime. The compiler and the runtime may be split in two (or more) separate files or combined in a single file, depending on the Logtalk release that you are installing. -

- -

Library

- -

-Starting from version 2.7, Logtalk contains a standard library of useful objects, categories, and protocols. Read the corresponding NOTES.txt file for details about the library contents. -

- -

Examples

- -

-Logtalk 2.x contains new implementations of some of the examples provided with previous 1.x versions. The sources of each one of these examples can be found included in a subdirectory with the same name, inside the directory examples. The majority of these examples include a file named SCRIPT.txt that contains cases of simple utilization. Some examples may depend on other examples and library objects to work properly. Read the corresponding NOTES.txt file for details before running an example. -

- -

Logtalk source files

- -

-Logtalk source files are text files containing entity definitions (objects, categories, or protocols). The extension .lgt is normally used. Logtalk compiles these files to plain Prolog, replacing the .lgt extension with .pl (the default Prolog extension). If your Prolog compiler expects the Prolog source filenames to end with a specific, different extension, you can set it in the corresponding configuration file. -

- - - - - - diff --git a/Logtalk/manuals/userman/messages.html b/Logtalk/manuals/userman/messages.html deleted file mode 100644 index fff6b0df2..000000000 --- a/Logtalk/manuals/userman/messages.html +++ /dev/null @@ -1,248 +0,0 @@ - - - - - - - - Logtalk user manual: message sending - - - - - - -
Logtalk user manual
-
Message sending
-
-
- - -

Message sending

- -

-Messages allows us to call object predicates. Logtalk uses the same nomenclature found in other object-oriented programming languages such as Smalltalk. Therefore, the terms predicate and method are often used interchangeably when refering to predicates defined inside objects and categories. A message must always match a predicate within the scope of the sender object. -

-

-Note that message sending is only the same as calling an object's predicate if the object does not inherit (or import) predicate definitions from other objects (or categories). Otherwise, the predicate definition that will be executed may depend on the relationships of the object with other Logtalk entities. -

- -

Operators used in message sending

- -

-Logtalk uses the following three operators for message sending: -

-
:- op(600, xfx, ::).
-:- op(600,  fx, ::).
-:- op(600,  fx, ^^).
-

-It is assumed that these operators remain active (once the Logtalk compiler and runtime files are loaded) until the end of the Prolog session (this is the usual behavior of most Prolog compilers). Note that these operator definitions are compatible with the pre-defined operators in the Prolog ISO standard. -

- -

Sending a message to an object

- -

-Sending a message to an object is accomplished by using the ::/2 infix operator: -

-
| ?- Object::Message.
-

-The message must match a public predicate declared for the receiving object or a Logtalk/Prolog built-in predicate, otherwise an exception will be thrown (see the Reference Manual for details). The Logtalk and Prolog built-in predicates are implicitly declared as object public predicates (unless redefined inside an object). Care should be taken when using Prolog built-in predicates as messages as different Prolog compilers provide different sets of built-in predicates. In particular, using a Prolog built-in meta-predicate as a message only provides meaningful results when the predicate is overloaded as a Logtalk built-in method; Prolog built-in (meta-)predicates are usually not Logtalk aware. -

- -

Broadcasting

- -

-In the Logtalk context, broadcasting is interpreted as the sending of the same message to a group of objects or the sending of several messages to the same object. Both needs can be achieved by using the message sending method described above. However, for convenience, Logtalk implements an extended syntax for message sending that makes programming easier in these situations. -

-

-If we wish to send several messages to the same object, we can write: -

-
| ?- Object::(Message1, Message2, ...).
-

-This is semantically equivalent to: -

-
| ?- Object::Message1, Object::Message2, ... .
-

-We can also write: -

-
| ?- Object::(Message1; Message2; ...).
-

-This will be semantically equivalent to writing: -

-
| ?- Object::Message1; Object::Message2; ... .
-

-To send the same message to a set of objects we can write: -

-
| ?- (Object1, Object2, ...)::Message.
-

-This will have the same semantics as: -

-
| ?- Object1::Message, Object2::Message, ... .
-

-If we want to use backtracking to try the same message over a set of objects we can write: -

-
| ?- (Object1; Object2, ...)::Message.
-

-This will be equivalent to: -

-
| ?- Object1::Message; Object2::Message; ... .
- -

Sending a message to self

- -

-While defining a predicate, we sometimes need to send a message to self, i.e., to the same object that has received the original message. This is done in Logtalk through the ::/1 prefix operator: -

-
::Message
-

-We can also use the broadcasting constructs with this operator: -

-
::(Message1, Message2, ...)
-

-or: -

-
::(Message1; Message2; ...)
-

-The message must match a public or protected predicate declared for the receiving object, a private predicate within the scope of the sender, or a Logtalk/Prolog built-in predicate otherwise an error will be thrown (see the Reference Manual for details). If the message is sent from inside a category or if we are using private inheritance, then the message may also match a private predicate. -

- -

Calling an overridden predicate definition

- -

-When redefining a predicate, sometimes we need to call the inherited definition in the new code. This functionality, introduced by the Smalltalk language through the super primitive, is available in Logtalk through the ^^/1 prefix operator: -

-
^^Predicate
-

-Most of the time we will use this operator by instantiating the pattern: -

-
Predicate :-
-    ...,            % do something
-    ^^Predicate,    % call inherited definition
-    ... .           % do something more
- -

Message sending and event generation

- -

-Every message sent using ::/2 operator generates two events, one before and one after the message execution. Messages that are sent using the ::/1 (message to self) operator or the ^^/1 super mechanism described above do not generate any events. The rational behind this distinction is that messages to self and super calls are only used internally in the definition of methods or to execute additional messages with the same target object (represented by self). In other words, events are only generated when using an object's public interface; they cannot be used to break object encapsulation. -

-

-If we need to generate events for a public message sent to self, then we just need to write something like: -

-
Predicate :-
-    ...,
-    self(Self),       % get self reference
-    Self::Message,    % send a message to self using ::/2
-    ... .
-

-If we also need the sender of the message to be other than the object containing the predicate definition, we can write: -

-
Predicate :-
-    ...,
-    self(Self),       % send a message to self using ::/2
-    {Self::Message},  % sender will be the pseudo-object user
-    ... .
-

-When events are not used, is possible to turn off event generation on a per object basis by using the events/1 compiler option. See the session on event-driven programming for more details. -

- -

Message sending performance

- -

-Logtalk supports both static binding and dynamic binding. Static binding is used whenever messages are sent (using ::/2) to objects loaded separately using the reload(skip) compiler flag. When that is not the case (or when using ::/1), Logtalk uses dynamic binding coupled with a caching mechanism that avoids repeated lookups of predicate declarations and predicate definitions. This is a solution common to other programming languages supporting dynamic binding. Message lookups are automatically cached the first time a message is sent. Cache entries are automatically removed when loading entities or using Logtalk dynamic features that invalidate the cached lookups. -

-

-Whenever static binding is used, message sending performance is the same as a predicate call in plain Prolog. When discussing Logtalk dynamic binding performance, two distinct cases should be considered: messages sent by the user from the top-level interpreter and messages sent from compiled objects. In addition, the message declaration and definition lookups may, or may not be already cached by the runtime engine. In what follows, we will assume that the message lookups are already cached. -

- -

Translating message processing to predicate calls

- -

-In order to better understand the performance tradeoffs of using Logtalk dynamic binding when compared to plain Prolog or to Prolog module systems, is useful to translate message processing in terms of predicate calls. However, in doing this, we should keep in mind that the number of predicate calls is not necessarily proportional to the time taken to execute them. -

-

-A message sent from a compiled object to another object translates to six predicate calls: -

-
-
cache lookup
-
one predicate call to a dynamic table
-
checking for before events
-
two predicate calls assuming that no events are defined
-
(one of them to the built-in predicate \+/1)
-
method call
-
one predicate call
-
checking for after events
-
two predicate calls assuming that no events are defined
-
(one of them to the built-in predicate \+/1)
-
-

-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 events/1. Doing so, reduces the number of predicate calls from six to just two. -

-

-Messages to self and super calls are transparent regarding events and, as such, imply only two predicate calls (the cache lookup and the method call). -

-

-When a message is sent by the user from the top-level interpreter, Logtalk needs to perform a runtime translation of the message in order to prove the corresponding goal. For user-defined messages/predicates, the runtime translation overhead corresponds to seventeen predicate calls. Thus, while sending a message from a compiled object corresponds to six predicate calls, the same message sent by the user from the top-level interpreter results in twenty-three predicate calls. Considering the time taken for the user to type the goal, this overhead is of no practical consequence. -

-

-When a message is not cached, the number of predicate calls depends on the number of steps needed for the Logtalk runtime engine to lookup the corresponding predicate scope declaration (to check if the message is valid) and then to lookup a predicate definition for answering the message. -

- -

Processing time

- -

-Not all predicate calls take the same time. Moreover, the time taken to process a specific predicate call depends on the Prolog compiler implementation details. As such, the only valid performance measure is the time taken for processing a message. -

-

-The usual way of measuring the time taken by a predicate call is to repeat the call a number of times and than to calculate the average time. A sufficient large number of repetitions would hopefully lead to an accurate measure. Care should be taken to subtract the time taken by the repetition code itself. In addition, we should be aware of any limitations of the predicates used to measure execution times. One way to make sense of numbers we get is to repeat the test with the same predicate using plain Prolog and with the predicate encapsulated in a module. -

-

-A simple predicate for helping benchmarking predicate calls could be: -

-
benchmark(N, Goal) :-
-    repeat(N),
-        call(Goal),
-    fail.
-
-benchmark(_, _).
-

-The rational of using a failure-driven loop is to try to avoid any interference on our timing measurements from garbage-collection or memory expansion mechanisms. Based on the predicate benchmark/2, we may define a more convenient predicate for performing our benchmarks. For example: -

-
benchmark(Goal) :-
-    N = 10000000,                   % some sufficiently large number of repetitions
-    write('Number of repetitions: '), write(N), nl,
-    get_cpu_time(Seconds1),         % replace by your Prolog-specific predicate
-    benchmark(N, Goal),
-    get_cpu_time(Seconds2),
-    Average is (Seconds2 - Seconds1)/N,
-    write('Average time per call: '), write(Average), write(' seconds'), nl,
-    Speed is 1.0/Average,
-    write('Number of calls per second: '), write(Speed), nl.
-

-We can get a baseline for our timings by doing: -

-
| ?- benchmark(true).
-

-For comparing message sending performance across several Prolog compilers, we would call the benchmark/1 predicate with a suitable argument. For example: -

-
| ?- benchmark(list::length([1, 2, 3, 4, 5, 6, 7, 8, 9, 0], _)).
-

-For comparing message sending performance with predicate calls in plain Prolog and with calls to predicates encapsulated in modules, we should use exactly the same predicate definition in the three cases. -

-

-It should be stressed that message sending is only one of the factors affecting the performance of a Logtalk application. The strengths and limitations of the chosen Prolog compiler play a crucial role on all aspects of the development, reliability, usability, and performance of a Logtalk application. It is advisable to take advantage of the Logtalk wide compatibility with most Prolog compilers to test for the best match for developing your Logtalk applications. -

- - - - - - diff --git a/Logtalk/manuals/userman/nomenclature.html b/Logtalk/manuals/userman/nomenclature.html deleted file mode 100644 index 5e974c274..000000000 --- a/Logtalk/manuals/userman/nomenclature.html +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - - - Logtalk user manual: nomenclature - - - - - - -
Logtalk user manual
-
Nomenclature
-
-
- - -

Nomenclature

- -

-Depending on your Object-oriented Programming background (or lack of it), you may find Logtalk nomenclature either familiar or at odds with the terms used in other languages. In addition, being a superset of Prolog, terms such as predicate and method are often used interchangeably. Logtalk inherits most of its nomenclature from Smalltalk, arguably (and somehow sadly!) not the most popular OOP language nowadays. In this section, we try to map nomenclatures from popular OOP languages such as C++ and Java to the Logtalk nomenclature. -

- -

C++ nomenclature

- -

-There are several C++ glossaries available on the Internet. The list that follows relates the most commonly used C++ terms with their Logtalk equivalents. -

- -
-
abstract class
-
Logtalk uses a operational definition of abstract class: any class that does not inherit a method for creating new instances is an abstract class. Moreover, Logtalk supports interfaces/protocols, which are often a better way to provide the functionality of C++ abstract classes.
-
-
-
base class
-
Logtalk uses the term superclass with the same meaning.
-
-
-
data member
-
Logtalk uses predicates for representing both behavior and data.
-
-
-
constructor function
-
There are no special methods for creating new objects in Logtalk. Instead, Logtalk provides a built-in predicate, create_object/4, which is often used to define more sophisticated object creation predicates.
-
-
-
derived class
-
Logtalk uses the term subclass with the same meaning.
-
-
-
destructor function
-
There are no special methods for deleting new objects in Logtalk. Instead, Logtalk provides a built-in predicate, abolish_object/1, which is often used to define more sophisticated object deletion predicates.
-
-
-
friend function
-
Not supported in Logtalk. Nevertheless, see the manual section on meta-predicates.
-
-
-
instance
-
In Logtalk, an instance can be either created dynamically at runtime or defined statically in a source file in the same way as classes.
-
-
-
member
-
Logtalk uses the term predicate.
-
-
-
member function
-
Logtalk uses predicates for representing both behavior and data.
-
-
-
nested class
-
Logtalk does not support nested classes.
-
-
-
template
-
Logtalk supports parametric objects, which allows you to get the similar functionality of templates at runtime.
-
-
-
this
-
Logtalk uses the built-in context method self/1 for retrieving the current instance. Logtalk also provides a this/1 method but for returning the class containing the method being executed. Why the name clashes? Well, the notion of self was inherited from Smalltalk, which predates C++.
-
-
-
virtual member function
-
Logtalk allows any predicate defined in a class to be overridden on a descendant class. There is no virtual keyword in Logtalk.
-
- -

Java nomenclature

- -

-There are several Java glossaries available on the Internet. The list that follows relates the most commonly used Java terms with their Logtalk equivalents. -

- -
-
abstract class
-
Logtalk uses a operational definition of abstract class: any class that does not inherit a method for creating new instances is an abstract class. I.e. there is no abstract keyword in Logtalk.
-
-
-
abstract method
-
In Logtalk, you may simply declare a method (predicate) in a class without defining it, leaving its definition to some descendant sub-class.
-
-
-
extends
-
There is no extends keyword in Logtalk. Class inheritance is indicated using specialization relations. Moreover, the extends relation is used in Logtalk to indicate protocol or prototype extension.
-
-
-
interface
-
Logtalk uses the term protocol with the same meaning.
-
-
-
callback method
-
Logtalk supports event-driven programming, the most common use context of callback methods.
-
-
-
class method
-
Class methods may be implemented in Logtalk by using a metaclass for the class and defining the class methods in the metaclass. I.e. class methods are simply instance methods of the class metaclass.
-
-
-
class variable
-
Class variables may be implemented in Logtalk by using a metaclass for the class and defining the class variables in the class. I.e. class variables are simply instance variables of the class metaclass. Moreover, there is no static keyword in Logtalk.
-
-
-
constructor
-
There are no special methods for creating new objects in Logtalk. Instead, Logtalk provides a built-in predicate, create_object/4, which is often used to define more sophisticated object creation predicates.
-
-
-
final
-
There is no final keyword in Logtalk; methods may always be redefined in subclasses (and instances!).
-
-
-
instance
-
In Logtalk, an instance can be either created dynamically at runtime or defined statically in a source file in the same way as classes.
-
-
-
method
-
Logtalk uses the term predicate interchangeably with the term method.
-
-
-
method call
-
Logtalk usually uses the expression message sending for method calls, true to its Smalltalk heritage.
-
-
-
method signature
-
Logtalk selects the method/predicate to execute in order to answer a method call based only on the method name (functor) and number of arguments (arity). Logtalk (and Prolog) are not typed languages in the same sense as Java.
-
-
-
super
-
Instead of a super keyword, Logtalk provides a super operator, ^^/1, for calling overridden methods.
-
-
-
synchronized
-
Logtalk supports multi-threading programming in selected Prolog compilers, including a synchronized/1 predicate directive and a synchronized/0 object (and category) directive. Logtalk allows you to synchronize a predicate, a set of predicates, or all object predicates using per-predicate and per-object locks.
-
-
-
this
-
Logtalk uses the built-in context method self/1 for retrieving the current instance. Logtalk also provides a this/1 method but for returning the class containing the method being executed. Why the name clashes? Well, the notion of self was inherited from Smalltalk, which predates Java.
-
- - - - - - diff --git a/Logtalk/manuals/userman/objects.html b/Logtalk/manuals/userman/objects.html deleted file mode 100644 index f931b2628..000000000 --- a/Logtalk/manuals/userman/objects.html +++ /dev/null @@ -1,442 +0,0 @@ - - - - - - - - Logtalk user manual: objects - - - - - - -
Logtalk user manual
-
Objects
-
-
- - -

Objects

- -

-The main goal of Logtalk objects is the encapsulation and reuse of predicates. Instead of a single database containing all your code, Logtalk objects provide separated namespaces or databases allowing the partitioning of code in more manageable parts. Logtalk does not aim to bring some sort of new dynamic state change concept to Logic Programming or Prolog. -

-

-In Logtalk, the only pre-defined objects are the built-in objects user, debugger, and logtalk, which are described at the end of this section. -

- -

Objects, prototypes, classes, and instances

- -

-There are only three kinds of encapsulation entities in Logtalk: objects, protocols, and categories. Logtalk uses the term object in a broad sense. The terms prototype, parent, class, subclass, superclass, metaclass, and instance always designate an object. Different names are used to emphasize the role played by an object in a particular context. I.e. we use a term other than object when we want to make the relationship with other objects explicit. For example, an object with an instantiation relation with other object plays the role of an instance, while the instantiated object plays the role of a class; an object with a specialization relation other object plays the role of a subclass, while the specialized object plays the role of a superclass; an object with an extension relation with other object plays the role of a prototype, the same for the extended object. A stand-alone object, i.e. an object with no relations with other objects, is always interpreted as a prototype. In Logtalk, entity relations essentially define patterns of code reuse. An entity is compiled accordingly to the roles it plays. -

-

-Logtalk allows you to work from standalone objects to any kind of hierarchy, either class-based or prototype-based. You may use single or multiple inheritance, use or forgo metaclasses, implement reflective designs, use parametric objects, and take advantage of protocols and categories (think components). -

- -

Prototypes

- -

-Prototypes are either self-defined objects or objects defined as extensions to other prototypes with whom they share common properties. Prototypes are ideal for representing one-of-a-kind objects. Prototypes usually represent concrete objects in the application domain. When linking prototypes using extension relations, Logtalk uses the term prototype hierarchies although most authors prefer to use the term hierarchy only with class generalization/specialization relations. In the context of logic programming, prototypes are often the ideal replacement for modules. -

- -

Classes

- -

-Classes are used to represent abstractions of common properties of sets of objects. Classes provide an ideal structuring solution when you want to express hierarchies of abstractions or work with many similar objects. Classes are used indirectly through instantiation. Contrary to most object-oriented programming languages, instances can be created both dynamically at runtime or defined in a source file like other objects. -

- -

Defining a new object

- -

-We can define a new object in the same way we write Prolog code: by using a text editor. Logtalk source files may contain one or more objects, categories, or protocols. If you prefer to define each entity in its own source file, it is recommended that the file be named after the object. By default, all Logtalk source files use the extension .lgt but this is optional and can be set in the configuration files. Intermediate Prolog source files (generated by the Logtalk compiler) have, by default, a .pl extension. Again, this can be set to match the needs of a particular Prolog compiler in the corresponding configuration file. For instance, we may define an object named vehicle and save it in a vehicle.lgt source file which will be compiled to a vehicle.pl Prolog file. -

-

-Object names can be atoms or compound terms (when defining parametric objects, see below). Objects, categories, and protocols share the same name space: we cannot have an object with the same name as a protocol or a category. -

-

-Object code (directives and predicates) is textually encapsulated by using two Logtalk directives: object/1-5 and end_object/0. The most simple object will be one that is self-contained, not depending on any other Logtalk entity: -

-
:- object(Object).
-    ...
-:- end_object.
-

-If an object implements one or more protocols then the opening directive will be: -

-
:- object(Object,
-    implements(Protocol)).
-    ...
-:- end_object.
-

-An object can import one or more categories: -

-
:- object(Object,
-    imports(Category)).
-    ...
-:- end_object.
-

-If an object both implements protocols and imports categories then we will write: -

-
:- object(Object,
-    implements(Protocol),
-    imports(Category)).
-    ...
-:- end_object.
-

-In object-oriented programming objects are usually organized in hierarchies that enable interface and code sharing by inheritance. In Logtalk, we can construct prototype-based hierarchies by writing: -

-
:- object(Prototype,
-    extends(Parent)).
-    ...
-:- end_object.
-

-We can also have class-based hierarchies by defining instantiation and specialization relations between objects. To define an object as a class instance we will write: -

-
:- object(Object,
-    instantiates(Class)).
-    ...
-:- end_object.
-

-A class may specialize another class, its superclass: -

-
:- object(Class,
-    specializes(Superclass)).
-    ...
-:- end_object.
-

-If we are defining a reflexive system where every class is also an instance, we will probably be using the following pattern: -

-
:- object(Class,
-    instantiates(Metaclass),
-    specializes(Superclass)).
-    ...
-:- end_object.
-

-In short, an object can be a stand-alone object or be part of an object hierarchy. The hierarchy can be prototype-based (defined by extending other objects) or class-based (with instantiation and specialization relations). An object may also implement one or more protocols or import one or more categories. -

-

-A stand-alone object (i.e. an object with no extension, instantiation, or specialization relations with other objects) is always compiled as a prototype, that is, a self-describing object. If we want to use classes and instances, then we will need to specify at least one instantiation or specialization relation. The best way to do this is to define a set of objects that provide the basis of a reflective system [Cointe 87, Moura 94]. For example: -

-
:- object(object,               % default root of the inheritance graph
-    instantiates(class)).       % predicates common to all objects
-    ...
-:- end_object.
-
-
-:- object(class,                % default metaclass for all classes
-    instantiates(class),        % predicates common to all instantiable classes
-    specializes(abstract_class)).
-    ...
-:- end_object.
-
-
-:- object(abstract_class,       % default metaclass for all abstract classes
-    instantiates(class),        % predicates common to all classes
-    specializes(object)).
-    ...
-:- end_object.
-

-Note that with these instantiation and specialization relations, object, class, and abstract_class are, at the same time, classes and instances of some class. In addition, each object inherits its own predicates and the predicates of the other two objects without any inheritance loop problems. -

-

-When a full-blown reflective system solution is not needed, the above scheme can be simplified by making an object an instance of itself, i.e. by making a class its own metaclass. For example: -

-
:- object(class,
-    instantiates(class)).
-    ...
-:- end_object.
-

-A third alternative is to use neither metaclasses or reflective designs but instead to take advantage of the built-in object logtalk. This empty object can be used as a dummy root superclass. For example: -

-
:- object(class,
-    specializes(logtalk)).
-    ...
-:- end_object.
-

-We can use, in the same application, both prototype and class-based hierarchies (and freely exchange messages between all objects). We cannot however mix the two types of hierarchies by, e.g., specializing an object that extends another object in this current Logtalk version. -

- -

Parametric objects

- -

-Parametric objects have a compound term for name instead of an atom. This compound term usually contains free variables that can be instantiated when sending a message to the object, thus acting as object parameters. The object predicates can then be coded to depend on the parameter values. When an object state is set at object creation and never changed, parameters provide a better solution than using the object's database via asserts. Parametric objects can also be used to associate a set of predicates to terms that share a common functor and arity. -

-

-In order to give access to an object parameters, Logtalk provides the parameter/2 built-in local method: -

-
:- object(Functor(Arg1, Arg2, ...)).
-
-    ...
-
-    Predicate :-
-        ...,
-        parameter(Number, Value),
-        ... .
-

-An alternative solution is to use the built-in local method this/1. For example: -

-
:- object(foo(Arg)).
-
-    ...
-
-    bar :-
-        ...,
-        this(foo(Arg)),
-        ... .
-

-Both solutions are equally efficient because the runtime cost of the methods this/1 and parameter/2 is negligible. The drawback of this second solution is that we must check all calls of this/1 if we change the object name. Note that we can't use these method with the message sending operators (::/2, ::/1, or ^^/1). -

-

-When storing a parametric object in its own source file, the convention is to name the file after the object, with the object arity appended. For instance, when defining an object named sort(Type), we may save it in a sort_1.lgt text file. This way it is easy to avoid file name clashes when saving Logtalk entities that have the same functor but different arity. -

-

-Compound terms with the same functor and (usually) the same number of arguments as a parametric object identifier may act as proxies to a parametric object. Proxies may be stored on the database as Prolog facts and be used to represent different instantiations of a parametric object identifier. -

- -

Finding defined objects

- -

-We can find, by backtracking, all defined objects by calling the current_object/1 built-in predicate with an uninstantiated variable: -

-
| ?- current_object(Object).
-

-This predicate can also be used to test if an object is defined by calling it with a valid object identifier (an atom or a compound term). -

- -

Creating a new object in runtime

- -

-An object can be dynamically created at runtime by using the create_object/4 built-in predicate: -

-
| ?- create_object(Object, Relations, Directives, Clauses).
-

-The first argument, the name of the new object (a Prolog atom or compound term), should not match any existing entity name. The remaining three arguments correspond to the relations described in the opening object directive and to the object code contents (directives and clauses). -

-

-For instance, the call: -

-
| ?- create_object(foo, [extends(bar)], [public(foo/1)], [foo(1), foo(2)]).
-

-is equivalent to compiling and loading the object: -

-
:- object(foo,
-    extends(bar)).
-
-    :- dynamic.
-
-    :- public(foo/1).
-
-    foo(1).
-    foo(2).
-
-:- end_object.
-

-If we need to create a lot of (dynamic) objects at runtime, then is best to define a metaclass or a prototype with a predicate that will call this built-in predicate to make new objects. This predicate may provide automatic object name generation, name checking, and accept object initialization options. -

- -

Abolishing an existing object

- -

-Dynamic objects can be abolished using the abolish_object/1 built-in predicate: -

-
| ?- abolish_object(Object).
-

-The argument must be an identifier of a defined dynamic object, otherwise an error will be thrown. -

- -

Object directives

- -

-Object directives are used to set initialization goals and object properties and to document an object dependencies on other Logtalk entities. -

- -

Object initialization

- -

-We can define a goal to be executed as soon as an object is (compiled and) loaded to memory with the initialization/1 directive: -

-
:- initialization(Goal).
-

-The argument can be any valid Prolog or Logtalk goal, including a message to other object. For example: -

-
:- object(foo).
-
-    :- initialization(init).
-    :- private(init/0).
-
-    init :-
-        ... .
-
-    ...
-
-:- end_object.
-

-Or: -

-
:- object(assembler).
-
-    :- initialization(control::start).
-    ...
-
-:- end_object.
-

-The initialization goal can also be a message to self in order to call an inherited or imported predicate. For example, assuming that we have a monitor category defining a reset/0 predicate: -

-
:- object(profiler,
-    imports(monitor)).
-
-    :- initialization(::reset).
-    ...
-
-:- end_object.
-

-Note, however, that descendant objects do not inherit initialization directives. In this context, self denotes the object that contains the directive. Also note that by initialization we do not necessarily mean setting an object dynamic state. -

- -

Synchronized objects

- -

-When doing multi-threading programming, is possible to synchronize all the predicates of an object using the synchronized/0 directive in the object source code: -

-
:- synchronized.
-

-This directive results in using internally the same mutex for synchronizing the execution of all defined object predicates. -

- -

Dynamic objects

- -

-Similar to Prolog predicates, an object can be either static or dynamic. An object created during the execution of a program is always dynamic. An object defined in a file can be either dynamic or static. Dynamic objects are declared by using the dynamic/0 directive in the object source code: -

-
:- dynamic.
-

-The directive must precede any predicate directives or clauses. Please be aware that using dynamic code implies a performance hit when compared to static code. We should only use dynamic objects when these need to be abolished during program execution. In addition, note that we can declare and define dynamic predicates within a static object. -

- -

Object dependencies

- -

-Besides the relations declared in the object opening directive, the predicate definitions contained in the object may imply other dependencies. These can be documented by using the calls/1 and the uses/1 directives. -

-

-The calls/1 directive can be used when a predicate definition sends a message that is declared in a specific protocol: -

-
:- calls(Protocol).
-

-If a predicate definition sends a message to a specific object, this dependence can be declared with the uses/1 directive: -

-
:- uses(Object).
-

-These two directives may be used by the Logtalk runtime to ensure that all needed entities are loaded when running an application. -

- -

Object documentation

- -

-An object can be documented with arbitrary user-defined information by using the info/1 directive: -

-
:- info(List).
-

-See the documenting Logtalk programs session for details. -

- -

Object relationships

- -

-Logtalk provides five sets of built-in predicates that enable us to query the system about the possible relationships that an object may have with other entities. -

-

-The built-in predicates instantiates_class/2 and instantiates_class/3 can be used to query all instantiation relations: -

-
| ?- instantiates_class(Instance, Class).
-

-or, if we want to know the instantiation scope: -

-
| ?- instantiates_class(Instance, Class, Scope).
-

-Specialization relations can be found by using either the specializes_class/2 or the specializes_class/3 built-in predicates: -

-
| ?- specializes_class(Class, Superclass).
-

-or, if we want to know the specialization scope: -

-
| ?- specializes_class(Class, Superclass, Scope).
-

-For prototypes, we can query extension relations with the extends_object/2 or the extends_object/3 built-in predicates: -

-
| ?- extends_object(Object, Parent).
-

-or, if we want to know the extension scope: -

-
| ?- extends_object(Object, Parent, Scope).
-

-In order to find which objects import which categories we can use the built-in predicates imports_category/2 or imports_category/3: -

-
| ?- imports_category(Object, Category).
-

-or, if we want to know the importation scope: -

-
| ?- imports_category(Object, Category, Scope).
-

-To find which objects implements which protocols we can use the implements_protocol/2 or the implements_protocol/3 built-in predicates: -

-
| ?- implements_protocol(Object, Protocol).
-

-or, if we want to know the implementation scope: -

-
| ?- implements_protocol(Object, Protocol, Scope).
-

-Note that, if we use an uninstantiated variable for the first argument, we will need to use the current_object/1 built-in predicate to ensure that the entity returned is an object and not a category. -

- -

Object properties

- -

-We can find the properties of defined objects by calling the built-in predicate object_property/2: -

-
| ?- object_property(Object, Property).
-

-An object may have the property static, dynamic, or built_in. Dynamic objects can be abolished in runtime by calling the abolish_object/1 built-in predicate. An object may also have the properties synchronized and threaded, which are related to multi-threading programming. -

- -

Built-in objects

- -

-Logtalk defines some built-in objects that are always available for any application. -

- -

The built-in pseudo-object user

- -

-Logtalk defines a built-in, pseudo-object named user that contains all user predicate definitions not encapsulated in a Logtalk entity. These predicates are assumed to be implicitly declared public. -

- -

The built-in object debugger

- -

-Logtalk defines a built-in object named debugger which implements the Logtalk built-in debugger (see the section on debugging Logtalk programs for details). This object is virtually compiled as a prototype. Programmers may define new prototypes extending debugger in order to implement custom debuggers. -

- -

The built-in object logtalk

- -

-Logtalk defines an empty built-in object named logtalk, which can play the role of both a class and a prototype. It may be used to define class hierarchies without forcing the use of metaclasses or reflective designs, as illustrated above. This object supports the dynamic declaration and definition of predicates (using the dynamic database built-in methods). -

- - - - - - diff --git a/Logtalk/manuals/userman/predicates.html b/Logtalk/manuals/userman/predicates.html deleted file mode 100644 index 04e38a652..000000000 --- a/Logtalk/manuals/userman/predicates.html +++ /dev/null @@ -1,688 +0,0 @@ - - - - - - - - Logtalk user manual: predicates - - - - - - -
Logtalk user manual
-
Predicates
-
-
- - -

Predicates

- -

-Predicate directives and clauses can be encapsulated inside objects and categories. Protocols can only contain predicate directives. -

- -

Declaring predicates

- -

-All object (or category) predicates that we want to access from other objects must be explicitly declared. A predicate declaration must contain, at least, a scope directive. Other directives may be used to document the predicate or to ensure proper compilation of the predicate definitions. -

-

-Predicate directives should always precede the corresponding predicate definitions and/or calls in the source files in order to ensure proper compilation. -

- -

Scope directives

- -

-A predicate can be public, protected, private, or local. Public predicates can be called from any object. Protected predicates can only be called from the container object or from a container descendant. Private predicates can only be called from the container object. Local predicates, like private predicates, can only be called from the container object (or category) but they are invisible to the reflection built-in methods (current_predicate/1 and predicate_property/2) and to the message error handling mechanisms (i.e. sending a message corresponding to a local predicate results in a predicate_declaration existence error, not in a scope error). -

-

-The scope declarations are made using the directives public/1, protected/1, and private/1. For example: -

-
:- public(init/1).
-
-:- protected(valid_init_option/1).
-
-:- private(process_init_options/1).
-

-If a predicate does not have a scope declaration, it is assumed that the predicate is local. Note that we do not need to write scope declarations for all defined predicates. One exception is local dynamic predicates: declaring them as private predicates may allow the Logtalk compiler to generate optimized code for asserting and retracting clauses. -

- -

Mode directive

- -

-Many predicates cannot be called with arbitrary arguments with arbitrary instantiation status. The valid arguments and instantiation modes can be documented by using the mode/2 directive. For instance: -

-
:- mode(member(?term, +list), zero_or_more).
-

-The first argument describes a valid calling mode. The minimum information will be the instantiation mode of each argument. There are four possible values (described in [ISO 95]): -

-
-
+
-
Argument must be instantiated.
-
-
-
Argument must be a free (non-instantiated) variable.
-
?
-
Argument can either be instantiated or free.
-
@
-
Argument will not be modified.
-
-

-These four mode atoms are also declared as prefix operators by the Logtalk compiler. This makes it possible to include type information for each argument like in the example above. Some of the possible type values are: event, object, category, protocol, callable, term, nonvar, var, atomic, atom, number, integer, float, compound, and list. The first four are Logtalk specific. The remaining are common Prolog types. We can also use our own types that can be either atoms or compound terms. -

-

-The second argument documents the number of proofs (or solutions) for the specified mode. The possible values are: -

-
-
zero
-
Predicate always fails.
-
one
-
Predicate always succeeds once.
-
zero_or_one
-
Predicate either fails or succeeds.
-
zero_or_more
-
Predicate has zero or more solutions.
-
one_or_more
-
Predicate has one or more solutions.
-
error
-
Predicate will throw an error (see below).
-
-

-Mode declarations can also be used to document that some call modes will throw an error. For instance, regarding the arg/3 ISO Prolog built-in predicate, we may write: -

-
:- mode(arg(-, -, +), error).
-

-Note that most predicates have more than one valid mode implying several mode directives. For example, to document the possible use modes of the atom_concat/3 ISO built-in predicate we would write: -

-
:- mode(atom_concat(?atom, ?atom, +atom), one_or_more).
-:- mode(atom_concat(+atom, +atom, -atom), zero_or_one).
-

-Some old Prolog compilers supported some sort of mode directives to improve performance. To the best of my knowledge, there is no modern Prolog compiler supporting these kind of directive. The current version of the Logtalk compiler just parses and than discards this directive (however, see the description on synchronized predicates on the multi-threading programming section). Nevertheless, the use of mode directives is a good starting point for documenting your predicates. -

- -

Meta-predicate directive

- -

-Some predicates may have arguments that will be called as goals or closures that will be used for constructing a call. To ensure that these calls and closures will be executed in the correct scope (i.e. in the calling context, this, not in the predicate definition context) we need to use the meta_predicate/1 directive. For example: -

-
:- meta_predicate(findall(*, ::, *)).
-

-The predicate arguments in this directive have the following meaning: -

-
-
::
-
Meta-argument that will be called as a goal.
-
N
-
Meta-argument that will be a closure used to construct a call by appending N arguments at the end. The value of N must be a positive integer.
-
*
-
Normal argument.
-
-

-This is similar to the declaration of meta-predicates in the ISO standard for Prolog modules except that we use the atom :: instead of : to be consistent with the message sending operators. To the best of my knowledge, the use of non-negative integers to specify closures has first introduced on Quintus Prolog for providing information for predicate cross-reference tools. -

-

-The meta_predicate/1 directive must precede the meta-predicate definition and any local calls to the meta-predicate in order to ensure proper compilation. In addition, as each Logtalk entity is independently compiled, this directive must be included in every object or category that contains a definition for the described predicate, even if the predicate declaration is inherited from another entity, to ensure proper compilation of meta-arguments. -

- -

Discontiguous directive

- -

-The clause of an object (or category) predicate may not be contiguous. In that case, we must declare the predicate discontiguous by using the discontiguous/1 directive: -

-
:- discontiguous(foo/1).
-

-This is a directive that we should avoid using: it makes your code harder to read and it is not supported by some Prolog compilers. -

-

-As each Logtalk entity is compiled independently from other entities, this directive must be included in every object or category that contains a definition for the described predicate (even if the predicate declaration is inherited from other entity). -

- -

Dynamic directive

- -

-An object (or category) predicate can be static or dynamic. By default, all object predicates are static. To declare a dynamic predicate we use the dynamic/1 directive: -

-
:- dynamic(foo/1).
-

-This directive may also be used to declare dynamic grammar rule non-terminals. As each Logtalk entity is compiled independently from other entities, this directive must be included in every object or category that contains a definition for the described predicate (even if the predicate declaration is inherited from other entity). If we omit the dynamic declaration then the predicate definition will be compiled to static code. Note that any static object may declare and define dynamic predicates. -

- -

Operator directive

- -

-An object (or category) predicate can be declared as an operator using the familiar op/3 directive: -

-
:- op(Priority, Specifier, Operator).
-

-Operators are local to the object (or category) where they are declared. This means that, if you declare a public predicate as an operator, you cannot use operator notation when sending to an object (where the predicate is visible) the respective message (as this would imply visibility of the operator declaration in the context of the sender of the message). If you want to declare global operators and, at the same time, use them inside an entity, just write the corresponding directives at the top of your source file, before the entity opening directive. -

-

-When the same operators are used on several entities within the same source file, the corresponding directives must appear before any entity that uses them. However, this results in a global scope for the operators. If you prefer the operators to be local to the source file, just undefine them at the end of the file. For example: -

-
:- op(400, xfx, implies).  % before any entity that uses the operator
-
-...
-
-:- op(0, xfx, implies).    % after all entities that used the operator
- -

Uses directive

- -

-When a predicate makes heavy use of predicates defined on other objects, its clauses can be excessively verbose due to all the necessary message sending constructs. Consider the following example: -

-
foo :-
-    ...,
-    findall(X, list::member(X, L), A),
-    list::append(A, B, C),
-    list::select(Y, C, R),
-    ...
-

-Logtalk provides a directive, uses/2, which allows us to simplify the code above. The usage template for this directive is: -

-
:- uses(Object, [Functor1/Arity1, Functor2/Arity2, ...]).
-

-Rewriting the code above using this directive results in a simplified and more easily readable predicate definition: -

-
:- uses(list,
-    [append/3, member/2, select/3]).
-
-    foo :-
-        ...,
-        findall(X, member(X, L), A),
-        append(A, B, C),
-        select(Y, C, R),
-        ...
-

-Logtalk supports an extended version of this directive that allows the declaration of predicate alias using the notation Predicate::Alias. For example: -

-
:- uses(btrees, [new/1::new_btree/1]).
-:- uses(queues, [new/1::new_queue/1]).
-

-You may use this extended version for solving conflicts between predicates declared on several uses/2 directives or just for giving new names to the predicates that will be more meaningful on their using context. -

-

-The uses/2 directive allows simpler predicate definitions as long as there are no conflicts between the predicates declared in the directive and the predicates defined in the object (or category) containing the directive. A predicate (or its alias if defined) cannot be listed in more than one uses/2 directive. In addition, a uses/2 directive cannot list a predicate (or its alias if defined) which is defined in the object (or category) containing the directive. Any conflicts are reported by the Logtalk pre-processor as compilation errors. -

-

-In the current Logtalk version, the omission of the Object:: prefix is not supported when the predicate call occurs as an argument of a user-defined meta-predicate (Logtalk specified meta-predicates and Prolog non-standard meta-predicates declared in the config files pose no problem). -

- -

Alias directive

- -

-Logtalk allows the definition of an alternative name for an inherited or imported predicate (or for an inherited or imported grammar rule non-terminal) through the use of the alias/3 directive: -

-
:- alias(Entity, Predicate, Alias).
-

-This directive can be used in objects, protocols, or categories. The first argument, Entity, must be an entity referenced in the opening directive of the entity contain the alias/3 directive. It can be an implemented protocol, an imported category, an extended prototype, an instantiated class, or a specialized class. The second and third arguments are predicate indicators (or grammar rule non-terminal indicators). -

-

-A common use for the alias/3 directive is to give an alternative name to an inherited predicate in order to improve readability. For example: -

-
:- object(square,
-    extends(rectangle)).
-
-    :- alias(rectangle, width/1, side/1).
-
-    ...
-
-:- end_object.
-

-The directive allows both width/1 and side/1 to be used as messages to the object square. Thus, using this directive, there is no need to explicitly declare and define a "new" side/1 predicate. Note that the alias/3 directive does not rename a predicate, only provides an alternative, additional name; the original name continues to be available. -

-

-Another common use for this directive is to solve conflicts when two inherited predicates have the same functor and arity. We may want to call the predicate which is masked out by the Logtalk lookup algorithm (see the Inheritance section) or we may need to call both predicates. This is simply accomplished by using the alias/3 directive to give alternative names to masked out or conflicting predicates. Consider the following example: -

-
:- object(my_data_structure,
-    extends(list, set)).
-
-    :- alias(list, member/2, list_member/2).
-    :- alias(set, member/2, set_member/2).
-
-    ...
-
-:- end_object.
-

-Assuming that both list and set objects define a member/2 predicate, without the alias/3 directives, only the definition of member/2 predicate in the object list would be visible on the object my_data_structure, as a result of the application of the Logtalk predicate lookup algorithm. By using the alias/3 directives, all the following messages would be valid (assuming a public scope for the predicates): -

-
| ?- my_data_structure::list_member(X, L).    % uses list member/2
-
-| ?- my_data_structure::set_member(X, L).     % uses set member/2
-
-| ?- my_data_structure::member(X, L).         % uses list member/2
-

-When used this way, the alias/3 directive provides functionality similar to programming constructs of other object-oriented languages which support multi-inheritance (the most notable example probably being the renaming of inherited features in Eiffel). -

-

-Note that the alias/3 directive never hides a predicate which is visible on the entity containing the directive as a result of the Logtalk lookup algorithm. However, it may be used to make visible a predicate which otherwise would be masked by another predicate, as illustrated in the above example. -

-

-The alias/3 directive may also be used to give access to an inherited predicate, which otherwise would be masked by another inherited predicate, while keeping the original name as follows: -

-
:- object(my_data_structure,
-    extends(list, set)).
-
-    :- alias(list, member/2, list_member/2).
-    :- alias(set, member/2, set_member/2).
-
-    member(X, L) :-
-        ::set_member(X, L).
-
-    ...
-
-:- end_object.
-

-Thus, when sending the message member/2 to my_data_structure, the predicate definition in set will be used instead of the one contained in list. -

- -

Documenting directive

- -

-A predicate can be documented with arbitrary user-defined information by using the info/2 directive: -

-
:- info(Functor/Arity, List).
-

-The second argument is a list of Key is Value terms. See the Documenting Logtalk programs session for details. -

- -

Defining predicates

- -

Object predicates

- -

-We define object predicates as we have always defined Prolog predicates, the only difference be that we have four more control structures (the three message sending operators plus the external call operator) to play with. For example, if we wish to define an object containing common utility list predicates like append/2 or member/2 we could write something like: -

-
:- object(list).
-
-    :- public(append/3).
-    :- public(member/2).
-
-    append([], L, L).
-    append([H| T], L, [H| T2]) :-
-        append(T, L, T2).
-
-    member(H, [H| _]).
-    member(H, [_| T]) :-
-        member(H, T).
-
-:- end_object.
-

-Note that, abstracting from the opening and closing object directives and the scope directives, what we have written is plain Prolog. Calls in a predicate definition body default to the local predicates, unless we use the message sending operators or the external call operator. This enables easy conversion from Prolog code to Logtalk objects: we just need to add the necessary encapsulation and scope directives to the old code. -

- -

Category predicates

- -

-Because a category can be imported by several different objects, dynamic private predicates must be called using the ::/1 message sending operator. This ensures that the correct predicate definition will be used. For example, if we want to define a category implementing variables using destructive assignment we could write: -

-
:- category(variable).
-
-    :- public(get/2).
-    :- public(set/2).
-
-    :- private(value_/2).
-    :- dynamic(value_/2).
-
-    get(Var, Value) :-
-        ::value_(Var, Value).
-
-    set(Var, Value) :-
-        ::retractall(value_(Var, _)), 
-        ::asserta(value_(Var, Value).
-
-:- end_category.
-

-This way, each importing object will have its own definition for the value_/2 private predicate. Furthermore, the get/2 and set/2 predicates will always access/update the correct definition, contained in the object receiving the messages. -

-

-A category may only contain clauses for static predicates. Nevertheless, as the example above illustrates, there are no restrictions in declaring and calling dynamic predicates from inside a category. -

- -

Meta-predicates

- -

-Meta-predicates may be defined inside objects (and categories) as any other predicate. A meta-predicate is declared using the meta_predicate/1 directive as described earlier on this section. When defining a meta-predicate, the arguments in the clause heads corresponding to the meta-arguments must be variables. All meta-arguments are called in the context of the object calling the meta-predicate (either directly or through message sending). -

-

-Some meta-predicates have meta-arguments which are not goals but closures. Logtalk supports the definition of meta-predicates that are called with closures instead of goals as long as the definition uses the Logtalk built-in predicate call/N to call the closure with the addtional arguments. For example: -

-
:- public(all_true/2).
-:- meta_predicate(all_true(1, *)).
-
-all_true(_, []).
-all_true(Closure, [Arg| Args]) :-
-    call(Closure, Arg),
-    all_true(Closure, Args).
-

-Note that the meta-predicate directive specifies that the closure will be extended with exactly one extra argument. -

- -

Definite clause grammars

- -

-Definite clause grammar rules provide a convenient notation to represent the rewrite rules common of most grammars in Prolog. In Logtalk, definite clause grammar rules can be encapsulated in objects and categories. Currently, the ISO/IEC WG17 group is working on a draft specification for a definite clause grammars Prolog standard. Therefore, in the mean time, Logtalk follows the common practice of Prolog compilers supporting definite clause grammars, extending it to support calling grammar rules contained in categories and objects. A common example of a definite clause grammar is the definition of a set of rules for parsing simple arithmetic expressions: -

-
:- object(calculator).
-
-    :- public(parse/2).
-
-    parse(Expression, Value) :-
-        phrase(expr(Value), Expression).
-
-    expr(Z) --> term(X), "+", expr(Y), {Z is X + Y}.
-    expr(Z) --> term(X), "-", expr(Y), {Z is X - Y}.
-    expr(X) --> term(X).
-
-    term(Z) --> number(X), "*", term(Y), {Z is X * Y}.
-    term(Z) --> number(X), "/", term(Y), {Z is X / Y}.
-    term(Z) --> number(Z).
-
-    number(C) --> "+", number(C).
-    number(C) --> "-", number(X), {C is -X}.
-    number(X) --> [C], {0'0 =< C, C =< 0'9, X is C - 0'0}.
-
-:- end_object. 
-

-The predicate phrase/2 called in the definition of predicate parse/2 above is a Logtalk built-in method, similar to the predicate with the same name found on most Prolog compilers that support definite clause grammars. After compiling and loading this object, we can test the grammar rules with calls such as the following one: -

-
| ?- calculator::parse("1+2-3*4", Result).
-
-Result = -9
-yes
-

-In most cases, the predicates resulting from the translation of the grammar rules to regular clauses are not declared. Instead, these predicates are usually called by using the built-in methods phrase/2 and phrase/3 as shown in the example above. When we want to send the messages phrase/2 and phrase/3 to self or to another object, the non-terminal used as first argument must be within the scope of the sender. For the above example, assuming that we want the predicate corresponding to the expr//1 non-terminal to be public, the corresponding scope directive would be: -

-
:- public(expr//1). 
-

-The // infix operator used above tells the Logtalk compiler that the scope directive refers to a grammar rule non-terminal, not to a predicate. The idea is that the predicate corresponding to the translation of the expr//1 non-terminal will have a number of arguments equal to one plus the number of additional arguments necessary for processing the subjacent lists of tokens. -

-

-In the body of a grammar rule, we can call rules that are inherited from ancestor objects, imported from categories, or contained in other objects. This is accomplished by using non-terminals as messages. Using a non-terminal as a message to self allows us to call grammar rules in categories and ancestor objects. To call grammar rules encapsulated in other objects, we use a non-terminal as a message to those objects. Consider the following example, containing grammar rules for parsing natural language sentences: -

-
:- object(sentence,
-    imports(determiners, nouns, verbs)).
-
-    :- public(parse/2).
-
-    parse(List, true) :-
-        phrase(sentence, List).
-    parse(_, false).
-
-    sentence --> noun_phrase, verb_phrase.
-
-    noun_phrase --> ::determiner, ::noun.
-    noun_phrase --> ::noun.
-
-    verb_phrase --> ::verb.
-    verb_phrase --> ::verb, noun_phrase.
-
-:- end_object.
-

-The categories imported by the object would contain the necessary grammar rules for parsing determiners, nouns, and verbs. For example: -

-
:- category(determiners).
-
-    :- private(determiner//0).
-
-    determiner --> [the].
-    determiner --> [a].
-
-:- end_category.
-

-Along with the message sending operators (::/1 and ::/2), we may also use other control constructs such as \+/1, !/0, ;/2, ->/2, and {}/1 in the body of a grammar. In addition, grammar rules may contain meta-calls (a variable taking the place of a non-terminal), which are translated to calls of the built-in method phrase/3. -

-

-You may have noticed that Logtalk defines {}/1 as a control construct for bypassing the compiler when compiling a clause body goal. As exemplified above, this is the same control construct that is used in grammar rules for bypassing the expansion of rule body goals when a rule is converted into a clause. Both control constructs can be combined in order to call a goal from a grammar rule body, while bypassing at the same time the Logtalk compiler. Consider the following example: -

-
bar :-
-    write('bar predicate called'), nl.
-
-
-:- object(bypass).
-
-    :- public(foo//0).
-
-    foo --> {{bar}}.
-
-:- end_object.
-

-After compiling and loading this code, we may try the following query: -

-
| ?- bypass::phrase(foo, _, _).
-
-bar predicate called
-yes
-

-This is the expected result as the expansion of the grammar rule into a clause leaves the {bar} goal untouched, which, in turn, is converted into the goal bar when the clause is compiled. -

-

-A grammar rule non-terminal may be declared as dynamic or discontiguous, as any object predicate, using the same Functor//Arity notation illustrated above for the scope directives. In addition, grammar rule non-terminals can be documented using the info/2 directive, as in the following example: -

-
:- public(sentence//0).
-
-:- info(sentence//0, [
-    comment is 'Rewrites a sentence into a noun phrase and a verb phrase.']).
- -

Built-in object predicates (methods)

- -

-Logtalk defines a set of built-in object predicates or methods to access message execution context, to find sets of solutions, to inspect objects and for database handling. Similar to Prolog built-in predicates, these built-in methods should not be redefined. -

- -

Execution context methods

- -

-Logtalk defines four built-in methods to access an object execution context. These methods (with the possible exception of parameter/2) are translated to a single unification performed at compile time with a clause head context argument. Therefore, they can be freely used without worrying about performance penalties. When called from inside a category, these methods refer to the execution context of the object importing the category. -

-

-To find the object that received the message under execution we may use the self/1 method. We may also retrieve the object that has sent the message under execution using the sender/1 method. -

-

-The method this/1 enables us to retrieve the name of the object that contains the code that is being executed instead of using the name directly. This helps to avoid breaking the code if we decide to change the object name and forget to change the name references. -

-

-Here is a short example including calls to these three object execution context methods: -

-
:- object(test).
-
-    :- public(test/0).
-
-    test :-
-        this(This), 
-        write('Executing  a predicate definition contained in '), writeq(This), nl,
-        self(Self),
-        write('to answer a message received by '), writeq(Self), nl,
-        sender(Sender),
-        write('that was sent by '), writeq(Sender), nl, nl.
-
-:- end_object.
-
-
-:- object(descendant,
-    extends(test)).
-
-:- end_object.
-

-After compiling and loading these two objects, we can try the following goal: -

-
| ?- descendant::test.
-
-Executing  a predicate definition contained in test
-to answer a message received by descendant
-that was sent by user
-yes
-

-Note that the goals self(Self), sender(Sender), and this(This), being translated to unifications with the clause head context arguments at compile time, are effectively removed from the clause body. This implies that a clause such as: -

-
predicate(Arg) :-
-    self(Self),
-    atom(Arg),
-    ... .
-

-is compiled with the goal atom(Arg) as the first condition on the clause body. As such, the use of these context execution methods do not interfere with the optimizations that some Prolog compilers perform when the first clause body condition is a call to a built-in type-test predicate or a comparison operator. -

-

-For parametric objects, the method parameter/2 enables us to retrieve current parameter values (see the session on parametric objects for a detailed description). For example: -

-
:- object(block(_Color)).
-
-    :- public(test/0).
-
-    test :-
-        parameter(1, Color), 
-        write('Color parameter value  is '), writeq(Color), nl.
-
-:- end_object.
-

-After compiling and loading these two objects, we can try the following goal: -

-
| ?- block(blue)::test.
-
-Color parameter value is blue
-yes
-

-The method parameter/2 is only translated to a compile time unification when used inside objects with its first argument instantiated at compile time. When the first argument is not known at compile time, or when the method is used inside categories, its call implies a call to the built-in Prolog predicate arg/3. Nevertheless, note that calls to parameter/2 from inside categories are inherently problematic: a category may be implemented by several objects, both parametric (with different number of parameters) and non-parametric. Care must be taken to ensure that a parametric object importing such a category match the interpretation of its parameters used in the category. -

- -

Database methods

- -

-Logtalk provides a set of built-in methods for object database handling similar to the usual database Prolog predicates: abolish/1, asserta/1, assertz/1, clause/2, retract/1, and retractall/1. These methods always operate on the database of the object receiving the corresponding message. -

-

-When working with dynamic grammar rule non-terminals, you may use the built-in method expand_term/2 convert a grammar rule into a clause that can than be used with the database methods. -

- -

Meta-call methods

- -

-Logtalk supports the generalizaed call/N predicate as a built-in. This built-in predicate must be used in the implementation of meta-predicates which work with closures instead of goals. -

- -

All solutions methods

- -

-The usual all solutions meta-predicates are pre-defined methods in Logtalk: bagof/3, findall/3, and setof/3. There is also a forall/2 method that implements generate and test loops. -

- -

Reflection methods

- -

-Logtalk provides two built-in methods for inspecting object predicates: predicate_property/2, which returns predicate properties and current_predicate/1, which enables us to query about predicate definitions. See below for a more detailed description of both methods. -

- -

Definite clause grammar parsing methods

- -

-Logtalk supports two definite clause grammar parsing built-in methods, phrase/2 and phrase/3, with definitions similar to the predicates with the same name found on most Prolog compilers that support definite clause grammars. -

- -

Term expansion methods

- -

-Logtalk supports a expand_term/2 built-in method for expanding a term into another. This method is mostly used to translate grammar rules into Prolog clauses. It can be customized, e.g. for bypassing the default Logtalk grammar rule translator, by defining clause for the predicate term_expansion/2. -

- -

Predicate properties

- -

-We can find the properties of visible predicates by calling the predicate_property/2 built-in method. For example: -

-
| ?- bar::predicate_property(foo(_), Property).
-

-Note that this method respects the predicate's scope declarations. For instance, the above call will only return properties for public predicates. -

-

-An object's set of visible predicates is the union of all the predicates declared for the object with all the built-in methods and all the Logtalk and Prolog built-in predicates. -

-

-Possible predicate properties values are: -

-
    -
  • public, protected, private
  • -
  • static, dynamic
  • -
  • built_in
  • -
  • meta_predicate(Mode)
  • -
  • declared_in(Entity)
  • -
  • defined_in(Entity)
  • -
  • non_terminal(NonTerminal//Arity)
  • -
  • alias(Predicate)
  • -
  • synchronized
  • -
-

-The properties declared_in/1 and defined_in/1 do not apply to built-in methods and Logtalk or Prolog built-in predicates. Note that if a predicate is declared in a category imported by the object, it will be the category name — not the object name — that will be returned by the property declared_in/1. The same goes for protocol declared predicates. -

-

-The predicate property defined_in(Entity) implies that definitions for the predicate are looked up in Entity. This does not necessarily implies that clauses for the predicate exist in Entity; the predicate can simply be false (closed world assumption). -

-

-The property non_terminal/1 only applies to predicates that result from the compilation of grammar rule non-terminals. -

-

-The property alias/1 is returned for predicates that are an alias to other predicate (which is returned in the property argument). -

-

-The property synchronized is returned for predicates that are declared synchronized when using multi-threading programming. -

- - -

Finding declared predicates

- -

-We can find, by backtracking, all visible user predicates by calling the current_predicate/1 built-in method. This method respects the predicate's scope declarations. For instance, the following call: -

-
| ?- some_object::current_predicate(Functor/Arity).
-

-will only return user predicates that are declared public. The predicate property non_terminal/1 may be used to retrieve all grammar rule non-terminals declared for an object. For example: -

-
current_non_terminal(Object, NonTerminal//Args) :-
-    Object::current_predicate(Functor/Arity),
-    functor(Predicate, Functor, Arity),
-    Object::predicate_property(Predicate, non_terminal(NonTerminal//Args)).
-

-Usually, the non-terminal and the corresponding predicate share the same functor but users should not rely on this always being true. -

- -

Calling Prolog built-in predicates

- -

-In predicate definitions, predicate calls which are not prefixed with a message sending operator (either :: or ^^), are compiled to either calls to local predicates or as calls to Logtalk/Prolog built-in predicates. A predicate call is compiled as a call to a local predicate if the object (or category) contains a scope directive, a definition for the called predicate, or a dynamic declaration for it. When the object (or category) does not contain either a definition of the called predicate or a corresponding dynamic declaration, Logtalk tests if the call corresponds to a Logtalk or Prolog built-in predicate. Calling a predicate which is neither a local predicate nor a Logtalk/Prolog built-in predicate results in a compile time warning. This means that, in the following example: -

-
foo :-
-    ...,
-    write(bar),
-    ...
-

-the call to the predicate write/1 will be compiled as a call to the corresponding Prolog built-in predicate unless the object (or category) encapsulating the above definition also contains a predicate named write/1 or a dynamic declaration for the predicate. -

-

-When calling non-standard Prolog built-in predicates, you may run into portability problems while trying your applications with different back-end Prolog compilers (non-standard predicates are often specific to a Prolog compiler). You may use the Logtalk compiler flag portability/1 to help check for problematic calls in your code. -

- -

Calling Prolog non-standard meta-predicates

- -

-Compiling calls to non-standard, Prolog built-in meta-predicates can be tricky for two reasons: first, there is no standard way of checking if a built-in predicate is also a meta-predicate and finding out which are its meta-arguments; second, in some cases, the meta-arguments of a meta-predicate are not goals but closures, used for constructing goals. The way the goals are constructed is specific to the meta-predicate and cannot be reliable inferred by the Logtalk compiler. For meta-predicates whose meta-arguments are directly called as goals, the solution is to explicitly declare them in the corresponding Prolog configuration file using the predicate '$lgt_pl_meta-predicate'/1. For example: -

-
'$lgt_pl_meta_predicate'(call_with_depth_limit(::, *, *)).
-

-Currently, there is no clean workaround for calling non-standard, Prolog built-in meta-predicates whose meta-arguments are used as closures instead of called as goals directly. -

- - - - - - diff --git a/Logtalk/manuals/userman/programming.html b/Logtalk/manuals/userman/programming.html deleted file mode 100644 index 9d81b1bac..000000000 --- a/Logtalk/manuals/userman/programming.html +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - - - Logtalk user manual: programming - - - - - - -
Logtalk user manual
-
Programming in Logtalk
-
-
- - -

Programming in Logtalk

- -

Writing programs

- -

-For a successful programming in Logtalk, you need a good working knowledge of Prolog and an understanding of the principles of object-oriented programming. All guidelines for writing good Prolog code apply as well to Logtalk programming. To those guidelines, you should add the basics of good object-oriented design. -

-

-One of the advantages of a system like Logtalk is that it enable us to use the currently available object-oriented methodologies, tools, and metrics [Champaux 92] in Prolog programming. That said, writing programs in Logtalk is similar to writing programs in Prolog: we define new predicates describing what is true about our domain objects, about our problem solution. We encapsulate our predicate directives and definitions inside new objects, categories and protocols that we create by hand with a text editor or by using the Logtalk built-in predicates. Some of the information collected during the analysis and design phases can be integrated in the objects, categories and protocols that we define by using the available entity and predicate documenting directives. -

- -

Source files

- -

-Logtalk source files may contain any number of objects, categories, protocols, and plain Prolog code. If you prefer to define each entity in its own source file, then it is recommended that the source file be named after the entity identifier. For parametric objects, the identifier arity can be appended to the identifier functor. By default, all Logtalk source files use the extension .lgt but this is optional and can be set in the configuration files. Intermediate Prolog source files (generated by the Logtalk compiler) have, by default, a .pl extension. Again, this can be set to match the needs of a particular Prolog compiler in the corresponding configuration file. For example, we may define an object named vehicle and save it in a vehicle.lgt source file that will be compiled to a vehicle.pl Prolog file. If we have a sort(_) parametric object we can save it on a sort_1.lgt source file that will be compiled to a sort_1.pl Prolog file. This name scheme helps avoid file name conflicts (remember that all Logtalk entities share the same name space). -

-

-Logtalk source files may contain arbitrary Prolog directives and clauses interleaved with Logtalk entity definitions. These directives and clauses will not be compiled by Logtalk and will be copied unchanged to the corresponding Prolog output file. This feature is included to help the integration of Logtalk with Prolog extensions such as, for example, constraint programming extensions. -

- -

Loader utility files

- -

-Most examples directories contain a Logtalk utility file that can be used to load all included source files. These loader utility files are usually named loader.lgt or contain the word "loader" in their name. Loader files are compiled and loaded like any ordinary Logtalk source file. For an example loader file named loader.lgt we would type: -

-
| ?- logtalk_load(loader).
-

-Usually these files contain a call to the Logtalk built-in predicates logtalk_load/1 or logtalk_load/2, wrapped inside an initialization/1 directive. For instance, if your code is split in three Logtalk source files named source1.lgt, source2.lgt, and source3.lgt, then the contents of your loader file could be: -

-
:- initialization(
-    logtalk_load([
-        source1, source2, source3])). 
-

-Another example of directives that are often used in a loader file would be op/3 directives declaring global operators needed by your application. Loader files are also often used for setting compiler options for the source files (this is useful even when you only have a single source file if you always load it with using the same set of compiler options). For example: -

-
:- initialization(
-    logtalk_load(
-        [source1, source2, source3],
-        [underscore_variables(dont_care), portability(warning), xmlspec(xsd)])). 
-

-To take the best advantage of loader files, assert a clause to the dynamic predicate logtalk_library_path/2 for the directory containing your source files, as explained in the next section. -

-

-A common mistake is to try to set compiler options using logtalk_load/2 with a loader file. For example, by writing: -

-
| ?- logtalk_load(loader, [xmlspec(xsd), xslfile('lgtxhtml.xsl')]).
-

-This will not work as you might expect as the compiler options will only be used in the compilation of the loader.lgt file itself and will not affect the compilation of files loaded through the initialization/1 directive contained on the loader file. -

- -

Libraries of source files

- -

-Logtalk defines a library simply as a directory containing source files. Library locations can be specified by asserting clauses to the dynamic predicate logtalk_library_path/2. For example: -

-
| ?- assertz(logtalk_library_path(shapes, '$LOGTALKUSER/examples/shapes/')). 
-

-The first argument of the predicate is used as an alias for the path on the second argument. Library aliases may also be used on the second argument. For example: -

-
| ?- assertz(logtalk_library_path(lgtuser, '$LOGTALKUSER/')),
-     assertz(logtalk_library_path(examples, lgtuser('examples/'))),
-     assertz(logtalk_library_path(viewpoints, examples('viewpoints/'))).
-

-This allows us to load a library source file without the need to first change the current working directory to the library directory and then back to the original directory. For example, in order to load a loader.lgt file, contained in a library named shapes, we just need to type: -

-
| ?- logtalk_load(viewpoints(loader)). 
-

-The best way to take advantage of this feature is to load at startup a source file containing an initialization/1 directive which asserts all the logtalk_library_path/2 clauses needed for all available libraries. This allows us to load library source files or entire libraries without worrying about libraries paths, improving code portability. The directory paths on the second argument must always end with the path directory separator character. -

-

-Unfortunately, a few Prolog compilers do not support the <library>(<source file>) notation. In this case, you will need to set the working directory to be the one that contains the source file in order to load it. The library notation provides functionality similar to the file_search_path/2 mechanism introduced by Quintus Prolog and later adopted by some other Prolog compilers. -

- -

Portable programs

- -

-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 defined built-in predicates. If you need to use built-in predicates 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 interface 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 defined built-in predicates by using the portability/1 compiler flag. -

- -

Avoiding common errors

- -

-Try to write objects and protocol documentation before writing any other code; if you are having trouble documenting a predicate perhaps we need to go back to the design stage. -

-

-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. -

-

-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). -

-

-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. -

-

-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. -

-

-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 read_term/3 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. -

- -

Coding style guidlines

- -

-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. -

- - -

Logtalk scope

- -

-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: -

-
-
Object-oriented programming teaching and researching
-
Logtalk smooth learning curve, combined with support for both prototype and class-based programming, protocols, components 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.
-
-
-
Structured knowledge representations and knowledge-based systems
-
Logtalk objects, coupled with event-driven programming features, enable easy implementation of frame-like systems and similar structured knowledge representations.
-
-
-
Blackboard systems, agent-based systems and systems with complex object relationships
-
Logtalk support for event-driven programming can provide a basis for the dynamic and reactive nature of blackboard type applications.
-
-
-
Highly portable applications
-
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.
-
-
-
Alternative to a Prolog module system
-
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 reuse framework provided by Logtalk object-oriented features.
-
-
-
Integration with other programming languages
-
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.
-
- - - - - - diff --git a/Logtalk/manuals/userman/protocols.html b/Logtalk/manuals/userman/protocols.html deleted file mode 100644 index ea639af21..000000000 --- a/Logtalk/manuals/userman/protocols.html +++ /dev/null @@ -1,238 +0,0 @@ - - - - - - - - Logtalk user manual: protocols - - - - - - -
Logtalk user manual
-
Protocols
-
-
- - -

Protocols

- -

-Protocols enable the separation between interface and implementation: several objects can implement the same protocol and an object can implement several protocols. Protocols may contain only predicate declarations. In some languages the term interface is used with similar meaning. Logtalk allows predicate declarations of any scope within protocols, contrary to some languages that only allow public declarations. -

-

-In Logtalk, the only pre-defined protocol is the built-in protocol monitoring, which is described at the end of this section. -

- -

Defining a new protocol

- -

-We can define a new object in the same way we write Prolog code: by using a text editor. Logtalk source files may contain one or more objects, categories, or protocols. If you prefer to define each entity in its own source file, it is recommended that the file be named after the protocol. By default, all Logtalk source files use the extension .lgt but this is optional and can be set in the configuration files. Intermediate Prolog source files (generated by the Logtalk compiler) have, by default, a .pl extension. Again, this can be set to match the needs of a particular Prolog compiler in the corresponding configuration file. For example, we may define a protocol named listp and save it in a listp.lgt source file that will be compiled to a listp.pl Prolog file. -

-

-Protocol names must be atoms. Objects, categories and protocols share the same name space: we cannot have a protocol with the same name as an object or a category. -

-

-Protocol directives are textually encapsulated by using two Logtalk directives: protocol/1-2 and end_protocol/0. The most simple protocol will be one that is self-contained, not depending on any other Logtalk entity: -

-
:- protocol(Protocol).
-    ...
-:- end_protocol.
-

-If a protocol extends one or more protocols, then the opening directive will be: -

-
:- protocol(Protocol,
-    extends(OtherProtocol)).
-    ...
-:- end_protocol.
- -

Finding defined protocols

- -

-We can find, by backtracking, all defined protocols by using the current_protocol/1 built-in predicate with an uninstantiated variable: -

-
| ?- current_protocol(Protocol).
-

-This predicate can also be used to test if a protocol is defined by calling it with a valid protocol identifier (an atom). -

- -

Creating a new protocol in runtime

- -

-We can create a new (dynamic) protocol in runtime by calling the Logtalk built-in predicate create_protocol/3: -

-
| ?- create_protocol(Protocol, Relations, Directives).
-

-The first argument, the name of the new protocol (a Prolog atom), should not match an existing entity name. The remaining two arguments correspond to the relations described in the opening protocol directive and to the protocol directives. -

-

-For instance, the call: -

-
| ?- create_protocol(ppp, [extends(qqq)], [public(foo/1, bar/1)]).
-

-is equivalent to compiling and loading the protocol: -

-
:- protocol(ppp,
-    extends(qqq)).
-
-    :- dynamic.
-
-    :- public(foo/1, bar/1).
-
-:- end_protocol.
-

-If we need to create a lot of (dynamic) protocols at runtime, then is best to define a metaclass or a prototype with a predicate that will call this built-in predicate in order to provide more sophisticated behavior. -

- -

Abolishing an existing protocol

- -

-Dynamic protocols can be abolished using the abolish_protocol/1 built-in predicate: -

-
| ?- abolish_protocol(Protocol).
-

-The argument must be an identifier of a defined dynamic protocol, otherwise an error will be thrown. -

- -

Protocol directives

- -

-Protocol directives are used to set initialization goals and protocol properties. -

- -

Protocol initialization

- -

-We can define a goal to be executed as soon as a protocol is (compiled and) loaded to memory with the initialization/1 directive: -

-
:- initialization(Goal).
-

-The argument can be any valid Prolog or Logtalk goal, including a message sending call. -

- -

Dynamic protocols

- -

-As usually happens with Prolog code, a protocol can be either static or dynamic. A protocol created during the execution of a program is always dynamic. A protocol defined in a file can be either dynamic or static. Dynamic protocols are declared by using the dynamic/0 directive in the protocol source code: -

-
:- dynamic.
-

-The directive must precede any predicate directives. Please be aware that using dynamic code implies a performance hit when compared to static code. We should only use dynamic protocols when these need to be abolished during program execution. -

- -

Protocol documentation

- -

-A protocol can be documented with arbitrary user-defined information by using the info/1 directive: -

-
:- info(List).
-

-See the documenting Logtalk programs session for details. -

- -

Protocol relationships

- -

-Logtalk provides two sets of built-in predicates that enable us to query the system about the possible relationships that a protocol have with other entities. -

-

-The built-in predicates extends_protocol/2 and extends_protocol/3 return all pairs of protocols so that the first one extends the second: -

-
| ?- extends_protocol(Protocol1, Protocol2).
-

-or, if we want to know the extension scope: -

-
| ?- extends_protocol(Protocol1, Protocol2, Scope).
-

-To find which objects or categories implement which protocols we can call the implements_protocol/2 or implements_protocol/2 built-in predicates: -

-
| ?- implements_protocol(ObjectOrCategory, Protocol).
-

-or, if we want to know the implementation scope: -

-
| ?- implements_protocol(ObjectOrCategory, Protocol, Scope).
-

-Note that, if we use an uninstantiated variable for the first argument, we will need to use the current_object/1 or current_category/1 built-in predicates to identify the kind of entity returned. -

- -

Protocol properties

- -

-We can find the properties of defined protocols by calling the protocol_property/2 built-in predicate: -

-
| ?- protocol_property(Protocol, Property).
-

-A protocol may have the property static, dynamic, or built_in. Dynamic protocols can be abolished in runtime by calling the abolish_protocol/1 built-in predicate. -

- -

Implementing protocols

- -

-Any number of objects or categories can implement a protocol. The syntax is very simple: -

-
:- object(Object,
-    implements(Protocol)).
-    ...
-:- end_object.
-

-or, in the case of a category: -

-
:- category(Object,
-    implements(Protocol)).
-    ...
-:- end_category.
-

-To make all public predicates declared via an implemented protocol protected or to make all public and protected predicates private we prefix the protocol's name with the corresponding keyword. For instance: -

-
:- object(Object,
-    implements(private::Protocol)).
-    ...
-:- end_object.
-

-or: -

-
:- object(Object,
-    implements(protected::Protocol)).
-    ...
-:- end_object.
-

-Omitting the scope keyword is equivalent to writing: -

-
:- object(Object,
-    implements(public::Protocol)).
-    ...
-:- end_object.
-

-The same rules applies to protocols implemented by categories. -

- -

Built-in protocols

- -

-Logtalk defines a built-in protocol that is always available for any application. -

- -

The built-in protocol monitoring

- -

-Logtalk defines a built-in protocol named monitoring that contains declarations for the before/3 and after/3 public event handler predicates. See the event-driven programming section for more details. -

- - - - - - diff --git a/Logtalk/manuals/userman/running.html b/Logtalk/manuals/userman/running.html deleted file mode 100644 index ca5518e54..000000000 --- a/Logtalk/manuals/userman/running.html +++ /dev/null @@ -1,505 +0,0 @@ - - - - - - - - Logtalk user manual: running and debugging programs - - - - - - -
Logtalk user manual
-
Running and debugging programs
-
-
- - -

Running and debugging programs

- -

Running a Logtalk session

- -

-We 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. -

- -

Starting Logtalk

- -

-Depending 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: -

-
    -
  1. Start your Prolog compiler.
  2. -
  3. Load the appropriate configuration file for your compiler. Configuration files for most common Prolog compilers can be found in the configs subdirectory.
  4. -
  5. Load the Logtalk compiler/runtime files contained in the compiler subdirectory.
  6. -
  7. Load the library paths configuration file corresponding to your Logtalk installation contained in the libpaths subdirectory.
  8. -
-

-Note 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 '$lgt_load_prolog_code'/1 in the corresponding configuration file. -

-

-Most 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. -

- -

Compiling and loading your programs

- -

-Your 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 -logtalk_compile/1: -

-
| ?- logtalk_compile([source_file1, source_file2, ...]).
-

-This 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. Note that the predicate argument must be either an entity name or a list of entity names. -

-

-To compile to disk and also load into memory the source files we can use the Logtalk built-in predicate logtalk_load/1: -

-
| ?- logtalk_load([source_file1, source_file2, ...]).
-

-This predicate works in the same way of the predicate logtalk_compile/1 but also loads the compiled files to memory. -

-

-Both 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. -

-

-If you have more than a few source files then you may want to use a loader helper file containing the calls to the logtalk_load/1-2 predicates. Consulting or compiling the loader file will then compile and load all your Logtalk entities into memory (see the next section for details). -

-

-With most Prolog back-end compilers, you can use the shorthand {File} for logtalk_load(File). The use this shorthand should be restricted to the Logtak/Prolog top-level; do not use it from within source files. -

- - -

Compiler flags

- -

-The logtalk_load/1 and logtalk_compile/1 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 set_logtalk_flag/2. 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 logtalk_load/2 or the logtalk_compile/2 built-in predicates. These two predicates accept a list of flag values affecting how a Logtalk source file is compiled and loaded: -

-
| ?- logtalk_compile(Files, Flags).
-

-or: -

-
| ?- logtalk_load(Files, Flags).
-

-In fact, the logtalk_load/1 and logtalk_compile/1 predicates are just shortcuts to the extended versions called with the default compiler flag values. -

-

-We may also change the default flag values from the ones loaded from the config file by using the set_logtalk_flag/2 built-in predicate. For example: -

-
| ?- set_logtalk_flag(xmldocs, off).
-

-The current default flags values can be enumerated using the current_logtalk_flag/2 built-in predicate: -

-
| ?- current_logtalk_flag(xmldocs, Value).
-
-Value = off
-yes
- -

Lint flags

- -
-
unknown(Option)
-
Controls the unknown entity warnings, resulting from loading an entity that references some other entity that is not currently loaded. Possible option values are warning (the usual default) and silent. Note that these warnings are not always avoidable, specially when using reflective designs of class-based hierarchies.
-
-
-
misspelt(Option)
-
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 error, warning (the usual default), and silent (not recommended).
-
-
-
lgtredef(Option)
-
Controls the Logtalk built-in predicate redefinition warnings. Possible option values are warning (the usual default) and silent. These warnings are almost always programming errors.
-
-
-
plredef(Option)
-
Controls the Prolog built-in predicate redefinition warnings. Possible option values are warning (can be very verbose if your code redefines a lot of Prolog built-in predicates) and silent (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.
-
-
-
portability(Option)
-
Controls the non-ISO specified built-in predicate calls warnings. Possible option values are warning and silent (the usual default).
-
-
-
singletons(Option)
-
Controls the singleton variable warnings. Possible option values are warning (the usual default) and silent (not recommended).
-
-
-
underscore_variables(Option)
-
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 dont_care and singletons (the usual default). Note that, depending on your Prolog compiler, the read_term/3 built-in predicate may report variables that start with an underscore as singleton variables. There is no standard behavior, hence this option.
-
- - -

Documenting flags

- -
-
xmldocs(Option)
-
Controls the automatic generation of documenting files in XML format. Possible option values are on (the usual default) and off.
-
-
-
xmldir(Directory)
-
Sets the directory to be used to store the automatically generated XML documenting files. The default value is xml_docs, a sub-directory of the source files directory. Use of this flag implies that the read-only flag altdirs be set to on (not supported in some back-end Prolog compilers).
-
-
-
xmlspec(Option)
-
Defines the XML documenting files specification format. Possible option values are dtd (for the DTD specification; the usual default) and xsd (for the XML Schema specification). Most XSL processors support DTDs but only some of them support XML Schemas.
-
-
-
xmlsref(Option)
-
Sets the reference to the XML specification file in the automatically generated XML documenting files. The default value is local, that is, the reference points to a local DTD or XSD file (respectively, logtalk.dtd or logtalk.xsd), residing in the same directory as the XML file. Other possible values are web (the reference points to an web location, either http://logtalk.org/xml/1.3/logtalk.dtd or http://logtalk.org/xml/1.3/logtalk.xsd), and standalone (no reference to specification files in the XML documenting files). The most appropriated option value depends on the XSL processor you intend to use. Some of them are buggy an may not work with the default option value.
-
-
-
xslfile(File)
-
Sets the XSLT file to be used with the automatically generated XML documenting files. The default value is lgtxml.xsl, which allows the XML files to be viewed by simply opening them with recent versions of web navigators which support XSLT transformations (after copying the lgtxml.xsl and of the logtalk.css files to the directory containing the XML files).
-
- -

Other flags

- -
-
report(Option)
-
Controls reporting of each compiled or loaded object, category, or protocol (including compilation and loading warnings). Possible option values are on (the usual default) and off (silent compilation and loading).
-
-
-
code_prefix(Option)
-
Enables the definition of prefix for all functors of Prolog code generated by the Logtalk compiler. The option value must be an atom; the default value is the empty atom (''). Specifying a code prefix provides a way to solve possible conflicts between Logtalk compiled code and other Prolog code. In addition, some Prolog compilers automatically hide predicates whose functor start with a specific prefix such as the character $.
-
-
-
debug(Option)
-
Controls the compilation of source files in debug mode (the Logtalk built-in debugger can only be used with files compiled in this mode). Possible option values are on and off (the usual default).
-
-
-
reload(Option)
-
Defines the reloading behavior for source files. Possible option values are skip (skip loading of already loaded files) and always (always reload files; the usual default). This option must not be used when recompiling source files in debug mode (see debug/1 option above).
-
-
-
smart_compilation(Option)
-
Controls the use of smart compilation of source files to avoid recompiling files that are unchanged since the last time they are compiled. Possible option values are on and off (the usual default). This option is only supported in some Prolog compilers. It must not be used when recompiling source files in debug mode (see debug/1 option above).
-
-
-
events(Option)
-
Allows Logtalk event-driven programming support to be turned off when not needed in order to improve message sending performance. Possible option values are on and off (the usual default). Objects (and categories) compiled with this option set to off use optimized code for message-sending that does not trigger events. As such, this option can be used on a per-object (or per-category) basis. Note that turning on this option is of no consequence for objects and categories already compiled and loaded.
-
-
-
hook(Object::Functor)
-
Allows the definition of a compiler hook that is called for each term read form a source file. This option specifies both an object (which can be the pseudo-object user) and the functor of a public predicate with two arguments, the first one receiving the term read form the source file and the second one returning a list of terms corresponding to the expansion of the first argument.
-
-
-
tmpdir(Directory)
-
Sets the directory to be used to store the temporary files generated when compiling Logtalk source files. The default value is lgt_tmp, a sub-directory of the source files directory. Use of this flag implies that the read-only flag altdirs be set to on (not supported in some back-end Prolog compilers).
-
- -

Reloading and smart compilation of source files

- -

-As a general rule, reloading source files should never occur in production code and should be handled with care in development code. Reloading a Logtalk source file usually implies reloading the intermediate Prolog file that is generated by the Logtalk compiler. The problem is that there is no standard behavior for reloading Prolog files. For static predicates, almost all Prolog compilers replace the old definitions with the new ones. However, for dynamic predicates, the behavior depends on the Prolog compiler. Most compilers replace the old definitions but some of them simply append the new ones, which usually leads to trouble. See the compatibility notes for the back-end Prolog compiler you intend to use for more information. There is an additional potential problem when using multi-threading programming. Reloading a threaded object does not recreate from scratch its old message queue, which may still be in use (e.g. threads may be waiting on it). -

-

-When using library entities and stable code, you can avoid reloading the corresponding source files (and, therefore, recompiling them) by setting the compiler option reload to skip. For code under development, you can turn on smart compilation of source files to avoid recompiling files that have not been modified since last compilation (assuming that back-end Prolog compiler that you are using supports retrieving of file modification dates). Smart compilation of source files is usually off by default. You can enable it by changing the default flag value in the configuration file, by using the corresponding compiler flag with the compiling and loading built-in predicates, or, for the remaining of a working session, by using the call: -

-
| ?- set_logtalk_flag(smart_compilation, on).
-

-Some caveats that you should be aware. First, some warnings that might be produced when compiling a source file will not show up if the corresponding object file is up-to-date because the source file is not being (re)compiled. Second, if you are using several Prolog compilers with Logtalk, be sure to perform the first compilation of your source files with smart compilation turned off: the intermediate Prolog files generated by the Logtalk compiler may be not compatible across Prolog compilers or even for the same Prolog compiler across operating systems (due to the use of different character encodings or end-of-line characters). -

- -

Using Logtalk for batch processing

- -

-If you use Logtalk for batch processing, you probably want to suppress most, if not all, banners, messages, and warnings that are normally printed by the system. To suppress printing of the Logtalk startup banner and default flags, set the option startup_message in the config file that you are using to none. To suppress printing of compiling and loading messages (including compiling warnings but not compiling error messages), turn off the option report. -

- -

Debugging Logtalk programs

- -

-Logtalk defines a built-in pseudo-object named debugger, which implements debugging features similar to those found on most Prolog compilers. However, there are some differences between the usual implementation of Prolog debuggers and the current implementation of the Logtalk debugger that you should be aware. First, unlike some Prolog debuggers, the Logtalk debugger is not implemented as a meta-interpreter. This translates to a different, although similar, set of debugging features with some limitations when compared with some Prolog debuggers. Second, debugging is only possible for objects compiled in debug mode. When compiling an object in debug mode, Logtalk keeps each clause goal in both source form and compiled form in order to allow tracing of the goal execution. Third, implementation of spy points allows the user to specify the execution context for entering the debugger. This feature is a consequence of the encapsulation of predicates inside objects. -

- -

Compiling entities in debug mode

- -

-Compilation of source files in debug mode is controlled by the compiler flag debug. The default value for this flag, usually off, is defined in the config files. Its value may be changed at runtime by writing: -

-
| ?- set_logtalk_flag(debug, on).
-
-yes
-

-In alternative, if we want to compile only some entities in debug mode, we may instead write: -

-
| ?- logtalk_load([file1, file2, ...], [debug(on)]).
-

-The compiler flag smart_compilation is automatically turned off whenever the debug flag is turned on at runtime. This is necessary because debug code would not be generated for files previously compiled in normal mode if there is no changes to the source files. However, note that you should be careful to not turn both flags on at the same time in a config file. -

-

We may check or enumerate, by backtracking, all loaded entities compiled in debug mode as follows: -

-
| ?- debugger::debugging(Entity).
- -

Logtalk Procedure Box model

- -

-Logtalk uses a Procedure Box model similar to those found on most Prolog compilers. The traditional Prolog procedure box model uses four ports (call, exit, redo, and fail) for describing control flow when a predicate clause is used during program execution: -

-
-
call
-
predicate call
-
exit
-
success of a predicate call
-
redo
-
backtracking into a predicate
-
fail
-
failure of a predicate call
-
-

-Logtalk, as found on some recent Prolog compilers, adds a port for dealing with exceptions thrown when calling a predicate: -

-
-
exception
-
predicate call throws an exception
-
-

-In addition to the ports described above, Logtalk adds two more ports, fact and rule, which show the result of the unification of a goal with, respectively, a fact and a rule head: -

-
-
fact
-
unification success between a goal and a fact
-
rule
-
unification success between a goal and a rule head
-
-

-The user may define for which ports the debugger should pause for user interaction by specifying a list of leashed ports. For example: -

-
| ?- debugger::leash([call, exit, fail]).
-

-Alternatively, the user may use an atom abbreviation for a pre-defined set of ports. For example: -

-
| ?- debugger::leash(loose).
-

-The abbreviations defined in Logtalk are similar to those defined on some Prolog compilers: -

-
-
none
-
[]
-
loose
-
[fact, rule, call]
-
half
-
[fact, rule, call, redo]
-
tight
-
[fact, rule, call, redo, fail, exception]
-
full
-
[fact, rule, call, exit, redo, fail, exception]
-
- -

Defining spy points

- -

-Logtalk spy points can be defined by simply stating which predicates should be spied, as in most Prolog debuggers, or by fully specifying the context for activating a spy point. -

- -

Defining predicate spy points

- -

-Predicate spy points are specified using the method spy/1. The argument can be either a predicate indicator (Functor/Arity) or a list of predicate indicators. For example: -

-
| ?- debugger::spy(foo/2).
-
-Spy points set.
-yes
-
-| ?- debugger::spy([foo/4, bar/1]).
-
-Spy points set.
-yes
-

-Predicate spy points can be removed by using the method nospy/1. The argument can be a predicate indicator, a list of predicate indicators, or a non-instantiated variable in which case all predicate spy points will be removed. For example: -

-
| ?- debugger::nospy(_).
-
-All matching predicate spy points removed.
-yes
- -

Defining context spy points

- -

-A context spy point is a term describing a message execution context and a goal: -

-
(Sender, This, Self, Goal)
-

-The debugger is evoked whenever the execution context is true and when the spy point goal unifies with the goal currently being executed. Variable bindings resulting from the unification between the current goal and the goal argument are discarded. The user may establish any number of context spy points as necessary. For example, in order to call the debugger whenever a predicate defined on an object named foo is called we may define the following spy point: -

-
| ?- debugger::spy(_, foo, _, _).
-
-Spy point set.
-yes
-

-For example, we can spy all calls to a foo/2 predicate by setting the condition: -

-
| ?- debugger::spy(_, _, _, foo(_, _)).
-
-Spy point set.
-yes
-

-The method nospy/4 may be used to remove all matching spy points. For example, the call: -

-
| ?- debugger::nospy(_, _, foo, _).
-
-All matching context spy points removed.
-yes
-

-will remove all context spy points where the value of Self matches the name foo. -

- -

Removing all spy points

- -

-We may remove all predicate spy points and all context spy points by using the method nospyall/0: -

-
| ?- debugger::nospyall.
-
-All predicate spy points removed.
-All context spy points removed.
-yes
- -

Tracing program execution

- -

-Logtalk allows tracing of execution for all objects compiled in debug mode. To start the debugger in trace mode, write: -

-
| ?- debugger::trace.
-
-yes
-

-Note that, when tracing, spy points will be ignored. While tracing, the debugger will pause for user input at each leashed port. -

-

-To stop tracing and turning off the debugger, write: -

-
| ?- debugger::notrace.
-
-yes
- - -

Debugging using spy points

- -

-Tracing a program execution may generate large amounts of debugging data. Debugging using spy points allows the user to concentrate its attention in specific points of its code. To start a debugging session using spy points, write: -

-
| ?- debugger::debug.
-
-yes
-

-At the beginning of a port description, the debugger will print a + or a * before the current goal if there is, respectively, a predicate spy point or a context spy point defined. -

-

-To stop the debugger, write: -

-
| ?- debugger::nodebug.
-
-yes
-

-Note that stopping the debugger does not remove any defined spy points. -

- -

Debugging commands

- -

-The debugger pauses at leashed posts when tracing or when finding a spy point for user interaction. The commands available are as follows: -

-
-
c — creep
-
go on; you may use the spacebar in alternative (but not the return or enter keys)
-
l — leap
-
continues execution until the next spy point is found
-
s — skip
-
skips debugging for the current goal; only meaningful at call and redo ports
-
i — ignore
-
ignores goal, assumes that it succeeded
-
f — fail
-
forces backtracking
-
n — nodebug
-
turns off debugging
-
@ — command; ! can be used in alternative
-
reads and executes a query
-
b — break
-
suspends execution and starts new interpreter; type end_of_file to terminate
-
a — abort
-
returns to top level interpreter
-
q — quit
-
quits Logtalk
-
d — display
-
writes current goal without using operator notation
-
x — context
-
prints execution context
-
e — exception
-
prints exception term thrown by the current goal
-
= — debugging
-
prints debugging information
-
* — add
-
adds a context spy point for the current goal
-
+ — add
-
adds a predicate spy point for the current goal
-
- — remove
-
removes a predicate spy point for the current goal
-
h — help
-
prints list of command options; ? can be used in alternative
-
- -

Context-switching calls

- -

-Logtalk provides a control construct, <</2, which allows the execution of a query within the context of an object. Common debugging uses include checking an object local predicates (e.g. predicates representing internal dynamic state) and sending a message from within an object. -

-

-Consider the following toy example: -

-
:- object(broken).
-
-    :- public(a/1).
-    :- private([b/2, c/1]).
-    :- dynamic(c/1).
-
-    a(A) :- b(A, B), c(B).
-    b(1, 2). b(2, 4). b(3, 6).
-    c(3).    % in a real-life example, this would be a clause asserted at runtime
-
-:- end_object.
-
-

-Something is wrong when we try the object public predicate, a/1: -

-
| ?- broken::a(A).
-
-no
-

-For helping diagnosing the problem, instead of compiling the object in debug mode and doing a trace of the query to check the clauses for the non-public predicates, we can instead simply type: -

-
| ?- broken << c(C).
-
-C = 3
-yes
-
-

-The <</2 control construct works by switching the execution context to the object in the first argument and then compiling and executing the second argument within that context: -

-
| ?- broken << (self(Self), sender(Sender), this(This)).
-
-Self = broken
-Sender = broken
-This = broken
-
-yes
-

-As exemplified above, the <</2 control construct allows you to call an object local and private predicates. However, it is important to stress that we are not bypassing or defeating an object predicate scope directives. The calls take place within the context of the specified object, not within the context of the object making the <</2 call. Thus, the <</2 control construct implements a form of execution-context switching. -

- - - - - - diff --git a/Logtalk/manuals/userman/threads.html b/Logtalk/manuals/userman/threads.html deleted file mode 100644 index 4e67dfb7b..000000000 --- a/Logtalk/manuals/userman/threads.html +++ /dev/null @@ -1,260 +0,0 @@ - - - - - - - - Logtalk user manual: multi-threading programming - - - - - - -
Logtalk user manual
-
Multi-threading programming
-
-
- - -

Multi-threading programming

- -

-Logtalk provides experimental support for multi-threading programming on selected Prolog compilers. Logtalk makes use of the low-level Prolog built-in predicates that interface with POSIX threads (or a suitable emulation), providing a small set of high-level predicates and directives that allows programmers to easily take advantage of modern multi-processor and multi-core computers without worrying about the details of creating, synchronizing, or communicating with threads. Logtalk multi-threading programming integrates with object-oriented programming by enabling objects and categories to prove goals concurrently and to send both synchronous and asynchronous messages. -

- -

Enabling multi-threading support

- -

-Multi-threading support may be disabled by default. It can be enabled on the Prolog configuration files of supported compilers by setting the read-only compiler flag threads to on. -

- -

Enabling objects to make multi-threading calls

- -

-The threaded/0 object directive is used to enable an object to make multi-threading calls: -

-
:- threaded.
-

-This directive results in the automatic creation and set up an object message queue when the object is loaded or created at runtime. Object message queues are used for exchanging thread notifications and for storing concurrent goal solutions and replies to the multi-threading calls made within the object. The message queue for the pseudo-object user is automatically created when Logtalk is loaded (provided that multi-threading programming is supported and enabled for the chosen Prolog compiler). -

- -

Multi-threading built-in predicates

- -

-Logtalk provides a small set of built-in predicates for multi-threading programming. For simple tasks where you simply want to prove a set of goals, each one in its own thread, Logtalk provides a threaded/1 built-in predicate. The remaining predicates allow for fine-grained control, including postponing retrieving of thread goal results at a later time, supporting non-deterministic thread goals, and making one-way asynchronous calls. Together, these predicates provide high-level support for multi-threading programming, covering most common use cases. -

- -

Proving goals concurrently using threads

- -

-A set of goals may be proved concurrently by calling the Logtalk built-in predicate threaded/1. Each goal in the set runs in its own thread. -

-

-When the threaded/1 predicate argument is a conjunction of goals, the predicate call is akin to and-parallelism. For example, assume that we want to find all the prime numbers in a given interval, [N, M]. We can split the interval in two parts and then span two threads to compute the primes numbers in each sub-interval: -

-
prime_numbers(N, M, Primes) :-
-    M > N,
-    N1 is N + (M - N) // 2,
-    N2 is N1 + 1,
-    threaded((
-        prime_numbers(N2, M, [], Acc),
-        prime_numbers(N, N1, Acc, Primes)
-    )).
-
-prime_numbers(N, M, Acc, Primes) :-
-    ...
-
-

-The threaded/1 call terminates when the two implicit threads terminate. In a computer with two or more processors (or with a processor with two or more cores) the code above can be expected to provide better computation times when compared with single-threaded code for sufficiently large intervals. -

-

-When the threaded/1 predicate argument is a disjunction of goals, the predicate call is akin to or-parallelism, here reinterpreted as a set of goal competing for providing a solution. For example, assume that we have several different methods to find the roots of real functions. Depending on the real function, some methods will faster than others. Some methods will converge into the solution while others may diverge and never find it. We can try all the methods at one by writing: -

-
find_root(Function, A, B, Error, Zero, Algorithm) :-
-    threaded((
-            (bisection::find_root(Function, A, B, Error, Zero), Algorithm = bisection)
-        ;   (newton::find_root(Function, A, B, Error, Zero), Algorithm = newton)
-        ;   (muller::find_root(Function, A, B, Error, Zero), Algorithm = muller)
-    )).
-
-

-The threaded/1 call succeeds when one of the implicit threads succeeds in finding the function root, leading to the termination of all the remaining competing threads. -

-

-The threaded/1 built-in predicate is most useful for lengthy, independent deterministic computations where the computational costs of each goal outweigh the overhead of the implicit thread creation and management. -

- -

Proving goals asynchronously using threads

- -

-A goal may be proved asynchronously using a new thread by calling the Logtalk built-in predicate threaded_call/1. Calls to this predicate are always true and return immediately (assuming a callable argument). The term representing the goal is copied, not shared with the thread. -

-

-The results of proving a goal asynchronously in a new thread may be later retrieved by calling the Logtalk built-in predicate threaded_exit/1 within the same object where the call to the threaded_call/1 predicate was made. The threaded_exit/1 calls block execution until the results of the threaded_call/1 calls are sent back to the object message queue. -

-

-The threaded_exit/1 predicate allow us to retrieve alternative solutions through backtracking (if you want to commit to the first solution, you may use the threaded_once/1 predicate instead of the threaded_call/1 predicate). For example, assuming a lists object implementing the usual member/2 predicate, we could write: -

-
| ?- threaded_call(lists::member(X, [1,2,3])).
-
-X = _G189 
-yes
-
-| ?- threaded_exit(lists::member(X, [1,2,3])).
-
-X = 1 ;
-X = 2 ;
-X = 3 ;
-no
-
-

-In this case, the threaded_call/1 and the threaded_exit/1 calls are made within the pseudo-object user. The implicit thread running the lists::member/2 goal suspends itself after providing a solution, waiting for a request to an alternative solution; the thread is automatically terminated when the runtime engine detects that backtracking to the threaded_exit/1 call is no longer possible. -

-

-Calls to the threaded_exit/1 predicate block the caller until the object message queue receives the reply to the asynchronous call. The predicate threaded_peek/1 may be used to check if a reply is already available without removing it from the thread queue. The threaded_peek/1 predicate call succeeds or fails immediately without blocking the caller. However, keep in mind that repeated use of this predicate is equivalent to polling a message queue, which may severely hurt performance. -

-

-Be careful when using the threaded_exit/1 predicate inside failure-driven loops. When all the solutions have been found (and the thread generating them is therefore terminated), re-calling the predicate will generate an exception. Note that failing instead of throwing an exception is not an acceptable solution as it could be misinterpreted as a failure of the threaded_exit/1 argument. -

-

-The example on the previous section with prime numbers could be rewritten using the threaded_call/1 and threaded_exit/1 predicates: -

-
prime_numbers(N, M, Primes) :-
-    M > N,
-    N1 is N + (M - N) // 2,
-    N2 is N1 + 1,
-    threaded_call(prime_numbers(N2, M, [], Acc)),
-    threaded_call(prime_numbers(N, N1, Acc, Primes)),
-    threaded_exit(prime_numbers(N2, M, [], Acc)),
-    threaded_exit(prime_numbers(N, N1, Acc, Primes)).
-
-prime_numbers(N, M, Acc, Primes) :-
-    ...
-
-

-When using asynchronous calls, the link between a threaded_exit/1 call and the corresponding threaded_call/1 call is made using unification. If there are several threaded_call/1 calls for a matching threaded_exit/1 call, the connection can potentially be established with any of them. Nevertheless, you can easily use a tag the calls by using the extended threaded_call/2 and threaded_exit/2 built-in predicates. For example: -

-
-?- threaded_call(member(X, [1,2,3]), Tag).
-
-Tag = 1
-yes
-
-?- threaded_call(member(X, [1,2,3]), Tag).
-
-Tag = 2
-yes
-
-?- threaded_exit(member(X, [1,2,3]), 2).
-
-X = 1 ;
-X = 2 ;
-X = 3
-yes
-
-

-When using these predicates, the tags shall be considered as an opaque term; users shall not rely on its type. -

- -

One-way asynchronous calls

- -

-Sometimes we want to prove a goal in a new thread without caring about the results. This may be accomplished by using the built-in predicate threaded_ignore/1. For example, assume that we are developing a multi-agent application where an agent may send an "happy birthday" message to another agent. We could write: -

-
threaded_ignore(agent::happy_birthday), ...
-
-

-The call succeeds with no reply of the goal success, failure, or even exception ever being sent back to the object making the call. Note that this predicate implicitly implies a deterministic call of its argument. -

- -

Asynchronous calls and synchronized predicates

- -

-Proving a goal asynchronously using a new thread may lead to problems when the goal implies side-effects such as input/output operations or modifications to an object database. For example, if a new thread is started with the same goal before the first one finished its job, we may end up with mixed output, a corrupted database, or unexpected goal failures. In order to solve this problem, predicates (and grammar rule non-terminals) with side-effects can be declared as synchronized by using the synchronized/1 predicate directive. Proving a query to a synchronized predicate (or synchronized non-terminal) is internally protected by a mutex, thus allowing for easy thread synchronization. For example: -

-
:- synchronized(db_update/1).   % ensure thread synchronization
-
-db_update(Update) :-            % predicate with side-effects
-    ...
-
-

-A second example: assume an object defining two predicates for writing, respectively, even and odd numbers in a given interval to the standard output. Given a large interval, a goal such as: -

-
| ?- threaded_call(obj::odd_numbers(1,1000)), threaded_call(obj::even_numbers(1,1000)).
-
-1 3 2 4 6 8 5 7 10 ...
-...
-
-

-will most likely result in a mixed up output. By declaring the odd_numbers/2 and even_numbers/2 predicates synchronized: -

-
:- synchronized([
-    odd_numbers/2,
-    even_numbers/2]).
-
-

-one goal will only start after the other one finished: -

-
| ?- threaded_ignore(obj::odd_numbers(1,1000)), threaded_ignore(obj::even_numbers(1,1000)).
-
-1 3 5 7 9 11 ...
-...
-2 4 6 8 10 12 ...
-...
-
-

-Note that, in a more realistic scenario, the two threaded_ignore/1 calls would be made concurrently from different objects. Using the same synchronized directive for a set of predicates imply that they all use the same mutex, as required for this example. -

- -

-The synchronized/1 directive must precede any local calls to the synchronized predicate (or synchronized non-terminal) in order to ensure proper compilation. In addition, as each Logtalk entity is independently compiled, this directive must be included in every object or category that contains a definition for the described predicate, even if the predicate declaration is inherited from another entity, in order to ensure proper compilation. -

-

-Logtalk supports both deterministic and non-deterministic synchronized predicates (and synchronized non-terminals). However, whenever possible, synchronized predicates should be coded as deterministic predicates in order to avoid deadlocks. In those cases where the predicate (or grammar rule) is defined in the same object (or category) where the predicate is declared synchronized, Logtalk takes advantage of any existing mode/2 directives in order to generate the most appropriated mutex handling code. When no mode/2 predicate directives are presented, Logtalk assumes a deterministic predicate when generating the mutex handling code. -

-

-We may declare all predicates of an object (or a category) as synchronized by using the entity directive synchronized/0. In this case, the synchronized/1 predicate directive is not necessary and should not be used. -

-

-Synchronized predicates may be used as wrappers to messages sent to objects that are not multi-threading aware. For example, assume a random object defining a random/1 predicate that generates random numbers, using side-effects on its implementation (e.g. for storing the generator seed). We can specify and define e.g. a sync_random/1 predicate as follows: -

-
-:- synchronized(sync_random/1).
-
-sync_random(Random) :-
-    random::random(Random).
-
-

-and then always use the sync_random/1 predicate instead of the predicate random/1 from multi-threaded code. -

-

-The synchronization entity and predicate directives may be used when defining objects that may be reused in both single-threaded and multi-threaded Logtalk applications. The directives are simply ignored (i.e. the synchronized predicates are interpreted as normal predicates) when the objects are used in a single-threaded application. -

- -

Synchronizing threads through notifications

- -

-Declaring a set of predicates as synchronized can only ensure that they are not executed at the same time by different threads. Sometimes we need to suspend a thread not on a synchronization lock but on some condition that must hold true for a thread goal to proceed. I.e. we want a thread goal to be suspended until a condition becomes true instead of simply failing. The built-in predicate threaded_wait/1 allows us to suspend a predicate execution (running in its own thread) until a notification is received. Notifications are posted using the built-in predicate - threaded_notify/1. A notification is a Prolog term that a programmer chooses to represent some condition becoming true. Any Prolog term can be used as a notification argument for these predicates. Related calls to the threaded_wait/1 and threaded_notify/1 must be made within the same object, this, as the object message queue is used internally for posting and retrieving notifications. -

-

-Each notification posted by a call to the threaded_notify/1 predicate is consumed by a single threaded_wait/1 predicate call (i.e. these predicates implement a peer-to-peer mechanism). Care should be taken to avoid deadlocks when two (or more) threads both wait and post notifications to each other. -

- - - - - - diff --git a/Logtalk/manuals/userman/userman.body b/Logtalk/manuals/userman/userman.body deleted file mode 100644 index 643604c3f..000000000 --- a/Logtalk/manuals/userman/userman.body +++ /dev/null @@ -1,4 +0,0 @@ - -
- -
diff --git a/Logtalk/manuals/userman/userman.footer b/Logtalk/manuals/userman/userman.footer deleted file mode 100644 index 087168854..000000000 --- a/Logtalk/manuals/userman/userman.footer +++ /dev/null @@ -1,6 +0,0 @@ - -
- - - - diff --git a/Logtalk/manuals/userman/userman.header b/Logtalk/manuals/userman/userman.header deleted file mode 100644 index c81089a13..000000000 --- a/Logtalk/manuals/userman/userman.header +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - Logtalk: User Manual - - - - - - -
-
- -
Logtalk user manual
-
Contents
-
-
- -
Logtalk user manual
-
-
-
- -
-

Logtalk 2.30.7

-

User Manual

-

Copyright © Paulo Moura

-

- pmoura@logtalk.org -
- http://logtalk.org/ -

-

Last updated on October 24, 2007

-
- -
diff --git a/Logtalk/manuals/userman/userman.sh b/Logtalk/manuals/userman/userman.sh deleted file mode 100755 index 5f92b757f..000000000 --- a/Logtalk/manuals/userman/userman.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -css2xslfo=/Applications/XML/CSSToXSLFO/css2xslfo1_5_1.jar - -xslt_proc=xsltproc -# xslt_proc=xalan -# xslt_proc=sabcmd - -#fo_proc=fop -fo_proc=xep -# fo_proc=xinc - -rm -f userman.fo userman.html -rm -fr *.section -eval $xslt_proc -o index.section userman.xsl index.html -eval $xslt_proc -o features.section userman.xsl features.html -eval $xslt_proc -o nomenclature.section userman.xsl nomenclature.html -eval $xslt_proc -o messages.section userman.xsl messages.html -eval $xslt_proc -o objects.section userman.xsl objects.html -eval $xslt_proc -o protocols.section userman.xsl protocols.html -eval $xslt_proc -o categories.section userman.xsl categories.html -eval $xslt_proc -o predicates.section userman.xsl predicates.html -eval $xslt_proc -o inheritance.section userman.xsl inheritance.html -eval $xslt_proc -o events.section userman.xsl events.html -eval $xslt_proc -o threads.section userman.xsl threads.html -eval $xslt_proc -o errors.section userman.xsl errors.html -eval $xslt_proc -o documenting.section userman.xsl documenting.html -eval $xslt_proc -o installing.section userman.xsl installing.html -eval $xslt_proc -o running.section userman.xsl running.html -eval $xslt_proc -o programming.section userman.xsl programming.html - -cat -s \ - userman.header \ - index.section \ - userman.body \ - features.section nomenclature.section messages.section \ - objects.section protocols.section categories.section predicates.section \ - inheritance.section events.section threads.section errors.section \ - documenting.section installing.section running.section programming.section \ - userman.footer \ - > userman.html - -java -jar $css2xslfo userman.html -fo userman.fo -eval $fo_proc -fo userman.fo -pdf userman.pdf -rm userman.fo userman.html -rm -fr *.section diff --git a/Logtalk/manuals/userman/userman.xsl b/Logtalk/manuals/userman/userman.xsl deleted file mode 100644 index 73e84702a..000000000 --- a/Logtalk/manuals/userman/userman.xsl +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/Logtalk/scripts/NOTES.txt b/Logtalk/scripts/NOTES.txt deleted file mode 100644 index 7a57c1fe1..000000000 --- a/Logtalk/scripts/NOTES.txt +++ /dev/null @@ -1,62 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This directory contains some shell scripts used for Logtalk packaging, -installation, and integration with Prolog compilers. Those with extension -".sh" are Bourne-compatible shells scripts for MacOS X, Linux, and similar -systems. Those with extension ".js" are JScript command-line scripts for -Windows; they require WSH 5.6 or later version to be installed and should -be run using cscript.exe from a DOS command line shell (you may download -WSH 5.6 from http://msdn.microsoft.com/downloads/list/webdev.asp). - -build_release.sh - helper script for building most of the distribution files of a new - Logtalk release - -cleandist.sh - script for cleaning a Logtalk distribution in preparation for packaging - -install.sh - shell script for installing Logtalk in a system-wide location for Unix - and Unix-like operating systems (must be run from this directory by a - user with administration privileges; accepts as an optional argument - a prefix for the installation directory: default is "/opt/local" on - Darwin, "/usr" on Debian systems, and "/usr/local" on other POSIX - systems, resulting in Logtalk being installed in "$prefix/share" with - useful scripts written to "$prefix/bin", which should be your path) - -uninstall.sh - shell script for de-installing Logtalk in Unix and Unix-like operating - systems (must be run from this directory by a user with administration - privileges) - -debian - directory containing support files for building a Debian package - (work in progress; experimental) - -linux - directory containing files used when building - -macosx - directory containing files used when building MacOS X installer - packages - -windows - directory containing files used when building Windows 2000/XP GUI - installers - -cplgtdirs.sh -cplgtdirs.js - end-user scripts for copying the Logtalk user-modifiable files and - directories to the location pointed by the environment variable - LOGTALKUSER (defaults to "~/logtalk" on POSIX operating-systems - and to "My Documents\Logtalk" on Windows when the variable is not - defined); must be run by the end-user in order to ensure proper - permissions for the copied files; the LOGTALKHOME environment - variable must be defined (pointing to the Logtalk installation - directory) diff --git a/Logtalk/scripts/build_release.sh b/Logtalk/scripts/build_release.sh deleted file mode 100644 index e2dcd02e0..000000000 --- a/Logtalk/scripts/build_release.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -dir=`PWD` - -svn export http://svn.logtalk.org/logtalk/trunk logtalk - -cd logtalk -chmod a+x scripts/cleandist.sh -scripts/cleandist.sh - -cd .. -cp -R logtalk/manuals man2307 -tar -czf man2307.tgz man2307 -mv logtalk lgt2307 -tar -cjf lgt2307.tar.bz2 lgt2307 - -mkdir -p debian/usr/bin -mkdir -p debian/usr/share/doc/logtalk -mkdir -p debian/usr/share/doc-base -mkdir -p debian/usr/share/menu -mkdir -p debian/DEBIAN -cd lgt2307/scripts -./install.sh $dir/debian/usr -cp debian/logtalk.doc-base $dir/debian/usr/share/doc-base/logtalk-docs -cp debian/menu $dir/debian/usr/share/menu/logtalk -cp ../*.bib $dir/debian/usr/share/doc/logtalk -cp ../*.txt $dir/debian/usr/share/doc/logtalk -cp debian/copyright $dir/debian/usr/share/doc/logtalk -cp debian/changelog $dir/debian/usr/share/doc/logtalk -cp debian/changelog.Debian $dir/debian/usr/share/doc/logtalk -gzip --best $dir/debian/usr/share/doc/logtalk/*.bib -gzip --best $dir/debian/usr/share/doc/logtalk/*.txt -gzip --best $dir/debian/usr/share/doc/logtalk/changelog -gzip --best $dir/debian/usr/share/doc/logtalk/changelog.Debian -cp debian/control $dir/debian/DEBIAN -cp debian/postinst $dir/debian/DEBIAN -cp debian/prerm $dir/debian/DEBIAN -cp debian/postrm $dir/debian/DEBIAN -cd $dir -dpkg-deb --build debian logtalk_2.30.7-1_all.deb - -md5="`md5 -q lgt2307.tar.bz2`" -sudo mkdir -p /opt/local/var/macports/distfiles/logtalk -sudo cp -f lgt2307.tar.bz2 /opt/local/var/macports/distfiles/logtalk/lgt2307.tar.bz2 -cd /opt/local/var/macports/sources/rsync.macports.org/release/ports/lang/logtalk/ -sudo cp -f Portfile Portfile.old -sudo sed -e 's/^version.*/version 2.30.7/' -i '' Portfile -sudo sed -e "s/^checksums.*/checksums md5 $md5/" -i '' Portfile -sudo sed -e 's/^distname.*/distname lgt2307/' -i '' Portfile -sudo sed -e 's/^extract\.suffix.*/extract.suffix .tar.bz2/' -i '' Portfile -sudo port clean --archive logtalk -sudo port destroot logtalk -sudo port pkg logtalk -cp -R work/logtalk-2.30.7.pkg $dir -sudo port clean logtalk - -cd $dir -mkdir manpdf2307 -cd man2307/userman -./userman.sh -mv userman.pdf ../../manpdf2307 -cd ../refman -./refman.sh -mv refman.pdf ../../manpdf2307 -cd ../.. -tar -czf manpdf2307.tgz manpdf2307 diff --git a/Logtalk/scripts/cleandist.sh b/Logtalk/scripts/cleandist.sh deleted file mode 100755 index 6f4fdcf94..000000000 --- a/Logtalk/scripts/cleandist.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -find . -name .svn -print0 | xargs -0 rm -rf -find . -name CVS -print0 | xargs -0 rm -rf -find . -name .cvsignore -print0 | xargs -0 rm -f -find . -name '.#*' -print0 | xargs -0 rm -f -find . -name .DS_Store -print0 | xargs -0 rm -f -find . -name '.gdb*' -print0 | xargs -0 rm -f - -find . -type f -print0 | xargs -0 chmod 644 -find . -type d -print0 | xargs -0 chmod 755 - -chmod a+x integration/*.sh -chmod a+x manuals/userman/*.sh -chmod a+x manuals/refman/*.sh -chmod a+x scripts/*.sh -chmod a-x scripts/*.js -chmod a+x scripts/debian/postinst -chmod a+x scripts/debian/prerm -chmod a+x scripts/debian/postrm -chmod a+x scripts/linux/*.sh -chmod a+x scripts/macosx/postflight -chmod a+x xml/*.sh -chmod a-x xml/*.js diff --git a/Logtalk/scripts/cplgtdirs.bat b/Logtalk/scripts/cplgtdirs.bat deleted file mode 100644 index 189c352ce..000000000 --- a/Logtalk/scripts/cplgtdirs.bat +++ /dev/null @@ -1,3 +0,0 @@ -@ECHO off -cscript "%LOGTALKHOME%\scripts\cplgtdirs.js" -@ECHO on diff --git a/Logtalk/scripts/cplgtdirs.js b/Logtalk/scripts/cplgtdirs.js deleted file mode 100644 index 6df4848c3..000000000 --- a/Logtalk/scripts/cplgtdirs.js +++ /dev/null @@ -1,164 +0,0 @@ -// ================================================================ -// Logtalk - Open source object-oriented logic programming language -// Release 2.30.7 -// -// Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -// ================================================================ - -if (ScriptEngineMajorVersion() < 5 || ScriptEngineMajorVersion() == 5 && ScriptEngineMinorVersion() < 6) { - WScript.Echo('Error! WSH 5.6 or later version needed for running this script.'); - WScript.Quit(1); -} - -var WshShell = new ActiveXObject("WScript.Shell"); - -var WshSystemEnv = WshShell.Environment("SYSTEM"); -var WshUserEnv = WshShell.Environment("USER"); -var logtalk_home; -var logtalk_user; - -if (WshSystemEnv.Item("LOGTALKHOME")) - logtalk_home = WshSystemEnv.Item("LOGTALKHOME"); -else if (WshUserEnv.Item("LOGTALKHOME")) - logtalk_home = WshUserEnv.Item("LOGTALKHOME") -else { - WScript.Echo("The environment variable LOGTALKHOME must be defined first!"); - usage_help(); - WScript.Quit(1); -} - -var FSObject = new ActiveXObject("Scripting.FileSystemObject"); - -if (!FSObject.FolderExists(logtalk_home)) { - WScript.Echo("The environment variable LOGTALKHOME points to a non-existing directory!"); - WScript.Echo("Its current value is: %LOGTALKHOME%"); - WScript.Echo("The variable must be set to your Logtalk installation directory!"); - WScript.Echo(""); - usage_help(); - WScript.Quit(1); -} - -if (WScript.Arguments.Unnamed.Length > 0) - usage_help(); - -if (WshUserEnv.Item("LOGTALKUSER")) - logtalk_user = WshUserEnv.Item("LOGTALKUSER"); -else { - logtalk_user = WshShell.SpecialFolders("MyDocuments") + "\\logtalk"; - WshUserEnv.Item("LOGTALKUSER") = WshShell.SpecialFolders("MyDocuments") + "\\logtalk"; - WScript.Echo("Defined user environment variable LOGTALKUSER."); - WScript.Echo(""); -} - -if (FSObject.FolderExists(logtalk_user)) { - var today = new Date(); - var year = today.getFullYear(); - var month = today.getMonth() + 1; - var day = today.getDate(); - if (day < 10) - day = "0" + day; - var hours = today.getHours(); - if (hours < 10) - hours = "0" + hours; - var mins = today.getMinutes(); - if (mins < 10) - mins = "0" + mins; - var secs = today.getSeconds(); - date = year + "-" + month + "-" + day + "-" + hours + mins + secs; - FSObject.MoveFolder(logtalk_user, logtalk_user + " backup " + date); - WScript.Echo("Created a backup of the existing " + logtalk_user + " directory."); - WScript.Echo(""); -} - -WScript.Echo("Creating LOGTALKUSER directory:"); -WScript.Echo(""); -WScript.Echo(" " + logtalk_user); -WScript.Echo(""); - -FSObject.CreateFolder(logtalk_user); - -WScript.Echo("Copying Logtalk files and directories..."); -FSObject.CopyFolder(logtalk_home + "\\configs", logtalk_user + "\\configs"); -FSObject.CopyFolder(logtalk_home + "\\contributions", logtalk_user + "\\contributions"); -FSObject.CopyFolder(logtalk_home + "\\examples", logtalk_user + "\\examples"); -FSObject.CopyFolder(logtalk_home + "\\libpaths", logtalk_user + "\\libpaths"); -FSObject.CopyFile(logtalk_user + "\\libpaths\\libpaths.pl", logtalk_user + "\\libpaths\\libpaths_no_env_var.pl"); -FSObject.CopyFolder(logtalk_home + "\\library", logtalk_user + "\\library"); -FSObject.CopyFolder(logtalk_home + "\\xml", logtalk_user + "\\xml"); - -FSObject.DeleteFile(logtalk_user + "\\xml\\lgt2*.*"); -FSObject.DeleteFile(logtalk_user + "\\xml\\logtalk.dtd"); -FSObject.DeleteFile(logtalk_user + "\\xml\\logtalk.xsd"); - -var link = WshShell.CreateShortcut(logtalk_user + "\\manuals.lnk"); -link.Description = "Shortcut to Logtalk documentation"; -link.TargetPath = logtalk_home + "\\manuals"; -link.Save(); - -link = WshShell.CreateShortcut(logtalk_user + "\\wenv.lnk"); -link.Description = "Shortcut to Logtalk text editing support"; -link.TargetPath = logtalk_home + "\\wenv"; -link.Save(); - -link = WshShell.CreateShortcut(logtalk_user + "\\xml\\lgt2html.js.lnk"); -link.Description = "Shortcut to lgt2html script"; -link.TargetPath = logtalk_home + "\\xml\\lgt2html.js"; -link.Save(); - -link = WshShell.CreateShortcut(logtalk_user + "\\xml\\lgt2pdf.js.lnk"); -link.Description = "Shortcut to lgt2pdf script"; -link.TargetPath = logtalk_home + "\\xml\\lgt2pdf.js"; -link.Save(); - -link = WshShell.CreateShortcut(logtalk_user + "\\xml\\lgt2xml.js.lnk"); -link.Description = "Shortcut to lgt2xml script"; -link.TargetPath = logtalk_home + "\\xml\\lgt2xml.js"; -link.Save(); - -link = WshShell.CreateShortcut(logtalk_user + "\\xml\\logtalk.dtd.lnk"); -link.Description = "Shortcut to Logtalk DTD"; -link.TargetPath = logtalk_home + "\\xml\\logtalk.dtd"; -link.Save(); - -link = WshShell.CreateShortcut(logtalk_user + "\\xml\\logtalk.rng.lnk"); -link.Description = "Shortcut to Logtalk RELAX NG Schema"; -link.TargetPath = logtalk_home + "\\xml\\logtalk.rng"; -link.Save(); - -link = WshShell.CreateShortcut(logtalk_user + "\\xml\\logtalk.xsd.lnk"); -link.Description = "Shortcut to Logtalk XML Schema"; -link.TargetPath = logtalk_home + "\\xml\\logtalk.xsd"; -link.Save(); - -WScript.Echo("Finished copying Logtalk files and directories."); -WScript.Echo(""); -WScript.Echo("You may need to edit the contents of the file:"); -WScript.Echo(""); -WScript.Echo(" " + logtalk_user + "\\libpaths\\libpaths.pl"); -WScript.Echo(""); -WScript.Echo("to match your Prolog compiler and operating-system requirements or to"); -WScript.Echo("add your own library paths."); -WScript.Echo(""); -WScript.Echo("You may want to customize the default Logtalk compiler flags by editing"); -WScript.Echo("the configuration file for your Prolog compiler found in the directory:"); -WScript.Echo(""); -WScript.Echo(" " + logtalk_user + "\\configs"); -WScript.Echo(""); -WScript.Echo("See the \%LOGTALKUSER\%\\CUSTOMIZE.txt file for details."); -WScript.Echo(""); - -WScript.Quit(0); - -function usage_help() { - WScript.Echo(""); - WScript.Echo("This script copies the Logtalk user-modifiable files and directories"); - WScript.Echo("to the user home directory. The location can be set by the environment"); - WScript.Echo("variable \%LOGTALKUSER\% (defaults to MyDocuments\\logtalk when the"); - WScript.Echo("variable is not defined)"); - WScript.Echo(""); - WScript.Echo("Usage:"); - WScript.Echo(" " + WScript.ScriptName + " help"); - WScript.Echo(" " + WScript.ScriptName); - WScript.Echo(""); - WScript.Quit(1); -} diff --git a/Logtalk/scripts/cplgtdirs.sh b/Logtalk/scripts/cplgtdirs.sh deleted file mode 100755 index 7d42827f3..000000000 --- a/Logtalk/scripts/cplgtdirs.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -echo -echo "This script copies the Logtalk user-modifiable files and directories" -echo "to the user home directory. The location can be set by the environment" -echo "variable \$LOGTALKUSER (defaults to \"~/logtalk\" when the variable is not" -echo "defined)" -echo - -if ! [ "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME should be defined first!" - echo "Trying default Logtalk installation directories..." - if [ -d "/usr/local/share/logtalk" ]; then - LOGTALKHOME=/usr/local/share/logtalk - echo "Using Logtalk installation at \"/usr/local/share/logtalk\"" - elif [ -d "/usr/share/logtalk" ]; then - LOGTALKHOME=/usr/share/logtalk - echo "Using Logtalk installation at \"/usr/share/logtalk\"" - elif [ -d "/opt/local/share/logtalk" ]; then - LOGTALKHOME=/opt/local/share/logtalk - echo "Using Logtalk installation at \"/opt/local/share/logtalk\"" - elif [ -d "/opt/share/logtalk" ]; then - LOGTALKHOME=/opt/share/logtalk - echo "Using Logtalk installation at \"/opt/share/logtalk\"" - else - echo "Unable to locate Logtalk installation directory!" - echo - exit 1 - fi - echo "After the script completion, you must set the environment variable" - echo "LOGTALKHOME pointing to \"$LOGTALKHOME\"." - echo -elif ! [ -d "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME points to a non-existing directory!" - echo "Its current value is: $LOGTALKHOME" - echo "The variable must be set to your Logtalk installation directory!" - echo - exit 1 -fi - -if ! [ "$LOGTALKUSER" ] -then - LOGTALKUSER=$HOME/logtalk - echo "After the script completion, you must set the environment variable" - echo "LOGTALKUSER pointing to \"$LOGTALKUSER\"." - echo -fi - -if [ -d "$LOGTALKUSER" ] -then - date=`eval date \"+%Y-%m-%d-%H%M%S\"` - mv $LOGTALKUSER "$LOGTALKUSER backup $date" - echo "Created a backup of the existing \"$LOGTALKUSER\" directory." - echo -fi - -echo "Copying Logtalk files and directories..." -mkdir -p "$LOGTALKUSER"/configs -mkdir -p "$LOGTALKUSER"/contributions -mkdir -p "$LOGTALKUSER"/examples -mkdir -p "$LOGTALKUSER"/libpaths -mkdir -p "$LOGTALKUSER"/library -mkdir -p "$LOGTALKUSER"/xml -cp -RL "$LOGTALKHOME"/configs "$LOGTALKUSER"/ -cp -RL "$LOGTALKHOME"/contributions "$LOGTALKUSER"/ -cp -RL "$LOGTALKHOME"/examples "$LOGTALKUSER"/ -cp -RL "$LOGTALKHOME"/libpaths "$LOGTALKUSER"/ -sed 's_\$LOGTALKUSER_'$LOGTALKUSER'_' "$LOGTALKUSER"/libpaths/libpaths.pl > "$LOGTALKUSER"/libpaths/libpaths_no_env_var.pl -cp -RL "$LOGTALKHOME"/library "$LOGTALKUSER"/ -cp -RL "$LOGTALKHOME"/xml "$LOGTALKUSER"/ -chmod -R u+w "$LOGTALKUSER" -rm -f "$LOGTALKUSER"/xml/lgt2* -rm -f "$LOGTALKUSER"/xml/logtalk.dtd -rm -f "$LOGTALKUSER"/xml/logtalk.xsd -ln -sf "$LOGTALKHOME"/BIBLIOGRAPHY.bib "$LOGTALKUSER"/BIBLIOGRAPHY.bib -ln -sf "$LOGTALKHOME"/CUSTOMIZE.txt "$LOGTALKUSER"/CUSTOMIZE.txt -ln -sf "$LOGTALKHOME"/INSTALL.txt "$LOGTALKUSER"/INSTALL.txt -ln -sf "$LOGTALKHOME"/LICENSE.txt "$LOGTALKUSER"/LICENSE.txt -ln -sf "$LOGTALKHOME"/QUICK_START.txt "$LOGTALKUSER"/QUICK_START.txt -ln -sf "$LOGTALKHOME"/README.txt "$LOGTALKUSER"/README.txt -ln -sf "$LOGTALKHOME"/RELEASE_NOTES.txt "$LOGTALKUSER"/RELEASE_NOTES.txt -ln -sf "$LOGTALKHOME"/UPGRADING.txt "$LOGTALKUSER"/UPGRADING.txt -ln -sf "$LOGTALKHOME"/manuals "$LOGTALKUSER"/manuals -ln -sf "$LOGTALKHOME"/wenv "$LOGTALKUSER"/wenv -ln -sf "$LOGTALKHOME"/xml/lgt2html.sh "$LOGTALKUSER"/xml/lgt2html -ln -sf "$LOGTALKHOME"/xml/lgt2pdf.sh "$LOGTALKUSER"/xml/lgt2pdf -ln -sf "$LOGTALKHOME"/xml/lgt2xml.sh "$LOGTALKUSER"/xml/lgt2xml -ln -sf "$LOGTALKHOME"/xml/logtalk.dtd "$LOGTALKUSER"/xml/logtalk.dtd -ln -sf "$LOGTALKHOME"/xml/logtalk.rng "$LOGTALKUSER"/xml/logtalk.rng -ln -sf "$LOGTALKHOME"/xml/logtalk.xsd "$LOGTALKUSER"/xml/logtalk.xsd -echo "Finished copying Logtalk files and directories." -echo -echo "You may need to edit the \"$LOGTALKUSER/libpaths/libpaths.pl\"" -echo "file to match your Prolog compiler and operating-system requirements or" -echo "to add your own library paths." -echo -echo "You may want to customize the default Logtalk compiler flags by editing" -echo "the configuration file for your Prolog compiler found in the directory" -echo "\"$LOGTALKUSER/configs\"." -echo "For more information on customizing Logtalk and your working environment," -echo "consult the \"$LOGTALKUSER/CUSTOMIZE.txt\" file." -echo diff --git a/Logtalk/scripts/debian/changelog b/Logtalk/scripts/debian/changelog deleted file mode 100644 index 630c2ec0d..000000000 --- a/Logtalk/scripts/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -logtalk (2.30.7-1) unstable; urgency=low - - * Initial Release. - - -- Paulo Moura Sat November 5 10:52:34 WEST 2007 diff --git a/Logtalk/scripts/debian/changelog.Debian b/Logtalk/scripts/debian/changelog.Debian deleted file mode 100644 index 1a9fda3ca..000000000 --- a/Logtalk/scripts/debian/changelog.Debian +++ /dev/null @@ -1,3 +0,0 @@ -Logtalk Debian maintainer and upstream author are the same. -Consult the normal changelog file for any Debian changes. -Consult the RELEASE_NOTES.txt file for Logtalk changes. \ No newline at end of file diff --git a/Logtalk/scripts/debian/control b/Logtalk/scripts/debian/control deleted file mode 100644 index 54a242dc0..000000000 --- a/Logtalk/scripts/debian/control +++ /dev/null @@ -1,14 +0,0 @@ -Package: logtalk -Version: 2.30.7 -Maintainer: Paulo Moura -Section: devel -Priority: optional -Architecture: all -Essential: no -Description: Open source object-oriented logic programming language. - Logtalk is an open source object-oriented logic programming language - that can use most Prolog implementations as a back-end compiler. - As a multi-paradigm language, Logtalk includes support for both - prototypes and classes, protocols, component-based programming - through category-based composition, event-driven programming, and - multi-threading programming. diff --git a/Logtalk/scripts/debian/copyright b/Logtalk/scripts/debian/copyright deleted file mode 100644 index 2b396f8c1..000000000 --- a/Logtalk/scripts/debian/copyright +++ /dev/null @@ -1,210 +0,0 @@ -This package was debianized by Paulo Moura . - -It was downloaded from: http://logtalk.org/files/ - -This software is copyright (c) 1998-2007 by Paulo Moura, Logtalk.org - -You are free to distribute this software under the terms of -the The Artistic License 2.0: - - The Artistic License 2.0 - - Copyright (c) 2000-2006, The Perl Foundation. - - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -Preamble - -This license establishes the terms under which a given free software -Package may be copied, modified, distributed, and/or redistributed. -The intent is that the Copyright Holder maintains some artistic -control over the development of that Package while still keeping the -Package available as open source and free software. - -You are always permitted to make arrangements wholly outside of this -license directly with the Copyright Holder of a given Package. If the -terms of this license do not permit the full use that you propose to -make of the Package, you should contact the Copyright Holder and seek -a different licensing arrangement. - -Definitions - - "Copyright Holder" means the individual(s) or organization(s) - named in the copyright notice for the entire Package. - - "Contributor" means any party that has contributed code or other - material to the Package, in accordance with the Copyright Holder's - procedures. - - "You" and "your" means any person who would like to copy, - distribute, or modify the Package. - - "Package" means the collection of files distributed by the - Copyright Holder, and derivatives of that collection and/or of - those files. A given Package may consist of either the Standard - Version, or a Modified Version. - - "Distribute" means providing a copy of the Package or making it - accessible to anyone else, or in the case of a company or - organization, to others outside of your company or organization. - - "Distributor Fee" means any fee that you charge for Distributing - this Package or providing support for this Package to another - party. It does not mean licensing fees. - - "Standard Version" refers to the Package if it has not been - modified, or has been modified only in ways explicitly requested - by the Copyright Holder. - - "Modified Version" means the Package, if it has been changed, and - such changes were not explicitly requested by the Copyright - Holder. - - "Original License" means this Artistic License as Distributed with - the Standard Version of the Package, in its current version or as - it may be modified by The Perl Foundation in the future. - - "Source" form means the source code, documentation source, and - configuration files for the Package. - - "Compiled" form means the compiled bytecode, object code, binary, - or any other form resulting from mechanical transformation or - translation of the Source form. - - -Permission for Use and Modification Without Distribution - -(1) You are permitted to use the Standard Version and create and use -Modified Versions for any purpose without restriction, provided that -you do not Distribute the Modified Version. - - -Permissions for Redistribution of the Standard Version - -(2) You may Distribute verbatim copies of the Source form of the -Standard Version of this Package in any medium without restriction, -either gratis or for a Distributor Fee, provided that you duplicate -all of the original copyright notices and associated disclaimers. At -your discretion, such verbatim copies may or may not include a -Compiled form of the Package. - -(3) You may apply any bug fixes, portability changes, and other -modifications made available from the Copyright Holder. The resulting -Package will still be considered the Standard Version, and as such -will be subject to the Original License. - - -Distribution of Modified Versions of the Package as Source - -(4) You may Distribute your Modified Version as Source (either gratis -or for a Distributor Fee, and with or without a Compiled form of the -Modified Version) provided that you clearly document how it differs -from the Standard Version, including, but not limited to, documenting -any non-standard features, executables, or modules, and provided that -you do at least ONE of the following: - - (a) make the Modified Version available to the Copyright Holder - of the Standard Version, under the Original License, so that the - Copyright Holder may include your modifications in the Standard - Version. - - (b) ensure that installation of your Modified Version does not - prevent the user installing or running the Standard Version. In - addition, the Modified Version must bear a name that is different - from the name of the Standard Version. - - (c) allow anyone who receives a copy of the Modified Version to - make the Source form of the Modified Version available to others - under - - (i) the Original License or - - (ii) a license that permits the licensee to freely copy, - modify and redistribute the Modified Version using the same - licensing terms that apply to the copy that the licensee - received, and requires that the Source form of the Modified - Version, and of any works derived from it, be made freely - available in that license fees are prohibited but Distributor - Fees are allowed. - - -Distribution of Compiled Forms of the Standard Version -or Modified Versions without the Source - -(5) You may Distribute Compiled forms of the Standard Version without -the Source, provided that you include complete instructions on how to -get the Source of the Standard Version. Such instructions must be -valid at the time of your distribution. If these instructions, at any -time while you are carrying out such distribution, become invalid, you -must provide new instructions on demand or cease further distribution. -If you provide valid instructions or cease distribution within thirty -days after you become aware that the instructions are invalid, then -you do not forfeit any of your rights under this license. - -(6) You may Distribute a Modified Version in Compiled form without -the Source, provided that you comply with Section 4 with respect to -the Source of the Modified Version. - - -Aggregating or Linking the Package - -(7) You may aggregate the Package (either the Standard Version or -Modified Version) with other packages and Distribute the resulting -aggregation provided that you do not charge a licensing fee for the -Package. Distributor Fees are permitted, and licensing fees for other -components in the aggregation are permitted. The terms of this license -apply to the use and Distribution of the Standard or Modified Versions -as included in the aggregation. - -(8) You are permitted to link Modified and Standard Versions with -other works, to embed the Package in a larger work of your own, or to -build stand-alone binary or bytecode versions of applications that -include the Package, and Distribute the result without restriction, -provided the result does not expose a direct interface to the Package. - - -Items That are Not Considered Part of a Modified Version - -(9) Works (including, but not limited to, modules and scripts) that -merely extend or make use of the Package, do not, by themselves, cause -the Package to be a Modified Version. In addition, such works are not -considered parts of the Package itself, and are not subject to the -terms of this license. - - -General Provisions - -(10) Any use, modification, and distribution of the Standard or -Modified Versions is governed by this Artistic License. By using, -modifying or distributing the Package, you accept this license. Do not -use, modify, or distribute the Package, if you do not accept this -license. - -(11) If your Modified Version has been derived from a Modified -Version made by someone other than you, you are nevertheless required -to ensure that your Modified Version complies with the requirements of -this license. - -(12) This license does not grant you the right to use any trademark, -service mark, tradename, or logo of the Copyright Holder. - -(13) This license includes the non-exclusive, worldwide, -free-of-charge patent license to make, have made, use, offer to sell, -sell, import and otherwise transfer the Package with respect to any -patent claims licensable by the Copyright Holder that are necessarily -infringed by the Package. If you institute patent litigation -(including a cross-claim or counterclaim) against any party alleging -that the Package constitutes direct or contributory patent -infringement, then this Artistic License to you shall terminate on the -date that such litigation is filed. - -(14) Disclaimer of Warranty: -THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS -IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL -LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF -ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Logtalk/scripts/debian/debian-binary b/Logtalk/scripts/debian/debian-binary deleted file mode 100644 index cd5ac039d..000000000 --- a/Logtalk/scripts/debian/debian-binary +++ /dev/null @@ -1 +0,0 @@ -2.0 diff --git a/Logtalk/scripts/debian/docs b/Logtalk/scripts/debian/docs deleted file mode 100644 index de58f4ba8..000000000 --- a/Logtalk/scripts/debian/docs +++ /dev/null @@ -1,8 +0,0 @@ -BIBLIOGRAPHY.bib -CUSTOMIZE.txt -INSTALL.txt -LICENSE.txt -QUICK_START.txt -README.txt -RELEASE_NOTES.txt -UPGRADING.txt diff --git a/Logtalk/scripts/debian/logtalk.doc-base b/Logtalk/scripts/debian/logtalk.doc-base deleted file mode 100644 index efd6e0cd8..000000000 --- a/Logtalk/scripts/debian/logtalk.doc-base +++ /dev/null @@ -1,15 +0,0 @@ -Document: logtalk-docs -Title: Logtalk -Author: Paulo Moura -Abstract: Logtalk documentation. - Logtalk is an open source object-oriented logic programming language, - which can be used with a large number of back-end Prolog compilers. -Section: Apps/Programming - -Format: HTML -Index: /usr/share/logtalk/manuals/index.html -Files: /usr/share/logtalk/manuals/* - -Format: text -Files: /usr/share/logtalk/BIBLIOGRAPHY.bib /usr/share/logtalk/CUSTOMIZE.txt /usr/share/logtalk/INSTALL.txt /usr/share/logtalk/LICENSE.txt /usr/share/logtalk/QUICK_START.txt /usr/share/logtalk/README.txt /usr/share/logtalk/RELEASE_NOTES.txt /usr/share/logtalk/UPGRADING.txt - diff --git a/Logtalk/scripts/debian/menu b/Logtalk/scripts/debian/menu deleted file mode 100644 index c1708c1b3..000000000 --- a/Logtalk/scripts/debian/menu +++ /dev/null @@ -1 +0,0 @@ -?package(logtalk): needs="text" section="Apps/Programming" title="Logtalk - GNU Prolog" command="gplgt" diff --git a/Logtalk/scripts/debian/postinst b/Logtalk/scripts/debian/postinst deleted file mode 100755 index 4bab1fb36..000000000 --- a/Logtalk/scripts/debian/postinst +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -echo "" -echo "Installed Logtalk on \"/usr/share\"." - -chown -f -R -L root:root /usr/share/logtalk - -echo "" -echo "Installing and registering Logtalk online documentation..." - -if [ "$1" = configure ]; then - if which install-docs >/dev/null 2>&1; then - install-docs -i /usr/share/doc-base/logtalk-docs - fi -fi - -chown -f -R -L root:root /usr/share/doc/logtalk - -echo "Adding menu entries for some of the Logtalk integration scripts..." - -if test -x /usr/bin/update-menus; then - update-menus -fi - -echo -echo "Links to the \"cplgtdirs\", \"lgt2pdf\", \"lgt2html\", and \"lgt2xml\" scripts have" -echo "been created on \"/usr/bin\"." -echo -echo "The following integration scripts are installed for running Logtalk" -echo "with selected back-end Prolog compilers:" -echo -echo " B-Prolog: bplgt (first run must use sudo)" -echo " CIAO: ciaolgt (first run must use sudo)" -echo " CxProlog: cxlgt" -echo " ECLiPSe: eclipselgt" -echo " GNU Prolog: gplgt" -echo " K-Prolog: plclgt" -echo " Qu-Prolog: qplgt" -echo " SICStus Prolog: sicstuslgt" -echo " SWI-Prolog: swilgt" -echo " XSB: xsblgt (first run must use sudo)" -echo " XSB (MT): xsbmtlgt (first run must use sudo)" -echo " YAP: yaplgt" -echo -echo "The Prolog integration scripts can be found on \"/usr/bin\"." -echo "Make sure that the Prolog compilers are properly installed and available" -echo "on your execution path." -echo -echo "Users should run the \"cplgtdirs\" shell script once before using the" -echo "integration scripts." -echo -echo "If you get an unexpected failure when using one of the Prolog integration" -echo "scripts, consult see the \"/usr/share/logtalk/configs/NOTES.txt\" file" -echo "for compatibility notes." -echo -echo "Logtalk basic installation completed." -echo diff --git a/Logtalk/scripts/debian/postrm b/Logtalk/scripts/debian/postrm deleted file mode 100755 index 40e742438..000000000 --- a/Logtalk/scripts/debian/postrm +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -echo "Removing menu entries for some of the Logtalk integration scripts..." - -if test -x /usr/bin/update-menus; then - update-menus -fi - -echo "" -echo "You have succesfully uninstalled Logtalk!" -echo "" diff --git a/Logtalk/scripts/debian/prerm b/Logtalk/scripts/debian/prerm deleted file mode 100755 index 98f29a8d8..000000000 --- a/Logtalk/scripts/debian/prerm +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -echo "" -echo "Uninstalling and de-registering Logtalk online documentation..." - -if [ "$1" = remove -o "$1" = upgrade ]; then - if which install-docs >/dev/null 2>&1; then - install-docs -r logtalk-docs - fi -fi - -echo "" -echo "Removing Logtalk integration and documentation scripts..." - -rm -rf /usr/share/logtalk/bin diff --git a/Logtalk/scripts/debian/rules b/Logtalk/scripts/debian/rules deleted file mode 100644 index e69de29bb..000000000 diff --git a/Logtalk/scripts/install.sh b/Logtalk/scripts/install.sh deleted file mode 100755 index 531bf855b..000000000 --- a/Logtalk/scripts/install.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -if [ -z "$1" ]; then - if [ -f "/etc/debian_version" ]; then - prefix=/usr - else - case $( uname -s ) in - Darwin ) prefix=/opt/local;; - * ) prefix=/usr/local;; - esac - fi - mkdir -p $prefix -else - prefix="$1" -fi - -if ! [ -d "$prefix" ]; then - echo "Directory prefix does not exist!" - echo - exit 1 -fi - -echo -echo "Installing Logtalk on $prefix/share ..." -echo - -mkdir -p $prefix/share - -rm -rf $prefix/share/lgt2307 -rm -f $prefix/share/logtalk - -mkdir $prefix/share/lgt2307 - -cd .. -cp -R * $prefix/share/lgt2307 - -cd $prefix/share/lgt2307 -chmod a+x scripts/cleandist.sh -scripts/cleandist.sh - -cd .. -ln -sf lgt2307 logtalk - -mkdir -p $prefix/bin -cd $prefix/bin - -ln -sf ../share/logtalk/scripts/cplgtdirs.sh cplgtdirs -ln -sf ../share/logtalk/xml/lgt2pdf.sh lgt2pdf -ln -sf ../share/logtalk/xml/lgt2html.sh lgt2html -ln -sf ../share/logtalk/xml/lgt2xml.sh lgt2xml - -echo "Links to the \"cplgtdirs\", \"lgt2pdf\", \"lgt2html\", and \"lgt2xml\" scripts" -echo "have been created on \"$prefix/bin\"; you may need to add this directory" -echo "to your execution path." -echo - -ln -sf ../share/logtalk/integration/bplgt.sh bplgt -ln -sf ../share/logtalk/integration/ciaolgt.sh ciaolgt -ln -sf ../share/logtalk/integration/cxlgt.sh cxlgt -ln -sf ../share/logtalk/integration/eclipselgt.sh eclipselgt -ln -sf ../share/logtalk/integration/gplgt.sh gplgt -ln -sf ../share/logtalk/integration/plclgt.sh plclgt -ln -sf ../share/logtalk/integration/qplgt.sh qplgt -ln -sf ../share/logtalk/integration/sicstuslgt.sh sicstuslgt -ln -sf ../share/logtalk/integration/swilgt.sh swilgt -ln -sf ../share/logtalk/integration/xsblgt.sh xsblgt -ln -sf ../share/logtalk/integration/xsbmtlgt.sh xsbmtlgt -ln -sf ../share/logtalk/integration/yaplgt.sh yaplgt - -echo "The following integration scripts are installed for running Logtalk" -echo "with selected back-end Prolog compilers:" -echo -echo " B-Prolog: bplgt (first run must use sudo)" -echo " CIAO: ciaolgt (first run must use sudo)" -echo " CxProlog: cxlgt" -echo " ECLiPSe: eclipselgt" -echo " GNU Prolog: gplgt" -echo " K-Prolog: plclgt" -echo " Qu-Prolog: qplgt" -echo " SICStus Prolog: sicstuslgt" -echo " SWI-Prolog: swilgt" -echo " XSB: xsblgt (first run must use sudo)" -echo " XSB (MT): xsbmtlgt (first run must use sudo)" -echo " YAP: yaplgt" -echo -echo "The Prolog integration scripts can be found on \"$prefix/bin\"." -echo "Make sure that the Prolog compilers are properly installed and available" -echo "on your execution path." -echo -echo "Users should ensure that the environment variable LOGTALKHOME is set to" -echo "\"$prefix/share/logtalk\" and then run the \"cplgtdirs\" shell script once" -echo "before running the integration scripts." -echo -echo "If you get an unexpected failure when using one of the Prolog integration" -echo "scripts, consult the \"$prefix/share/logtalk/configs/NOTES.txt\" file" -echo "for compatibility notes." -echo -echo "Logtalk basic installation completed." -echo diff --git a/Logtalk/scripts/linux/NOTES.txt b/Logtalk/scripts/linux/NOTES.txt deleted file mode 100644 index 8236ffccd..000000000 --- a/Logtalk/scripts/linux/NOTES.txt +++ /dev/null @@ -1,9 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This directory contains files used when building Linux RPM packages. diff --git a/Logtalk/scripts/linux/build_rpm.sh b/Logtalk/scripts/linux/build_rpm.sh deleted file mode 100644 index 60355fe9f..000000000 --- a/Logtalk/scripts/linux/build_rpm.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -dir="$PWD" -cd .. - -LOGTALKHOME=/usr/local/share/logtalk ./uninstall.sh -./install.sh - -cd /usr/local/share -tar -cjf lgt2307.tar.bz2 lgt2307 -mv lgt2307.tar.bz2 /usr/src/redhat/SOURCES - -cd "$dir" -rpmbuild -ba --target=noarch-*-linux logtalk.spec - -cd /usr/src/redhat/RPMS/noarch -echo $PWD -ls -l diff --git a/Logtalk/scripts/linux/logtalk.spec b/Logtalk/scripts/linux/logtalk.spec deleted file mode 100644 index a1b6bd791..000000000 --- a/Logtalk/scripts/linux/logtalk.spec +++ /dev/null @@ -1,183 +0,0 @@ -Name: logtalk -Summary: Logtalk - Open source object-oriented logic programming language -Version: 2.30.7 -Release: 1 -License: Artistic License 2.0 -Group: Development/Languages -Packager: Paulo Moura -Source: http://logtalk.org/files/lgt2307.tar.bz2 -BuildArchitectures: noarch -URL: http://logtalk.org/ -Prefix: /usr/local -AutoReqProv: no -%description -Logtalk is an open source object-oriented logic programming language that can use most Prolog implementations as a back-end compiler. As a multi-paradigm language, Logtalk includes support for both prototypes and classes, protocols, component-based programming through category-based composition, event-driven programming, and multi-threading programming. - -%prep - -%setup -n lgt2307 - -%build - -%install -mkdir -p /usr/local/share -rm -rf /usr/local/share/lgt2307 -rm -f /usr/local/share/logtalk -mkdir /usr/local/share/lgt2307 -cp -R * /usr/local/share/lgt2307 -cd /usr/local/share/lgt2307 -chmod a+x scripts/cleandist.sh -scripts/cleandist.sh -cd .. -ln -sf lgt2307 logtalk -cd .. -mkdir -p bin -cd bin -ln -sf ../share/logtalk/integration/bplgt.sh bplgt -ln -sf ../share/logtalk/integration/ciaolgt.sh ciaolgt -ln -sf ../share/logtalk/integration/cxlgt.sh cxlgt -ln -sf ../share/logtalk/integration/eclipselgt.sh eclipselgt -ln -sf ../share/logtalk/integration/gplgt.sh gplgt -ln -sf ../share/logtalk/integration/plclgt.sh plclgt -ln -sf ../share/logtalk/integration/qplgt.sh qplgt -ln -sf ../share/logtalk/integration/sicstuslgt.sh sicstuslgt -ln -sf ../share/logtalk/integration/swilgt.sh swilgt -ln -sf ../share/logtalk/integration/xsblgt.sh xsblgt -ln -sf ../share/logtalk/integration/xsbmtlgt.sh xsbmtlgt -ln -sf ../share/logtalk/integration/yaplgt.sh yaplgt -ln -sf ../share/logtalk/scripts/cplgtdirs.sh cplgtdirs -ln -sf ../share/logtalk/xml/lgt2pdf.sh lgt2pdf -ln -sf ../share/logtalk/xml/lgt2html.sh lgt2html -ln -sf ../share/logtalk/xml/lgt2xml.sh lgt2xml - -%clean -cd /usr/local/share -rm -rf lgt2307 -rm -f logtalk -cd ../bin -rm -f bplgt -rm -f ciaolgt -rm -f cplgtdirs -rm -f cxlgt -rm -f eclipselgt -rm -f gplgt -rm -f lgt2html -rm -f lgt2pdf -rm -f lgt2xml -rm -f plclgt -rm -f qplgt -rm -f sicstuslgt -rm -f swilgt -rm -f xsblgt -rm -f xsbmtlgt -rm -f yaplgt - -%files -%defattr(-,root,root) -%doc /usr/local/share/lgt2307/BIBLIOGRAPHY.bib -%doc /usr/local/share/lgt2307/CUSTOMIZE.txt -%doc /usr/local/share/lgt2307/INSTALL.txt -%doc /usr/local/share/lgt2307/LICENSE.txt -%doc /usr/local/share/lgt2307/QUICK_START.txt -%doc /usr/local/share/lgt2307/README.txt -%doc /usr/local/share/lgt2307/RELEASE_NOTES.txt -%doc /usr/local/share/lgt2307/UPGRADING.txt -/usr/local/share/lgt2307/compiler -/usr/local/share/lgt2307/configs -/usr/local/share/lgt2307/contributions -/usr/local/share/lgt2307/examples -/usr/local/share/lgt2307/integration -/usr/local/share/lgt2307/libpaths -/usr/local/share/lgt2307/library -%docdir /usr/local/share/lgt2307/manuals -/usr/local/share/lgt2307/manuals -/usr/local/share/lgt2307/scripts -/usr/local/share/lgt2307/wenv -/usr/local/share/lgt2307/xml -/usr/local/share/logtalk -/usr/local/bin/cplgtdirs -/usr/local/bin/lgt2pdf -/usr/local/bin/lgt2html -/usr/local/bin/lgt2xml -/usr/local/bin/bplgt -/usr/local/bin/ciaolgt -/usr/local/bin/cxlgt -/usr/local/bin/eclipselgt -/usr/local/bin/gplgt -/usr/local/bin/plclgt -/usr/local/bin/qplgt -/usr/local/bin/sicstuslgt -/usr/local/bin/swilgt -/usr/local/bin/xsblgt -/usr/local/bin/xsbmtlgt -/usr/local/bin/yaplgt - -%post -echo -echo "Installed Logtalk on \"$RPM_INSTALL_PREFIX/share\"." -echo -echo "Links to the \"cplgtdirs\", \"lgt2pdf\", \"lgt2html\", and \"lgt2xml\" scripts" -echo "have been created on \"$RPM_INSTALL_PREFIX/bin\"; you may need to add this directory" -echo "to your execution path." -echo -echo "The following integration scripts are installed for running Logtalk" -echo "with selected back-end Prolog compilers:" -echo -echo " B-Prolog: bplgt (first run must use sudo)" -echo " CIAO: ciaolgt (first run must use sudo)" -echo " CxProlog: cxlgt" -echo " ECLiPSe: eclipselgt" -echo " GNU Prolog: gplgt" -echo " K-Prolog: plclgt" -echo " Qu-Prolog: qplgt" -echo " SICStus Prolog: sicstuslgt" -echo " SWI-Prolog: swilgt" -echo " XSB: xsblgt (first run must use sudo)" -echo " XSB (MT): xsbmtlgt (first run must use sudo)" -echo " YAP: yaplgt" -echo -echo "The Prolog integration scripts can be found on \"$RPM_INSTALL_PREFIX/bin\"." -echo "Make sure that the Prolog compilers are properly installed and available" -echo "on your execution path." -echo -echo "If you get an unexpected failure when using one of the Prolog integration" -echo "scripts, consult the \"$RPM_INSTALL_PREFIX/share/logtalk/configs/NOTES.txt\" file" -echo "for compatibility notes." -echo -mkdir -p /etc/profile.d -echo "# Logtalk environment setup" > /etc/profile.d/logtalk.sh -echo "" >> /etc/profile.d/logtalk.sh -echo "# Logtalk installation directory:" >> /etc/profile.d/logtalk.sh -echo "export LOGTALKHOME=$RPM_INSTALL_PREFIX/share/logtalk" >> /etc/profile.d/logtalk.sh -echo "" >> /etc/profile.d/logtalk.sh -echo "# Default location for Logtalk end-user files:" >> /etc/profile.d/logtalk.sh -echo "export LOGTALKUSER=\$HOME/logtalk" >> /etc/profile.d/logtalk.sh -chmod a+x /etc/profile.d/logtalk.sh -echo "# Logtalk environment setup" > /etc/profile.d/logtalk.csh -echo "" >> /etc/profile.d/logtalk.csh -echo "# Logtalk installation directory:" >> /etc/profile.d/logtalk.csh -echo "setenv LOGTALKHOME $RPM_INSTALL_PREFIX/share/logtalk" >> /etc/profile.d/logtalk.csh -echo "" >> /etc/profile.d/logtalk.csh -echo "# Default location for Logtalk end-user files:" >> /etc/profile.d/logtalk.csh -echo "setenv LOGTALKUSER \$HOME/logtalk" >> /etc/profile.d/logtalk.csh -chmod a+x /etc/profile.d/logtalk.csh -echo "Defined the following environment variables for all users:" -echo -echo " Logtalk installation directory: LOGTALKHOME = $RPM_INSTALL_PREFIX/share/logtalk" -echo " Default Logtalk user files directory: LOGTALKUSER = \$HOME/logtalk" -echo -echo "You may need to logout and login again or start a new shell in order to" -echo "use the new environment variables." -echo -echo "Users may change the default value of the LOGTALKUSER environment variable" -echo "in their shell configuration files if they already use, or want to use, a " -echo "different location for the Logtalk user files directory. This directory " -echo "is created by running the \"cplgtdirs\" shell script, which must be run " -echo "once by each user before using the integration scripts." -echo -echo "Logtalk basic installation completed." -echo - -%postun -rm -f /etc/profile.d/logtalk.sh 2> /dev/null -rm -f /etc/profile.d/logtalk.csh 2> /dev/null diff --git a/Logtalk/scripts/macosx/License.html b/Logtalk/scripts/macosx/License.html deleted file mode 100644 index 8bd8f5bdf..000000000 --- a/Logtalk/scripts/macosx/License.html +++ /dev/null @@ -1,205 +0,0 @@ - -
-		       The Artistic License 2.0
-
-	    Copyright (c) 2000-2006, The Perl Foundation.
-
-     Everyone is permitted to copy and distribute verbatim copies
-      of this license document, but changing it is not allowed.
-
-Preamble
-
-This license establishes the terms under which a given free software
-Package may be copied, modified, distributed, and/or redistributed.
-The intent is that the Copyright Holder maintains some artistic
-control over the development of that Package while still keeping the
-Package available as open source and free software.
-
-You are always permitted to make arrangements wholly outside of this
-license directly with the Copyright Holder of a given Package.  If the
-terms of this license do not permit the full use that you propose to
-make of the Package, you should contact the Copyright Holder and seek
-a different licensing arrangement. 
-
-Definitions
-
-    "Copyright Holder" means the individual(s) or organization(s)
-    named in the copyright notice for the entire Package.
-
-    "Contributor" means any party that has contributed code or other
-    material to the Package, in accordance with the Copyright Holder's
-    procedures.
-
-    "You" and "your" means any person who would like to copy,
-    distribute, or modify the Package.
-
-    "Package" means the collection of files distributed by the
-    Copyright Holder, and derivatives of that collection and/or of
-    those files. A given Package may consist of either the Standard
-    Version, or a Modified Version.
-
-    "Distribute" means providing a copy of the Package or making it
-    accessible to anyone else, or in the case of a company or
-    organization, to others outside of your company or organization.
-
-    "Distributor Fee" means any fee that you charge for Distributing
-    this Package or providing support for this Package to another
-    party.  It does not mean licensing fees.
-
-    "Standard Version" refers to the Package if it has not been
-    modified, or has been modified only in ways explicitly requested
-    by the Copyright Holder.
-
-    "Modified Version" means the Package, if it has been changed, and
-    such changes were not explicitly requested by the Copyright
-    Holder. 
-
-    "Original License" means this Artistic License as Distributed with
-    the Standard Version of the Package, in its current version or as
-    it may be modified by The Perl Foundation in the future.
-
-    "Source" form means the source code, documentation source, and
-    configuration files for the Package.
-
-    "Compiled" form means the compiled bytecode, object code, binary,
-    or any other form resulting from mechanical transformation or
-    translation of the Source form.
-
-
-Permission for Use and Modification Without Distribution
-
-(1)  You are permitted to use the Standard Version and create and use
-Modified Versions for any purpose without restriction, provided that
-you do not Distribute the Modified Version.
-
-
-Permissions for Redistribution of the Standard Version
-
-(2)  You may Distribute verbatim copies of the Source form of the
-Standard Version of this Package in any medium without restriction,
-either gratis or for a Distributor Fee, provided that you duplicate
-all of the original copyright notices and associated disclaimers.  At
-your discretion, such verbatim copies may or may not include a
-Compiled form of the Package.
-
-(3)  You may apply any bug fixes, portability changes, and other
-modifications made available from the Copyright Holder.  The resulting
-Package will still be considered the Standard Version, and as such
-will be subject to the Original License.
-
-
-Distribution of Modified Versions of the Package as Source 
-
-(4)  You may Distribute your Modified Version as Source (either gratis
-or for a Distributor Fee, and with or without a Compiled form of the
-Modified Version) provided that you clearly document how it differs
-from the Standard Version, including, but not limited to, documenting
-any non-standard features, executables, or modules, and provided that
-you do at least ONE of the following:
-
-    (a)  make the Modified Version available to the Copyright Holder
-    of the Standard Version, under the Original License, so that the
-    Copyright Holder may include your modifications in the Standard
-    Version.
-
-    (b)  ensure that installation of your Modified Version does not
-    prevent the user installing or running the Standard Version. In
-    addition, the Modified Version must bear a name that is different
-    from the name of the Standard Version.
-
-    (c)  allow anyone who receives a copy of the Modified Version to
-    make the Source form of the Modified Version available to others
-    under
-		
-	(i)  the Original License or
-
-	(ii)  a license that permits the licensee to freely copy,
-	modify and redistribute the Modified Version using the same
-	licensing terms that apply to the copy that the licensee
-	received, and requires that the Source form of the Modified
-	Version, and of any works derived from it, be made freely
-	available in that license fees are prohibited but Distributor
-	Fees are allowed.
-
-
-Distribution of Compiled Forms of the Standard Version 
-or Modified Versions without the Source
-
-(5)  You may Distribute Compiled forms of the Standard Version without
-the Source, provided that you include complete instructions on how to
-get the Source of the Standard Version.  Such instructions must be
-valid at the time of your distribution.  If these instructions, at any
-time while you are carrying out such distribution, become invalid, you
-must provide new instructions on demand or cease further distribution.
-If you provide valid instructions or cease distribution within thirty
-days after you become aware that the instructions are invalid, then
-you do not forfeit any of your rights under this license.
-
-(6)  You may Distribute a Modified Version in Compiled form without
-the Source, provided that you comply with Section 4 with respect to
-the Source of the Modified Version.
-
-
-Aggregating or Linking the Package 
-
-(7)  You may aggregate the Package (either the Standard Version or
-Modified Version) with other packages and Distribute the resulting
-aggregation provided that you do not charge a licensing fee for the
-Package.  Distributor Fees are permitted, and licensing fees for other
-components in the aggregation are permitted. The terms of this license
-apply to the use and Distribution of the Standard or Modified Versions
-as included in the aggregation.
-
-(8) You are permitted to link Modified and Standard Versions with
-other works, to embed the Package in a larger work of your own, or to
-build stand-alone binary or bytecode versions of applications that
-include the Package, and Distribute the result without restriction,
-provided the result does not expose a direct interface to the Package.
-
-
-Items That are Not Considered Part of a Modified Version 
-
-(9) Works (including, but not limited to, modules and scripts) that
-merely extend or make use of the Package, do not, by themselves, cause
-the Package to be a Modified Version.  In addition, such works are not
-considered parts of the Package itself, and are not subject to the
-terms of this license.
-
-
-General Provisions
-
-(10)  Any use, modification, and distribution of the Standard or
-Modified Versions is governed by this Artistic License. By using,
-modifying or distributing the Package, you accept this license. Do not
-use, modify, or distribute the Package, if you do not accept this
-license.
-
-(11)  If your Modified Version has been derived from a Modified
-Version made by someone other than you, you are nevertheless required
-to ensure that your Modified Version complies with the requirements of
-this license.
-
-(12)  This license does not grant you the right to use any trademark,
-service mark, tradename, or logo of the Copyright Holder.
-
-(13)  This license includes the non-exclusive, worldwide,
-free-of-charge patent license to make, have made, use, offer to sell,
-sell, import and otherwise transfer the Package with respect to any
-patent claims licensable by the Copyright Holder that are necessarily
-infringed by the Package. If you institute patent litigation
-(including a cross-claim or counterclaim) against any party alleging
-that the Package constitutes direct or contributory patent
-infringement, then this Artistic License to you shall terminate on the
-date that such litigation is filed.
-
-(14)  Disclaimer of Warranty:
-THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS
-IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
-WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
-NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL
-LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
-DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
diff --git a/Logtalk/scripts/macosx/NOTES.txt b/Logtalk/scripts/macosx/NOTES.txt deleted file mode 100644 index 7413bbd4f..000000000 --- a/Logtalk/scripts/macosx/NOTES.txt +++ /dev/null @@ -1,10 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This directory contains files used when building MacOS X installer -packages. diff --git a/Logtalk/scripts/macosx/Portfile b/Logtalk/scripts/macosx/Portfile deleted file mode 100644 index 24af05b56..000000000 --- a/Logtalk/scripts/macosx/Portfile +++ /dev/null @@ -1,73 +0,0 @@ -# $Id: Portfile 26918 2007-07-11 15:28:15Z gwright@macports.org $ - -PortSystem 1.0 -name logtalk -version 2.30.7 - -categories lang -maintainers pmoura@logtalk.org -platforms darwin freebsd linux -description Logtalk - Open source object-oriented logic programming language - -long_description \ - Logtalk is an open source object-oriented logic programming language \ - that can use most Prolog implementations as a back-end compiler. \ - As a multi-paradigm language, Logtalk includes support for both \ - prototypes and classes, protocols, component-based programming \ - through category-based composition, event-driven programming, and \ - multi-threading programming. - -homepage http://logtalk.org/ -master_sites ${homepage}/files/ - -checksums md5 0653f6e2e10219111deed4b2096e6394 - -distname lgt2307 -extract.suffix .tar.bz2 - -use_bzip2 yes - -configure {} - -build {} - -destroot { - cd ${workpath}/${worksrcdir}/scripts - system "./install.sh ${destroot}/${prefix}" -} - -post-pkg { - set resources ${workpath}/${name}-${version}.pkg/Contents/Resources/ - file copy -force -- ${workpath}/${worksrcdir}/scripts/macosx/License.html ${resources} - file copy -force -- ${workpath}/${worksrcdir}/scripts/macosx/ReadMe.html ${resources} - file copy -force -- ${workpath}/${worksrcdir}/scripts/macosx/Welcome.html ${resources} - file copy -force -- ${workpath}/${worksrcdir}/scripts/macosx/postflight ${resources} -} - -post-activate { - ui_msg "****************************************************************************" - ui_msg "* Integration scripts have been created for running Logtalk with selected" - ui_msg "* back-end Prolog compilers (which must be properly installed for running" - ui_msg "* the scripts!):" - ui_msg "*" - ui_msg "* B-Prolog: bplgt (first run must use sudo)" - ui_msg "* CIAO: ciaolgt (first run must use sudo)" - ui_msg "* CxProlog: cxlgt" - ui_msg "* ECLiPSe: eclipselgt" - ui_msg "* GNU Prolog: gplgt" - ui_msg "* K-Prolog: plclgt" - ui_msg "* Qu-Prolog: qplgt" - ui_msg "* SICStus Prolog: sicstuslgt" - ui_msg "* SWI-Prolog: swilgt" - ui_msg "* XSB: xsblgt (first run must use sudo)" - ui_msg "* XSB (MT): xsbmtlgt (first run must use sudo)" - ui_msg "* YAP: yaplgt" - ui_msg "*" - ui_msg "* Remember to set the environment variable LOGTALKHOME to the path to" - ui_msg "* the Logtalk distribution: ${prefix}/share/logtalk" - ui_msg "* and the environment variable LOGTALKUSER to your local configuration" - ui_msg "* directory (usually ~/logtalk), which you can create by running the" - ui_msg "* command cplgtdirs. See the file \$LOGTALKHOME/CUSTOMIZE.txt for details" - ui_msg "* on how to customize your working environment." - ui_msg "****************************************************************************" -} diff --git a/Logtalk/scripts/macosx/ReadMe.html b/Logtalk/scripts/macosx/ReadMe.html deleted file mode 100644 index d5c45cc1b..000000000 --- a/Logtalk/scripts/macosx/ReadMe.html +++ /dev/null @@ -1,115 +0,0 @@ -

Logtalk

-

Open source object-oriented logic programming language

- -

Release 2.30.7

- -

Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.

- -

CONTENTS

- -
    -
  1. License
  2. -
  3. Home of Logtalk package
  4. -
  5. Registration
  6. -
  7. Support
  8. -
  9. Installation
  10. -
  11. Customization
  12. -
  13. Quick start
  14. -
  15. Documentation
  16. -
  17. Upgrading
  18. -
  19. Citations
  20. -
  21. Contributions
  22. -
- -

1. License

- -

The overall copyright and permission notice for Logtalk can be found in the -LICENSE file in this directory. Logtalk follows the Artistic License 2.0. -The copyright notice and license applies to all files in this release -(including sources, documentation, and examples) unless otherwise explicitly -stated.

- -

2. Home of Logtalk package

- -

The latest release of the Logtalk package is always available at the URL:

- -
-

http://logtalk.org/

-
- -

At this address you can also find additional documentation and information -about Logtalk.

- -

3. Registration

- -

-To register as a Logtalk user either use the registration form found at the Logtalk web site, http://logtalk.org/regform.html, or send an email message to:

- -
-

registration@logtalk.org

-
- -

with the following information:

- -

email address, full name, organization, organization type (education, -commercial, government, ...), prolog compilers used (optional), -platforms (mac, pc, unix,...) (optional)

- -

4. Support

- -

-For support options, please consult the page http://logtalk.org/support.html. -

- -

5. Installation

- -

Logtalk can be installed either from sources by running a few shell scripts -or by using one of the provided installers, depending on your operating -system. For manual installation, see the file INSTALL.txt for detailed -instructions.

- -

See the user manual for a description of the source files organization -and for using instructions (to read the user manual open the file -manuals/index.html with a web browser). Most files are formatted -using four-space tabs.

- -

6. Customization

- -

The file CUSTOMIZE.txt provides detailed instructions for customizing the -Logtalk installation and working environment.

- -

7. Quick start

- -

The file QUICK_START.txt provides quick instructions for those of you in a hurry -to run Logtalk, provided that your favorite Prolog compiler is supported.

- -

7. Documentation

- -

The reference and user manuals and the tutorial are provided in XHTML format -and can be found in the "manuals" directory.

- -

The file RELEASE_NOTES.txt contains descriptions of all Logtalk updates since the -first public version. Read it carefully if you have been using a previous -Logtalk version.

- -

8. Upgrading

- -

If you are upgrading from a previous Logtalk version, please check the file -UPGRADING.txt for instructions on how to upgrade your programs or your custom -configuration files to run under this new version.

- -

9. Citations

- -

If you want to cite Logtalk in your publications, please consult the file -BIBLIOGRAPHY.bib for bibliographic references in BibTeX format.

- -

10. Contributions

- -

Contributions, constructive criticisms, code, bug reports, and suggestions -are always welcome. If you want to contribute to this project, drop me a -line to the support address given above.

- -

Happy Logtalking!

- -

Paulo Moura -pmoura@logtalk.org

diff --git a/Logtalk/scripts/macosx/Welcome.html b/Logtalk/scripts/macosx/Welcome.html deleted file mode 100644 index 0126eca66..000000000 --- a/Logtalk/scripts/macosx/Welcome.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - Install Logtalk - - -

-Welcome to the Logtalk for Mac OS X Installer -

-

-Logtalk is an open source object-oriented logic programming language that can use most Prolog implementations as a back-end compiler. As a multi-paradigm language, Logtalk includes support for both prototypes and classes, protocols, component-based programming through category-based composition, event-driven programming, and multi-threading programming. -

-

-This installer guides you through the steps necessary to install Logtalk for Mac OS X. Logtalk is installed on the /opt/local/share/logtalk directory. A link to the Logtalk installation folder is automatically created on the Applications folder. After completing the installation, each Logtalk end-user must run the shell command cplgtdirs once before using the Prolog integration scripts. This command creates a folder named logtalk on the user's home directory containing configuration files, examples, and documentation. Inside this folder is a link to a CUSTOMIZE.txt file describes how to customize Logtalk for your personal use. Links to the Prolog integration scripts are created on the /opt/local/bin directory, which must be on your system path. See the /Applications/Logtalk/QUICK_START.txt file for instructions on how to run Logtalk. -

-

-To get started, click Continue. -

- - diff --git a/Logtalk/scripts/macosx/postflight b/Logtalk/scripts/macosx/postflight deleted file mode 100644 index 3d2e18faf..000000000 --- a/Logtalk/scripts/macosx/postflight +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -echo "" -echo "Checking for the Logtalk environment variable definitions..." -echo "" - -if grep "LOGTALKHOME=/opt/local/share/logtalk" /etc/profile >/dev/null 2>&1; then - echo "Logtalk environment variables default values already set for bash!" -else - /bin/cp -fp /etc/profile /etc/profile.lgtsaved - echo '' >> /etc/profile - echo '# Logtalk environment variables default values' >> /etc/profile - echo 'LOGTALKHOME=/opt/local/share/logtalk' >> /etc/profile - echo 'LOGTALKUSER=$HOME/logtalk' >> /etc/profile - echo 'export LOGTALKHOME LOGTALKUSER' >> /etc/profile -fi - -if grep "setenv LOGTALKHOME /opt/local/share/logtalk" /etc/csh.cshrc >/dev/null 2>&1; then - echo "Logtalk environment variables default values already set for csh!" -else - /bin/cp -fp /etc/csh.cshrc /etc/csh.cshrc.lgtsaved - echo '' >> /etc/csh.cshrc - echo '# Logtalk environment variables default values' >> /etc/csh.cshrc - echo "setenv LOGTALKHOME /opt/local/share/logtalk" >> /etc/csh.cshrc - echo 'setenv LOGTALKUSER $HOME/logtalk' >> /etc/csh.cshrc -fi - -echo "" -echo "Creating a link to the Logtalk installation folder in the /Applications folder..." -ln -sf /opt/local/share/logtalk /Applications/Logtalk - -echo "" -echo "You have succesfully installed Logtalk!" -echo "" diff --git a/Logtalk/scripts/make_qplgt.sh b/Logtalk/scripts/make_qplgt.sh deleted file mode 100755 index 647b3f6c9..000000000 --- a/Logtalk/scripts/make_qplgt.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.2 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -# makes a shell script named "qplgt" for running Logtalk with Qu-Prolog -# (based on script code contributed by Peter Robinson); this script does -# not read at runtime the config and the libpaths files: you will need to -# run this script again if you modify these files - - -echo -echo "Creating a script named qplgt for running Logtalk with Qu-Prolog..." -echo - -if ! [ "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME should be defined first!" - echo "Trying default Logtalk installation directories..." - if [ -d "/usr/local/share/logtalk" ]; then - LOGTALKHOME=/usr/local/share/logtalk - echo "Using Logtalk installation at \"/usr/local/share/logtalk\"" - elif [ -d "/usr/share/logtalk" ]; then - LOGTALKHOME=/usr/share/logtalk - echo "Using Logtalk installation at \"/usr/share/logtalk\"" - elif [ -d "/opt/local/share/logtalk" ]; then - LOGTALKHOME=/opt/local/share/logtalk - echo "Using Logtalk installation at \"/opt/local/share/logtalk\"" - elif [ -d "/opt/share/logtalk" ]; then - LOGTALKHOME=/opt/share/logtalk - echo "Using Logtalk installation at \"/opt/share/logtalk\"" - else - echo "Unable to locate Logtalk installation directory!" - echo - exit 1 - fi - elif ! [ -d "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME points to a non-existing directory!" - echo "Its current value is: $LOGTALKHOME" - echo "The variable must be set to your Logtalk installation directory!" - echo - exit 1 -fi - -if [ -z "$1" ]; then - prefix=/usr/local -else - prefix="$1" -fi - -if ! [ -d "$prefix" ]; then - echo "Directory prefix does not exist!" - echo - exit 1 -fi - -cd "$LOGTALKHOME" -mkdir -p bin - -cd configs -cp qu.config qu.ql -echo "fcompile('qu.ql', [assemble_only(true)]), load(qu). \ -chdir('../compiler/'), fcompile('logtalk.pl', [assemble_only(true), string_table(256)]), load(logtalk). \ -chdir('../libpaths/'), fcompile('libpaths.pl', [assemble_only(true)]), load(libpaths)." | qp -s 3072 -d 1024 -h 2048 -qc -c qphook.ql -cd ../bin -qc -s 3072 -d 1024 -h 2048 -o qplgt ../configs/qphook.qo ../configs/qu.qo ../compiler/logtalk.qo ../libpaths/libpaths.qo -chmod a+x qplgt - -mkdir -p $prefix/bin -ln -sf $LOGTALKHOME/bin/qplgt $prefix/bin/qplgt - -rm ../configs/qu.ql -rm ../configs/qphook.qo -rm ../configs/qu.qo -rm ../compiler/logtalk.qo -rm ../libpaths/libpaths.qo - -echo "Done. A link to the script was been created in $prefix/bin." -echo "The script must be regenerated whenever changes are made to" -echo "either the config file or the libpaths file." -echo -echo "Users should ensure that the environment variables LOGTALKHOME" -echo "and LOGTALKUSER are defined and then run the \"cplgtdirs\" script" -echo "once prior to using the qplgt script." -echo diff --git a/Logtalk/scripts/uninstall.sh b/Logtalk/scripts/uninstall.sh deleted file mode 100755 index e8d4ee132..000000000 --- a/Logtalk/scripts/uninstall.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh - -## ================================================================ -## Logtalk - Open source object-oriented logic programming language -## Release 2.30.7 -## -## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -## ================================================================ - -echo -echo "Uninstalling Logtalk system-level files..." -echo - -if ! [ "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME should be defined first!" - echo "Trying default Logtalk installation directories..." - if [ -d "/usr/local/share/logtalk" ]; then - LOGTALKHOME=/usr/local/share/logtalk - echo "Using Logtalk installation at \"/usr/local/share/logtalk\"" - elif [ -d "/usr/share/logtalk" ]; then - LOGTALKHOME=/usr/share/logtalk - echo "Using Logtalk installation at \"/usr/share/logtalk\"" - elif [ -d "/opt/local/share/logtalk" ]; then - LOGTALKHOME=/opt/local/share/logtalk - echo "Using Logtalk installation at \"/opt/local/share/logtalk\"" - elif [ -d "/opt/share/logtalk" ]; then - LOGTALKHOME=/opt/share/logtalk - echo "Using Logtalk installation at \"/opt/share/logtalk\"" - else - echo "Unable to locate Logtalk installation directory!" - echo - exit 1 - fi - elif ! [ -d "$LOGTALKHOME" ]; then - echo "The environment variable LOGTALKHOME points to a non-existing directory!" - echo "Its current value is: $LOGTALKHOME" - echo "The variable must be set to your Logtalk installation directory!" - echo - exit 1 -fi - -cd $LOGTALKHOME/.. -rm -rf lgt2307 -rm -f logtalk -cd ../bin -rm -f bplgt -rm -f ciaolgt -rm -f cplgtdirs -rm -f cxlgt -rm -f eclipselgt -rm -f gplgt -rm -f lgt2html -rm -f lgt2pdf -rm -f lgt2xml -rm -f plclgt -rm -f qplgt -rm -f sicstuslgt -rm -f swilgt -rm -f xsblgt -rm -f xsbmtlgt -rm -f yaplgt - -echo "Logtalk system-level uninstall completed. For uninstalling user-level" -echo "Logtalk files simply delete the LOGTALKUSER directories." -echo diff --git a/Logtalk/scripts/windows/NOTES.txt b/Logtalk/scripts/windows/NOTES.txt deleted file mode 100644 index 952cbb0ed..000000000 --- a/Logtalk/scripts/windows/NOTES.txt +++ /dev/null @@ -1,12 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This directory contains files used when building Windows 2000/XP GUI -installers using Inno Setup 5.1.11 (or a later version): - - http://www.jrsoftware.org/isinfo.php diff --git a/Logtalk/scripts/windows/logtalk.iss b/Logtalk/scripts/windows/logtalk.iss deleted file mode 100644 index 4e2d85b0d..000000000 --- a/Logtalk/scripts/windows/logtalk.iss +++ /dev/null @@ -1,289 +0,0 @@ -; Script generated by the Inno Setup Script Wizard. - -#define MyAppName "Logtalk" -#define MyAppVerName "Logtalk 2.30.7" -#define MyAppPublisher "Logtalk.org" -#define MyAppURL "http://logtalk.org" -#define MyAppUrlName "Logtalk Web Site.url" -#define MyAppRegURL "http://logtalk.org/regform.html" -#define MyAppRegUrlName "Logtalk Registration.url" - -#define LOGTALKHOME "{reg:HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment,LOGTALKHOME|{pf}\Logtalk}" -#define LOGTALKUSER "{reg:HKCU\Environment,LOGTALKUSER|{userdocs}\Logtalk}" - -[Setup] -AppName={#MyAppName} -AppVerName={#MyAppVerName} -AppPublisher={#MyAppPublisher} -AppPublisherURL={#MyAppURL} -AppSupportURL={#MyAppURL} -AppUpdatesURL={#MyAppURL} -ChangesEnvironment=yes -DefaultDirName={#LOGTALKHOME} -DefaultGroupName={#MyAppName} -DisableProgramGroupPage=yes -LicenseFile=C:\logtalk\LICENSE.txt -InfoBeforeFile=C:\logtalk\README.txt -OutputBaseFilename=lgt2307 -Compression=lzma -SolidCompression=yes -PrivilegesRequired=none - -VersionInfoVersion=2.30.7 -VersionInfoCopyright= Paulo Moura, 1998-2007 - -AllowRootDirectory=yes -UninstallFilesDir="{userdocs}\Logtalk uninstaller" - -MinVersion=0,5.0 - -[Types] -Name: "full"; Description: "Full installation (recommended)" -Name: "base"; Description: "Base system installation" -Name: "user"; Description: "User data files installation (must be run by all end-users)" -Name: "prolog"; Description: "Prolog integration (see documentation for compatibility details)" -Name: "custom"; Description: "Custom installation"; Flags: iscustom - -[Components] -Name: "base"; Description: "Base system"; Types: full base custom; Flags: disablenouninstallwarning -Name: "user"; Description: "User data files"; Types: full user custom; Flags: checkablealone disablenouninstallwarning -Name: "user\backup"; Description: "Backup current user data files"; Types: full user custom; Flags: disablenouninstallwarning -Name: "prolog"; Description: "Prolog integration"; Types: full prolog custom; Flags: disablenouninstallwarning -Name: "prolog\bp"; Description: "B-Prolog integration (version 7.0 or later)"; Types: full prolog custom; Flags: disablenouninstallwarning -Name: "prolog\ciao"; Description: "Ciao Prolog integration (version 1.10#5 or later)"; Types: full prolog custom; Flags: disablenouninstallwarning -Name: "prolog\eclipse"; Description: "ECLiPSe integration (version 5.10#26 or later)"; Types: full prolog custom; Flags: disablenouninstallwarning -Name: "prolog\gprolog"; Description: "GNU Prolog integration (version 1.2.16 or later)"; Types: full prolog custom; Flags: disablenouninstallwarning -Name: "prolog\plc"; Description: "K-Prolog integration (version 5.1.4 or later)"; Types: full prolog custom; Flags: disablenouninstallwarning -Name: "prolog\sicstus"; Description: "SICStus Prolog integration (versions 3.12.x, 4.0)"; Types: full prolog custom; Flags: disablenouninstallwarning -Name: "prolog\swi"; Description: "SWI-Prolog integration (version 5.6.16 or later)"; Types: full prolog custom; Flags: disablenouninstallwarning -Name: "prolog\xsb"; Description: "XSB integration (version 3.1 or later)"; Types: full prolog custom; Flags: disablenouninstallwarning -Name: "prolog\yap"; Description: "YAP integration (version 5.1.2 or later)"; Types: full prolog custom; Flags: disablenouninstallwarning - -[Tasks] -Name: registration; Description: "&Register {#MyAppName} (opens a web page; requires an Internet connection)"; Components: base user -Name: shortcut; Description: "&Create a desktop shortcut to the Logtalk user folder"; Components: user - -[Languages] -Name: "english"; MessagesFile: "compiler:Default.isl" - -[Messages] -BeveledLabel=Logtalk 2.30.7 Paulo Moura, 1998-2007 - -[Dirs] -Name: {code:GetLgtUserDir}; Components: user; Flags: uninsneveruninstall -Name: "{userdocs}\Logtalk uninstaller" - -[Files] -Source: "C:\logtalk\*"; Excludes: ".*,CVS"; DestDir: "{app}"; Components: base; Flags: ignoreversion recursesubdirs createallsubdirs - -Source: "C:\logtalk\configs\*"; Excludes: ".*,CVS"; DestDir: "{code:GetLgtUserDir}\configs"; Components: user; Flags: ignoreversion recursesubdirs createallsubdirs uninsneveruninstall -Source: "C:\logtalk\contributions\*"; Excludes: ".*,CVS"; DestDir: "{code:GetLgtUserDir}\contributions"; Components: user; Flags: ignoreversion recursesubdirs createallsubdirs uninsneveruninstall -Source: "C:\logtalk\examples\*"; Excludes: ".*,CVS"; DestDir: "{code:GetLgtUserDir}\examples"; Components: user; Flags: ignoreversion recursesubdirs createallsubdirs uninsneveruninstall -Source: "C:\logtalk\libpaths\*"; Excludes: ".*,CVS"; DestDir: "{code:GetLgtUserDir}\libpaths"; Components: user; Flags: ignoreversion recursesubdirs createallsubdirs uninsneveruninstall -Source: "C:\logtalk\library\*"; Excludes: ".*,CVS"; DestDir: "{code:GetLgtUserDir}\library"; Components: user; Flags: ignoreversion recursesubdirs createallsubdirs uninsneveruninstall -Source: "C:\logtalk\xml\*"; Excludes: ".*,CVS"; DestDir: "{code:GetLgtUserDir}\xml"; Components: user; Flags: ignoreversion recursesubdirs createallsubdirs uninsneveruninstall - -Source: "C:\logtalk\configs\amzi.config"; DestDir: "{code:GetLgtUserDir}\configs"; DestName: "amzi.pro"; Components: user; Flags: ignoreversion uninsneveruninstall -Source: "C:\logtalk\libpaths\libpaths.pl"; DestDir: "{code:GetLgtUserDir}\libpaths"; DestName: "libpaths_no_env_var.pl"; Components: user; Flags: ignoreversion uninsneveruninstall - -Source: "C:\logtalk\scripts\*.bat"; DestDir: "{win}"; Components: base; Flags: ignoreversion -Source: "C:\logtalk\xml\*.bat"; DestDir: "{win}"; Components: base; Flags: ignoreversion - -[INI] -Filename: "{app}\{#MyAppUrlName}"; Section: "InternetShortcut"; Key: "URL"; String: "{#MyAppURL}"; Components: base -Filename: "{app}\{#MyAppRegUrlName}"; Section: "InternetShortcut"; Key: "URL"; String: "{#MyAppRegURL}"; Components: base - -[Icons] -Name: "{group}\Bibliography"; Filename: "{app}\BIBLIOGRAPHY.bib"; Components: base -Name: "{group}\Documentation"; Filename: "{app}\manuals\index.html"; Components: base -Name: "{group}\License"; Filename: "{app}\LICENSE.txt"; Components: base -Name: "{group}\Release Notes"; Filename: "{app}\RELEASE_NOTES.txt"; Components: base -Name: "{group}\Read Me"; Filename: "{app}\README.txt"; Components: base -Name: "{group}\Customization instructions"; Filename: "{app}\CUSTOMIZE.txt"; Components: base - -Name: "{group}\Web Site"; Filename: "{#MyAppUrl}"; Components: base - -Name: "{group}\Logtalk - B-Prolog"; Filename: "{code:GetBPExePath}"; Parameters: "-g ""consult('$LOGTALKHOME/integration/logtalk_bp.pl'), $bp_top_level"""; Comment: "Runs Logtalk with B-Prolog"; WorkingDir: "{code:GetLgtUserDir}"; Components: prolog\bp; Flags: createonlyiffileexists - -Name: "{group}\Logtalk - Ciao Prolog"; Filename: "{code:GetCiaoExePath}"; Parameters: "-l ""$LOGTALKHOME/integration/logtalk_ciao.pl"""; Comment: "Runs Logtalk with Ciao Prolog"; WorkingDir: "{code:GetLgtUserDir}"; Components: prolog\ciao; Flags: createonlyiffileexists - -Name: "{group}\Logtalk - ECLiPSe"; Filename: "{code:GetEclipseExePath}"; Parameters: "-b ""%LOGTALKHOME%\integration\logtalk_eclipse.pl"""; Comment: "Runs Logtalk with ECLiPSe"; WorkingDir: "{code:GetLgtUserDir}"; Components: prolog\eclipse; Flags: createonlyiffileexists - -Name: "{group}\Logtalk - GNU Prolog"; Filename: "{code:GetGPExePath}"; Parameters: "--init-goal ""['$LOGTALKUSER/configs/gnu.config', '$LOGTALKHOME/integration/logtalk_gp.pl', '$LOGTALKUSER/libpaths/libpaths.pl']"""; Comment: "Runs Logtalk with GNU Prolog"; WorkingDir: "{code:GetLgtUserDir}"; Components: prolog\gprolog; Flags: createonlyiffileexists - -Name: "{group}\Logtalk - K-Prolog"; Filename: "{code:GetKPExePath}"; Parameters: "-h 2048k -l 1024k -g 2048k -e ""(consult('$LOGTALKHOME/integration/logtalk_plc.pl'), '$root')."""; Comment: "Runs Logtalk with K-Prolog"; WorkingDir: "{code:GetLgtUserDir}"; Components: prolog\gprolog; Flags: createonlyiffileexists - -Name: "{group}\Logtalk - SICStus Prolog 3"; Filename: "{code:GetSP3ExePath}"; Parameters: "-l ""%LOGTALKHOME%\integration\logtalk_sicstus3.pl"""; Comment: "Runs Logtalk with SSICStus Prolog 3"; WorkingDir: "{code:GetLgtUserDir}"; Components: prolog\sicstus; Flags: createonlyiffileexists - -Name: "{group}\Logtalk - SICStus Prolog 4"; Filename: "{code:GetSP4ExePath}"; Parameters: "-l ""%LOGTALKHOME%\integration\logtalk_sicstus4.pl"""; Comment: "Runs Logtalk with SICStus Prolog 4"; WorkingDir: "{code:GetLgtUserDir}"; Components: prolog\sicstus; Flags: createonlyiffileexists - -Name: "{group}\Logtalk - SWI-Prolog"; Filename: "{code:GetSWIExePath}"; Parameters: "-f ""%LOGTALKHOME%\integration\logtalk_swi.pl"""; Comment: "Runs Logtalk with SWI-Prolog"; WorkingDir: "{code:GetLgtUserDir}"; Components: prolog\swi; Flags: createonlyiffileexists - -Name: "{group}\Logtalk - XSB"; Filename: "C:\XSB\config\x86-pc-windows\bin\xsb.exe"; Parameters: "-l -e ""['%LOGTALKUSER%\\configs\\xsb.config', '%LOGTALKHOME%\\compiler\\logtalk.pl', '%LOGTALKUSER%\\libpaths\\libpaths.pl']."""; Comment: "Runs Logtalk with XSB"; WorkingDir: "{code:GetLgtUserDir}"; Components: prolog\xsb; Flags: createonlyiffileexists - -Name: "{group}\Logtalk - XSB-MT"; Filename: "C:\XSB\config\i686-pc-cygwin-mt\bin\xsb.exe"; Parameters: "--shared_predicates -l -e ""['%LOGTALKUSER%\\configs\\xsb.config', '%LOGTALKHOME%\\compiler\\logtalk.pl', '%LOGTALKUSER%\\libpaths\\libpaths.pl']."""; Comment: "Runs Logtalk with XSB-MT"; WorkingDir: "{code:GetLgtUserDir}"; Components: prolog\xsb; Flags: createonlyiffileexists - -Name: "{group}\Logtalk - YAP"; Filename: "C:\Yap\bin\yap.exe"; Parameters: "-l ""$LOGTALKHOME/integration/logtalk_yap.pl"""; Comment: "Runs Logtalk with YAP"; WorkingDir: "{code:GetLgtUserDir}"; Components: prolog\yap; Flags: createonlyiffileexists - -Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"; Components: base - -Name: "{code:GetLgtUserDir}\manuals"; Filename: "{app}\manuals"; Components: user -Name: "{code:GetLgtUserDir}\wenv"; Filename: "{app}\wenv"; Components: user - -Name: "{userdesktop}\Logtalk user files"; Filename: "{code:GetLgtUserDir}"; Components: user; Tasks: shortcut - -[Registry] -Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "LOGTALKHOME"; ValueData: "{app}"; Components: base; Flags: deletevalue uninsdeletevalue -Root: HKCU; Subkey: "Environment"; ValueType: expandsz; ValueName: "LOGTALKUSER"; ValueData: "{code:GetLgtUserDir}"; Flags: deletevalue uninsdeletevalue - -[Run] -Filename: "{app}\RELEASE_NOTES.txt"; Description: "View the release notes"; Components: base user; Flags: postinstall shellexec skipifsilent -Filename: "{app}\CUSTOMIZE.txt"; Description: "Read the customization instructions for completing your setup"; Components: base user; Flags: postinstall shellexec skipifsilent - -Filename: "{app}\{#MyAppRegUrlName}"; Flags: shellexec nowait; Tasks: registration - -[UninstallDelete] -Type: filesandordirs; Name: "{app}"; Components: base -Type: filesandordirs; Name: "{group}"; Components: base - -[Code] -var - LgtUserDirPage: TInputDirWizardPage; - WarningPage: TOutputMsgWizardPage; - Explanation, Warning: String; - -procedure InitializeWizard; -begin - Explanation := 'Select the folder in which Setup should install Logtalk user data files, then click Next.' - + Chr(13) + Chr(13) - + 'These files allows each user to independently customize Logtalk and to freely modify the provided programming examples.' - + Chr(13) + Chr(13) - + 'A copy of these files must exist in the user home folder in order to use the Logtalk-Prolog integration scripts available from the Start Menu.' - + Chr(13) + Chr(13) - + 'Addtional end-users may use this installer to make a copy of these files on their home folders after a full installation of Logtalk.'; - LgtUserDirPage := CreateInputDirPage(wpSelectDir, - 'Select folder for Logtalk user data files', 'Where should Logtalk user data files be installed?', - Explanation, - False, 'New Folder'); - LgtUserDirPage.Add(''); - LgtUserDirPage.Values[0] := ExpandConstant('{#LOGTALKUSER}'); - if not IsAdminLoggedOn then - begin - Warning := 'Full installation of Logtalk requires an administrative user.' - + Chr(13) + Chr(13) - + 'If the base Logtalk system is already installed, you may proceed in order to setup Logtalk for you as an end-user.' - + Chr(13) + Chr(13) - + 'If Logtalk is already set for you, this installer will make a backup copy of your current files (if you choose the same installation folder) and will restore all user data files to their default, pristine state.'; - WarningPage := CreateOutputMsgPage(wpWelcome, - 'Information', 'Please read the following important information before continuing.', Warning); - end -end; - -function GetLgtUserDir(Param: String): String; -begin - Result := LgtUserDirPage.Values[0] -end; - -function GetCurrentDate(Param: String): String; -begin - Result := GetDateTimeString('dddddd tt', '-', '-') -end; - -function ShouldSkipPage(PageID: Integer): Boolean; -begin - if (PageID = wpSelectDir) and not IsAdminLoggedOn then - Result := True - else if (PageID = wpSelectComponents) and not IsAdminLoggedOn then - begin - WizardForm.TypesCombo.ItemIndex := 2; - WizardForm.TypesCombo.OnChange(nil); - Result := True - end - else if (PageID = wpReady) and not IsAdminLoggedOn then - Result := True - else - Result := False; -end; - -procedure CurStepChanged(CurStep: TSetupStep); -begin - if (CurStep = ssInstall) and DirExists(LgtUserDirPage.Values[0]) and (pos('backup', WizardSelectedComponents(False)) > 0) then - RenameFile(LgtUserDirPage.Values[0], LgtUserDirPage.Values[0] + ' backup ' + GetDateTimeString('dddddd tt', '-', '-')) -end; - -function GetBPExePath(Param: String): String; -var - BPDIR: String; -begin - if RegQueryStringValue(HKLM, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment\', 'BPDIR', BPDIR) then - Result := BPDIR + '\bp.bat' - else - Result := 'lgt_exe_does_not_exist' -end; - -function GetCiaoExePath(Param: String): String; -var - CiaoDir: String; -begin - if RegQueryStringValue(HKLM, 'Software\Ciao Prolog\', 'ciao_dir', CiaoDir) then - Result := CiaoDir + '\shell\ciaosh.cpx' - else - Result := 'lgt_exe_does_not_exist' -end; - -function GetEclipseExePath(Param: String): String; -var - ECLIPSEDIR: String; -begin - if RegQueryStringValue(HKLM, 'Software\IC-Parc\Eclipse\5.11\', 'ECLIPSEDIR', ECLIPSEDIR) then - Result := ECLIPSEDIR + '\lib\i386_nt\eclipse.exe' - else if RegQueryStringValue(HKLM, 'Software\IC-Parc\Eclipse\5.10\', 'ECLIPSEDIR', ECLIPSEDIR) then - Result := ECLIPSEDIR + '\lib\i386_nt\eclipse.exe' - else - Result := 'lgt_exe_does_not_exist' -end; - -function GetGPExePath(Param: String): String; -var - RootPath: String; -begin - if RegQueryStringValue(HKCU, 'Software\GnuProlog\', 'RootPath', RootPath) then - Result := RootPath + '\bin\gprolog.exe' - else - Result := 'lgt_exe_does_not_exist' -end; - -function GetKPExePath(Param: String): String; -begin - Result := GetEnv('PLC') + '\plc.exe' -end; - -function GetSP3ExePath(Param: String): String; -var - SP_PATH: String; -begin - if RegQueryStringValue(HKLM, 'Software\SICS\SICStus3.12_win32\', 'SP_PATH', SP_PATH) then - Result := SP_PATH + '\bin\spwin.exe' - else - Result := 'lgt_exe_does_not_exist' -end; - -function GetSP4ExePath(Param: String): String; -var - SP_PATH: String; -begin - if RegQueryStringValue(HKLM, 'Software\SICS\SICStus4.0_win32\', 'SP_PATH', SP_PATH) then - Result := SP_PATH + '\bin\spwin.exe' - else - Result := 'lgt_exe_does_not_exist' -end; - -function GetSWIExePath(Param: String): String; -var - Home: String; -begin - if RegQueryStringValue(HKLM, 'Software\SWI\Prolog\', 'home', Home) then - Result := Home + '\bin\plwin.exe' - else - Result := 'lgt_exe_does_not_exist' -end; diff --git a/Logtalk/wenv/NOTES.txt b/Logtalk/wenv/NOTES.txt deleted file mode 100644 index 4dd43ca53..000000000 --- a/Logtalk/wenv/NOTES.txt +++ /dev/null @@ -1,28 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This directory contains files that provide syntax highlighting and -other text editing services for writing Logtalk source files (*.lgt) -with common text editors. By default, Logtalk syntax highlighting is -also applied to the Prolog configuration files (*.config). - -Some text editors already include support for Logtalk. If that is the -case of your favorite editor, you may want to check if the supporting -files provided in this directory are newer than the editor ones. - -Logtalk source files (including the programming examples) are usually -formatted using four-space tabs; it is recommended that you set the tab -width on your editor preferences panel. - -You may notice that support for some text editors, notably for Windows-only -editors, is rather poor. Proper syntax highlighting support for Prolog and -Logtalk requires support for regular expressions with zero-width look-ahead -features, which some editors lack. - -As Logtalk can be viewed as a superset of ISO Prolog, you may also use -the resources in this directory for editing plain Prolog source files. diff --git a/Logtalk/wenv/bbedit/NOTES.txt b/Logtalk/wenv/bbedit/NOTES.txt deleted file mode 100644 index def2dfea3..000000000 --- a/Logtalk/wenv/bbedit/NOTES.txt +++ /dev/null @@ -1,32 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This directory contains files that provide basic syntax highlighting -for editing Logtalk source files with the Bare Bones BBEdit 8.x or -TextWrangler 2.x text editors: - - http://www.barebones.com/ - -To install copy the file "logtalk.plist" either to the folders: - - ~/Library/Application Support/BBEdit/Language Modules/ - ~/Library/Application Support/TextWrangler/Language Modules/ - -or to the folders: - - /Library/Application Support/BBEdit/Language Modules/ - /Library/Application Support/TextWrangler/Language Modules/ - -(create the folder if it does not exist). - -Logtalk source files (including the programming examples) are usually -formatted using four-space tabs; you may set the tab width on the -editor preference panel. - - -THESE SYNTAX COLORING SUPPORT FILES ARE UNDER DEVELOPMENT. diff --git a/Logtalk/wenv/bbedit/logtalk.plist b/Logtalk/wenv/bbedit/logtalk.plist deleted file mode 100644 index 61ee3d971..000000000 --- a/Logtalk/wenv/bbedit/logtalk.plist +++ /dev/null @@ -1,65 +0,0 @@ - - - - - BBEditDocumentType - CodelessLanguageModule - BBLMColorsSyntax - - BBLMIsCaseSensitive - - BBLMKeywordList - - : - << - :: - ^^ - { - } - - BBLMLanguageCode - LGT2 - BBLMLanguageDisplayName - Logtalk - BBLMScansFunctions - - BBLMSuffixMap - - - BBLMLanguageSuffix - .config - - - BBLMLanguageSuffix - .lgt - - - Language Features - - Comment Pattern - % .* $ ) | - (?> /\* (?s:.*?) (?>\*/) ) - )]]> - - Function Pattern - - - String Pattern - " (?s: \\. | [^"] )*? (?> " ) ) | - (?> ' (?s: \\. | [^'] )*? (?> ' ) ) - )]]> - - Identifier and Keyword Character Class - - - - diff --git a/Logtalk/wenv/context/Logtalk.chl b/Logtalk/wenv/context/Logtalk.chl deleted file mode 100644 index 130e81544..000000000 --- a/Logtalk/wenv/context/Logtalk.chl +++ /dev/null @@ -1,57 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Logtalk highlighter -// Paulo Moura -// -// http://logtalk.org/ -// -// Last updated on: June 10, 2007 -// -////////////////////////////////////////////////////////////////////////////// - - - -Language: Logtalk - -Filter: Logtalk files (*.lgt)|*.lgt - -HelpFile: - -CaseSensitive: 1 - -LineComment: % - -BlockCommentBeg: /* -BlockCommentEnd: */ - -IdentifierBegChars: -IdentifierChars: - -NumConstBegChars: -NumConstChars: - -EscapeChar: \ - - -KeyWords1: :: ^^ { } : << - - -StringBegChar: " -StringEndChar: " -MultilineStrings: 0 - -UsePreprocessor: 0 - -CurrLineHighlighted: 0 - - -SpaceCol: clWindowText clWindow -Keyword1Col: clNavy clWindow B -IdentifierCol: clBlue clWindow -CommentCol: clGray clWindow I -NumberCol: clWindowText clWindow -StringCol: clMaroon clWindow -SymbolCol: clPurple clWindow -PreprocessorCol: clBlue clWindow -SelectionCol: clWhite clNavy -CurrentLineCol: clBlack clYellow diff --git a/Logtalk/wenv/context/NOTES.txt b/Logtalk/wenv/context/NOTES.txt deleted file mode 100644 index 1951bd7bd..000000000 --- a/Logtalk/wenv/context/NOTES.txt +++ /dev/null @@ -1,20 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This directory contains files that provides basic syntax coloring for -editing Logtalk source files with the text editor Context 0.98.3 or -later version: - - http://www.context.cx/ - -To install copy the file "Logtalk.chl" to the Highlighters folder of -your ConTEXT folder (e.g. C:\Program Files\ConTEXT\Highlighters). If -ConTEXT is running, restart it to update its list of highlighters. - - -THESE SYNTAX COLORING SUPPORT FILES ARE UNDER DEVELOPMENT. diff --git a/Logtalk/wenv/crimson/NOTES.txt b/Logtalk/wenv/crimson/NOTES.txt deleted file mode 100644 index 55181e215..000000000 --- a/Logtalk/wenv/crimson/NOTES.txt +++ /dev/null @@ -1,32 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This directory contains files that provides basic syntax coloring -for editing Logtalk source files with Crimson Editor V3.60 or later -version: - - http://www.crimsoneditor.com/ - -To install these files do the following: - -1. Copy the files extension.lgt, extension.loader, and extension.config -to the "link" folder on the Crimson installation directory. - -2. Copy the files logtalk.key and logtalk.spc to the "spec" folder on -the Crimson installation directory. - -Note: The Crimson installation directory is usually: - - C:\Program Files\Crimson Editor - -Logtalk source files (including the programming examples) are usually -formatted using four-space tabs; you may set the tab width on the -editor preference panel. - - -THESE SYNTAX COLORING SUPPORT FILES ARE UNDER DEVELOPMENT. diff --git a/Logtalk/wenv/crimson/extension.config b/Logtalk/wenv/crimson/extension.config deleted file mode 100755 index 6dfde9616..000000000 --- a/Logtalk/wenv/crimson/extension.config +++ /dev/null @@ -1,2 +0,0 @@ -LANGSPEC:logtalk.spc -KEYWORDS:logtalk.key diff --git a/Logtalk/wenv/crimson/extension.lgt b/Logtalk/wenv/crimson/extension.lgt deleted file mode 100755 index 6dfde9616..000000000 --- a/Logtalk/wenv/crimson/extension.lgt +++ /dev/null @@ -1,2 +0,0 @@ -LANGSPEC:logtalk.spc -KEYWORDS:logtalk.key diff --git a/Logtalk/wenv/crimson/extension.loader b/Logtalk/wenv/crimson/extension.loader deleted file mode 100755 index 6dfde9616..000000000 --- a/Logtalk/wenv/crimson/extension.loader +++ /dev/null @@ -1,2 +0,0 @@ -LANGSPEC:logtalk.spc -KEYWORDS:logtalk.key diff --git a/Logtalk/wenv/crimson/logtalk.key b/Logtalk/wenv/crimson/logtalk.key deleted file mode 100755 index 24896e438..000000000 --- a/Logtalk/wenv/crimson/logtalk.key +++ /dev/null @@ -1,35 +0,0 @@ -[-COMMENT-:GLOBAL] -# Logtalk keywords file -# Paulo Moura (pmoura@logtalk.org) - - -[KEYWORDS0:R1||R2] -object category protocol module -encoding export -info initialization -public protected private -dynamic discontiguous multifile -mode meta_predicate alias synchronized -end_object end_category end_protocol -uses use_module -threaded - -[KEYWORDS1:RANGE1] -implements imports extends instantiates specializes - -[KEYWORDS2:GLOBAL] -:: ^^ { } : << - -[KEYWORDS3:GLOBAL] - -[KEYWORDS4:GLOBAL] - -[KEYWORDS5:GLOBAL] - -[KEYWORDS6:GLOBAL] - -[KEYWORDS7:GLOBAL] - -[KEYWORDS8:GLOBAL] - -[KEYWORDS9:GLOBAL] diff --git a/Logtalk/wenv/crimson/logtalk.spc b/Logtalk/wenv/crimson/logtalk.spc deleted file mode 100755 index a1ef17f68..000000000 --- a/Logtalk/wenv/crimson/logtalk.spc +++ /dev/null @@ -1,19 +0,0 @@ -# Logtalk specification file (http://logtalk.org/) -# Paulo Moura (pmoura@logtalk.org) - -$CASESENSITIVE=YES -$DELIMITERS=~`!@#$%^&*()-+=|\{}[]:;"',.<>/? -$HEXADECIMALMARK=0x -$ESCAPECHAR= -$QUOTATIONMARK1=" -$QUOTATIONMARK2=' -$LINECOMMENT=% -$BLOCKCOMMENTON=/* -$BLOCKCOMMENTOFF=*/ -$RANGE1BEG=:- -$RANGE1END=( -$RANGE2BEG=:- -$RANGE2END=. -$PAIRS1=() -$PAIRS2=[] -$PAIRS3={} diff --git a/Logtalk/wenv/ctags/NOTES.txt b/Logtalk/wenv/ctags/NOTES.txt deleted file mode 100644 index d6a509c06..000000000 --- a/Logtalk/wenv/ctags/NOTES.txt +++ /dev/null @@ -1,21 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This folder contains minimal support for using Exuberant Ctags -(http://ctags.sourceforge.net/) with Logtalk. There are two files -that you will need to rename and copy to your home directory: - - ctags - Rename this file to "$HOME/.ctags" or append its contents to - the "$HOME/.ctags" file if it already exists - - ctags.tmcodebrowser - Rename this file to "$HOME/.ctags.tmcodebrowser" or append its - contents to "$HOME/.ctags.tmcodebrowser" if it already exists - in order to use the MacOS X TextMate text editor and its - TmCodeBrowser plug-in (http://www.cocoabits.com/TmCodeBrowser/) diff --git a/Logtalk/wenv/ctags/ctags b/Logtalk/wenv/ctags/ctags deleted file mode 100644 index 71c7e6c1a..000000000 --- a/Logtalk/wenv/ctags/ctags +++ /dev/null @@ -1,8 +0,0 @@ ---langdef=logtalk ---langmap=logtalk:.lgt ---regex-logtalk=/^[ \t]*:- object\(([a-z][a-zA-Z0-9_]*)/\1/Objects/ ---regex-logtalk=/^[ \t]*:- protocol\(([a-z][a-zA-Z0-9_]*)/\1/Protocols/ ---regex-logtalk=/^[ \t]*:- category\(([a-z][a-zA-Z0-9_]*)/\1/Categories/ ---regex-logtalk=/^[ \t]*:- public\(([a-z][a-zA-Z0-9_]*)/\1/Public predicates/ ---regex-logtalk=/^[ \t]*:- protected\(([a-z][a-zA-Z0-9_]*)/\1/Protected predicates/ ---regex-logtalk=/^[ \t]*:- private\(([a-z][a-zA-Z0-9_]*)/\1/Private predicates/ diff --git a/Logtalk/wenv/ctags/ctags.tmcodebrowser b/Logtalk/wenv/ctags/ctags.tmcodebrowser deleted file mode 100644 index 71c7e6c1a..000000000 --- a/Logtalk/wenv/ctags/ctags.tmcodebrowser +++ /dev/null @@ -1,8 +0,0 @@ ---langdef=logtalk ---langmap=logtalk:.lgt ---regex-logtalk=/^[ \t]*:- object\(([a-z][a-zA-Z0-9_]*)/\1/Objects/ ---regex-logtalk=/^[ \t]*:- protocol\(([a-z][a-zA-Z0-9_]*)/\1/Protocols/ ---regex-logtalk=/^[ \t]*:- category\(([a-z][a-zA-Z0-9_]*)/\1/Categories/ ---regex-logtalk=/^[ \t]*:- public\(([a-z][a-zA-Z0-9_]*)/\1/Public predicates/ ---regex-logtalk=/^[ \t]*:- protected\(([a-z][a-zA-Z0-9_]*)/\1/Protected predicates/ ---regex-logtalk=/^[ \t]*:- private\(([a-z][a-zA-Z0-9_]*)/\1/Private predicates/ diff --git a/Logtalk/wenv/e/NOTES.txt b/Logtalk/wenv/e/NOTES.txt deleted file mode 100644 index 8f7a23a42..000000000 --- a/Logtalk/wenv/e/NOTES.txt +++ /dev/null @@ -1,11 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -The "e" Windows text editor (http://www.e-texteditor.com/) supports -the TextMate 1.x text editor syntax configuration files; see the -../textmate folder. diff --git a/Logtalk/wenv/emacs/NOTES.txt b/Logtalk/wenv/emacs/NOTES.txt deleted file mode 100644 index 076d27de7..000000000 --- a/Logtalk/wenv/emacs/NOTES.txt +++ /dev/null @@ -1,18 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This directory contains a logtalk.el file that provides syntax -highlighting for editing Logtalk source files with the Emacs text -editor: - - http://www.gnu.org/software/emacs/emacs.html - -To install follow the instructions contained in the file itself. - - -THIS FONT-LOCK CONFIGURATION FILE IS UNDER DEVELOPMENT. diff --git a/Logtalk/wenv/emacs/logtalk.el b/Logtalk/wenv/emacs/logtalk.el deleted file mode 100644 index 67b7c0dfb..000000000 --- a/Logtalk/wenv/emacs/logtalk.el +++ /dev/null @@ -1,285 +0,0 @@ -;; logtalk.el -- font lock support for Logtalk (http://logtalk.org/) - -;; Copyright (C) 2003-2007 Paulo Moura - -;; Author: Paulo Moura -;; Creation date: November 15, 2003 -;; Last modification date: September 20, 2007 -;; Version: 1.0 - -;; Installation: -;; -;; First, copy this file to the appropriated directory. For FSF Emacs this will -;; probably be /usr/local/share/emacs/site-lisp. For XEmacs, the directory is -;; usully /usr/local/lib/xemacs/site-lisp. You may also copy the file to a -;; sub-directory in your home directory depending on your Emacs configuration. -;; Type "C-h v load-path" in Emacs to find the list of paths that are searched -;; for when looking for lisp files. -;; -;; Second, add the following lines in your Emacs init file, for example -;; your ~/.emacs file: -;; -;; (autoload 'logtalk-mode "logtalk" "Major mode for editing Logtalk programs." t) -;; (setq auto-mode-alist (cons '("\\.lgt\\'" . logtalk-mode) auto-mode-alist)) -;; (setq auto-mode-alist (cons '("\\.config\\'" . logtalk-mode) auto-mode-alist)) - - - -;; setup - -(defvar logtalk-mode-version "1.0" - "Logtalk mode version number") - -(defvar logtalk-mode-hook nil) - -(defvar logtalk-mode-map nil) - -(if logtalk-mode-map nil - (setq logtalk-mode-map (make-keymap))) - - - -;; syntax highlighting - -(defvar logtalk-font-lock-keywords nil) - - - -;; syntax table - -(defvar logtalk-mode-syntax-table - (let ((logtalk-mode-syntax-table (make-syntax-table))) - (modify-syntax-entry ?_ "w" logtalk-mode-syntax-table) - (modify-syntax-entry ?_ "_" logtalk-mode-syntax-table) - (modify-syntax-entry ?/ ". 14b" logtalk-mode-syntax-table) - (modify-syntax-entry ?* ". 23b" logtalk-mode-syntax-table) - (modify-syntax-entry ?% "<" logtalk-mode-syntax-table) - (modify-syntax-entry ?\n ">" logtalk-mode-syntax-table) - (modify-syntax-entry ?\' "w" logtalk-mode-syntax-table) - logtalk-mode-syntax-table) - "Syntax table for logtalk-mode") - - - -;; make logtalk font-lock-faces - -(make-face 'logtalk-default-face) -(make-face 'logtalk-directive-face) -(make-face 'logtalk-built-in-predicate-face) -(make-face 'logtalk-built-in-method-face) -(make-face 'logtalk-message-operator-face) -(make-face 'logtalk-variable-face) -(make-face 'logtalk-number-face) -(make-face 'logtalk-comment-face) -(make-face 'logtalk-string-face) - -;; set logtalk font-lock-faces - -(require 'font-lock) - -(copy-face 'default 'logtalk-default-face) -(copy-face 'font-lock-keyword-face 'logtalk-directive-face) -(copy-face 'font-lock-builtin-face 'logtalk-built-in-predicate-face) -(copy-face 'font-lock-builtin-face 'logtalk-built-in-method-face) -(copy-face 'font-lock-function-name-face 'logtalk-message-operator-face) -(copy-face 'font-lock-variable-name-face 'logtalk-variable-face) -(copy-face 'font-lock-constant-face 'logtalk-number-face) -(copy-face 'font-lock-comment-face 'logtalk-comment-face) -(copy-face 'font-lock-string-face 'logtalk-string-face) - - - -(setq logtalk-font-lock-strings - '( - ("\\(\"\\([^\n\"]\\|\\\\\"\\)*\"\\)" 1 'logtalk-string-face) - ("\\(^\\|[^0-9]\\)\\('\\([^\n']\\|\\\\'\\)*'\\)" 2 'logtalk-string-face) - )) - - -(setq logtalk-font-lock-directives - '( - ("\\(:- \\)\\(\\(end_\\(?:category\\|object\\|protocol\\)\\)\\)\\([\.]\\)" 2 'logtalk-directive-face) - ("\\(:- \\)\\(category\\|object\\|protocol\\|module\\)\\([(]\\)" 2 'logtalk-directive-face) - ("\\(:- \\)\\(p\\(?:r\\(?:ivate\\|otected\\)\\|ublic\\)\\)\\([(]\\)" 2 'logtalk-directive-face) - ("\\(:- \\)\\(alias\\|calls\\|d\\(?:iscontiguous\\|ynamic\\)\\|e\\(?:ncoding\\|xport\\)\\|in\\(?:fo\\|itialization\\)\\|m\\(?:\\(?:eta_predicat\\|od\\)e\\)\\|op\\|use\\(?:s\\|_module\\)\\|synchronized\\)\\([(]\\)" 2 'logtalk-directive-face) - ("\\(:- \\)\\(dynamic\\|synchronized\\|threaded\\)\\([\.]\\)" 2 'logtalk-directive-face) - ("\\(\\(?:extend\\|i\\(?:mp\\(?:\\(?:lemen\\|or\\)t\\)\\|nstantiate\\)\\|specialize\\)s\\)\\([(]\\)" 1 'logtalk-directive-face) - )) - - -(setq logtalk-font-lock-built-in-methods - '( - ("\\(parameter\\|se\\(?:lf\\|nder\\)\\|this\\)\\([(]\\)" 1 'logtalk-built-in-method-face) - ("\\(current_predicate\\|predicate_property\\)\\([(]\\)" 1 'logtalk-built-in-method-face) - ("\\(a\\(?:bolish\\|ssert[az]\\)\\|clause\\|retract\\(?:all\\)?\\)\\([(]\\)" 1 'logtalk-built-in-method-face) - ("\\(bagof\\|f\\(?:\\(?:ind\\|or\\)all\\)\\|setof\\)\\([(]\\)" 1 'logtalk-built-in-method-face) - ("\\(after\\|before\\)\\([(]\\)" 1 'logtalk-built-in-method-face) - ("\\(phrase\\|expand_term\\|term_expansion\\)\\([(]\\)" 1 'logtalk-built-in-method-face) - )) - - -(setq logtalk-font-lock-built-in-predicates - '( - ("\\(c\\(?:urrent\\|reate\\)_\\(?:category\\|object\\|protocol\\)\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ("\\(abolish_\\(?:category\\|object\\|protocol\\)\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ("\\(\\(?:category\\|object\\|protocol\\)_property\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ("\\(extends_\\(?:object\\|protocol\\)\\|i\\(?:mp\\(?:lements_protocol\\|orts_category\\)\\|nstantiates_class\\)\\|specializes_class\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ("\\(\\(?:abolish\\|define\\)_events\\|current_event\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ("\\(\\(?:curren\\|se\\)t_logtalk_flag\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ("\\(logtalk_\\(?:compile\\|load\\|version\\|library_path\\)\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ("\\(forall\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ("\\(retractall\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ;; - ;; control constructs: - ;; - ("\\(ca\\(?:ll\\|tch\\)\\|throw\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ("\\(fail\\|true\\|!\\|->\\|;\\)" 0 'logtalk-built-in-predicate-face) - ;; - ;; multi-threading: - ;; - ("\\(threaded\\(_\\(?:call\\|once\\|ignore\\|exit\\|peek\\|wait\\|notify\\)\\)?\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ;; - ;; logic and control: - ;; - ("\\(once\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ("\\\\\\+\\|repeat" 0 'logtalk-built-in-predicate-face) - ;; - ;; term testing: - ;; - ("\\(atom\\(?:ic\\)?\\|compound\\|float\\|\\(?:intege\\|n\\(?:onva\\|umbe\\)\\|va\\)r\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ;; - ;; term comparison: - ;; - ("==\\|@\\(?:=<\\|>=\\|[<>]\\)\\|\\\\==" 0 'logtalk-built-in-predicate-face) - ;; - ;; term creation and decomposition: - ;; - ("\\(arg\\|copy_term\\|functor\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ("=\\.\\." 0 'logtalk-built-in-predicate-face) - ;; - ;; arithemtic evaluation: - ;; - ("\\<\\is\\>" 0 'logtalk-built-in-predicate-face) - ;; - ;; arithemtic comparison: - ("=:=\\|@\\(?:=<\\|>=\\|[<>]\\)\\|\\\\==" 0 'logtalk-built-in-predicate-face) - ;; - ;; term unification: - ;; - ("\\\\?=" 0 'logtalk-built-in-predicate-face) - ;; - ;; dcgs: - ;; - ("-->" 0 'logtalk-built-in-predicate-face) - ;; - ;; evaluable functors: - ;; - ("\\(abs\\|ceiling\\|flo\\(?:at\\(?:_\\(?:\\(?:fractional\\|integer\\)_part\\)\\)?\\|or\\)\\|mod\\|r\\(?:em\\|ound\\)\\|sign\\|truncate\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ("//\\|[*/]" 0 'logtalk-built-in-predicate-face) - ("\\([^eE]\\)\\([+]\\)" 2 'logtalk-built-in-predicate-face) - ("\\([^:eE]\\)\\([-]\\)" 2 'logtalk-built-in-predicate-face) - ("\\<\\(rem\\|mod\\)\\>" 0 'logtalk-built-in-predicate-face) - ;; - ;; other arithemtic functors: - ;; - ("\\(atan\\|cos\\|exp\\|log\\|s\\(?:in\\|qrt\\)\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ("\\*\\*" 1 'logtalk-built-in-predicate-face) - ;; - ;; stream selection and control: - ;; - ("\\(at_end_of_stream\\|c\\(?:lose\\|urrent_\\(?:\\(?:in\\|out\\)put\\)\\)\\|flush_output\\|open\\|s\\(?:et_\\(?:input\\|output\\|stream_position\\)\\|tream_property\\)\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ("\\<\\(at_end_of_stream\\|flush_output\\)\\>" 0 'logtalk-built-in-predicate-face) - ;; - ;; character input/output: - ;; - ("\\(get_c\\(?:har\\|ode\\)\\|nl\\|p\\(?:eek_c\\(?:har\\|ode\\)\\|ut_c\\(?:har\\|ode\\)\\)\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ("\\" 0 'logtalk-built-in-predicate-face) - ;; - ;; byte input/output: - ;; - ("\\(\\(?:get\\|p\\(?:eek\\|ut\\)\\)_byte\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ;; - ;; term input/output: - ;; - ("\\(c\\(?:har_conversion\\|urrent_\\(?:char_conversion\\|op\\)\\)\\|op\\|read\\(?:_term\\)?\\|write\\(?:_\\(?:canonical\\|term\\)\\|q\\)?\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ;; - ;; implementation defined hooks functions: - ;; - ("\\(\\(?:curren\\|se\\)t_prolog_flag\\|halt\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ("\\" 0 'logtalk-built-in-predicate-face) - ;; - ;; atomic term processing: - ;; - ("\\(atom_\\(?:c\\(?:hars\\|o\\(?:des\\|ncat\\)\\)\\|length\\)\\|char_code\\|number_c\\(?:\\(?:har\\|ode\\)s\\)\\|sub_atom\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face) - ;; - ;; bitwise functors: - ;; - ("/\\\\\\|<<\\|>>\\|\\\\/" 0 'logtalk-built-in-predicate-face) - ("\\\\" 0 'logtalk-built-in-predicate-face) - )) - - -(setq logtalk-font-lock-operators - '( - ;; - ;; clause operator: - ;; - (":-" 0 'logtalk-default-face) - ;; - ;; message sending operators: - ;; - ("::\\|\\^\\^\\|[{}]" 0 'logtalk-message-operator-face) - ;; - ;; category predicate direct call: - ;; - (":" 0 'logtalk-message-operator-face) - ;; - ;; mode operators: - ;; - ("[@?]" 0 'logtalk-built-in-predicate-face) - )) - - -(setq logtalk-font-lock-numbers - '( - ("\\<\\(0x[a-fA-F0-9]+\\)\\>" 1 'logtalk-number-face) - ("\\<\\(0o[0-7]+\\)\\>" 1 'logtalk-number-face) - ("\\<\\(0b[0-1]+\\)\\>" 1 'logtalk-number-face) - ("\\<\\(0['][a-zA-Z0-9]\\)\\>" 1 'logtalk-number-face) - ("\\<\\([0-9]+\\([.][0-9]+\\)?\\([eE][+-][0-9]+\\)?\\)\\>" 1 'logtalk-number-face) - )) - - -(setq logtalk-font-lock-variables - '( - ("\\<\\([_A-Z][a-zA-Z0-9_]*\\)\\>" 1 'logtalk-variable-face) - )) - - -(setq logtalk-font-lock-keywords - (append - logtalk-font-lock-strings - logtalk-font-lock-directives - logtalk-font-lock-built-in-methods - logtalk-font-lock-built-in-predicates - logtalk-font-lock-operators - logtalk-font-lock-variables - logtalk-font-lock-numbers - )) - - -;; entry function - -(defun logtalk-mode () - "Major mode for editing Logtalk files" - (interactive) - (kill-all-local-variables) - (setq tab-width 4) - (set-syntax-table logtalk-mode-syntax-table) - (set (make-local-variable 'font-lock-defaults) '(logtalk-font-lock-keywords)) - (turn-on-font-lock) - (setq major-mode 'logtalk-mode) - (setq mode-name "Logtalk") - (run-hooks 'logtalk-mode-hook)) - -(provide 'logtalk-mode) diff --git a/Logtalk/wenv/gtksourceview2/NOTES.txt b/Logtalk/wenv/gtksourceview2/NOTES.txt deleted file mode 100644 index f5ecc6454..000000000 --- a/Logtalk/wenv/gtksourceview2/NOTES.txt +++ /dev/null @@ -1,26 +0,0 @@ -================================================================ -Logtalk - Open source object-oriented logic programming language -Release 2.30.7 - -Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================ - - -This directory contains files that provide syntax highlighting for -GtkSourceView 2.x, which is a text widget used in text editors and -IDEs such as recent versions of Gnome's Gedit and MonoDevelop: - - http://gtksourceview.sourceforge.net/ - -To install, copy the file "logtalk.lang" to the following system-wide -directory: - - ${prefix}/share/gtksourceview-2.0/language-specs/ - -The ${prefix} can be e.g. "/usr", "/usr/local", or "/opt", depending -on your system configuration. - -Alternatively, you can copy the "logtalk.lang" file to the following -location on your home directory: - - ~./gnome2/gtksourceview-2.0/language-specs/ diff --git a/Logtalk/wenv/gtksourceview2/logtalk.lang b/Logtalk/wenv/gtksourceview2/logtalk.lang deleted file mode 100644 index 1c0a352ea..000000000 --- a/Logtalk/wenv/gtksourceview2/logtalk.lang +++ /dev/null @@ -1,335 +0,0 @@ - - - - - - text/x-logtalk - *.lgt - % - /* - */ - - - -