Logtalk 2.24.0 files.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1282 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
pmoura 2005-04-22 23:57:45 +00:00
parent 08efcbeb64
commit c2e03a81b9
195 changed files with 4005 additions and 1219 deletions

View File

@ -1,13 +1,13 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================
This file contains detailed instruction for installing and configuring
Logtalk. You should also consult the "misc/NOTES" file for a description
Logtalk. You should also consult the "scripts/NOTES" file 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.
@ -39,29 +39,29 @@ 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 "misc" sub-directory contains shell scripts for easy installation of
The "scripts" sub-directory contains shell scripts for easy installation of
Logtalk on Windows, Unix, and Unix-like operating systems (for details,
see the "misc/NOTES" file). After running the appropriated script for your
see the "scripts/NOTES" file). After running the appropriated script for your
operating-system, the second step will be to run the Prolog integration
scripts that you find on the "misc" sub-directory, assuming that your
scripts that you find on the "scripts" sub-directory, assuming that your
favorite Prolog compilers are supported (if that is not the case, don't
worry: just follow the steps described in the "QUICK_START" file). The third
step is for each user to make a local copy of the Logtalk user-modifiable
files to its home directory. This allows each user to easily customize
Logtalk to its needs. These copies can be easily made by instructing end-users
to simply run the shell command "cplgtdirs" (the corresponding scripts are
described in the "misc/NOTES" file).
described in the "scripts/NOTES" file).
The "misc/lgt_install.*" installation scripts make all files read-only in
The "scripts/lgt_install.*" installation scripts make all files read-only in
order to avoid user tempering. This is a convenient setup for computer labs,
given that making directories world-writable is a security risk. Of course,
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 Prolog compilers for which an integration script
is provided on the "misc" directory, this setup as the advantage of allowing
each end-user to independently customize default compilation options and
library paths.
is provided on the "scripts" directory, this setup as the advantage of
allowing each end-user to independently customize default compilation options
and library paths.
2. LOGTALK CONFIGURATION
@ -85,13 +85,13 @@ 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:$LOGTALKUSER/xml:$LOGTALKHOME/misc
setenv PATH $PATH:$LOGTALKUSER/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:$LOGTALKUSER/xml:$LOGTALKHOME/misc
PATH=$PATH:$LOGTALKUSER/xml:$LOGTALKHOME/scripts
export PATH LOGTALKHOME LOGTALKUSER
When using the provided shell script for installing Logtalk, a symbolic link
@ -109,11 +109,11 @@ file (you will need to reboot after editing the file):
SET LOGTALKUSER=%HOMEPATH%\logtalk
In Windows 2000/XP, environment variables are defined using the System
properties control panel (if you are a system administrator, you should use
the JScript install script provided in the "misc" sub-directory; this script
sets the LOGTALKHOME environment variable for all users and also sets the
LOGTALKUSER environment variable for the administrator user running the
script).
properties control panel (if you are a system administrator, you should
use the JScript install script provided in the "scripts" sub-directory;
this script sets the LOGTALKHOME environment variable for all users and
also sets the LOGTALKUSER environment variable for the administrator user
running the script).
2.2 Setting library paths
@ -121,13 +121,13 @@ script).
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. Assuming that you have used the "misc/cplgtdirs.*" shell scripts
for making a copy of the user-modifiable Logtalk files, you will find in the
"$LOGTALKUSER/libpaths" directory 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 your Logtalk installation
and your Prolog compiler and operating-system requirements. For more details,
see the file "$LOGTALKUSER/libpaths/NOTES".
library paths. Assuming that you have used the "scripts/cplgtdirs.*" shell
scripts for making a copy of the user-modifiable Logtalk files, you will find
in the "$LOGTALKUSER/libpaths" directory 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 your Logtalk
installation and your Prolog compiler and operating-system requirements. For
more details, see the file "$LOGTALKUSER/libpaths/NOTES".
2.3 Customizing Prolog configuration files
@ -156,12 +156,12 @@ scripts and transformations to generate other formats. For more details, see
the file "$LOGTALKUSER/xml/NOTES".
CREATING NEW PROLOG TOP-LEVELS FOR AUTOMATIC LOADING OF LOGTALK
3. 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. This initialization file may contain
directives for loading other files, such as the Logtalk configuration file
and the Logtalk compiler. The "misc" sub-directory contains several scripts
and the Logtalk compiler. The "scripts" sub-directory contains several scripts
for automating the creation of these initialization files for some Prolog
compilers. In addition, be sure to read the "configs/NOTES" file notes on
the Prolog compilers that you intend to use.

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================
@ -25,7 +25,8 @@ CONTENTS
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
(sources, documentation and examples) unless otherwise explicitly stated.
(including sources, documentation, and examples) unless otherwise explicitly
stated.
2. HOME OF LOGTALK PACKAGE
@ -100,8 +101,8 @@ The reference and user manuals and the tutorial are provided in XHTML format
and are contained in the manuals directory.
PDF versions of all documentation are also available as a separated download
from the Logtalk web site. The PDF files include page numbers, index and a
table of contents and are available for printing in both A4 and US Letter
from the Logtalk web site. The PDF files include page numbers, an index, and
a table of contents and are available for printing in both A4 and US Letter
paper formats.
The file RELEASE_NOTES contains descriptions of the changes made in Logtalk

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.9.1
Release 2.24.0
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
=================================================================
@ -16,6 +16,10 @@ 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.

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================
@ -10,6 +10,87 @@ RELEASE NOTES
=============
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

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -0,0 +1,20 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.24.0
Copyright (c) 1998-2005 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 a (X)HTML or PDF documentation. Your
feedback is appreciated.

664
Logtalk/contributions/iso8601.lgt Executable file
View File

@ -0,0 +1,664 @@
/******************************************************************************
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.

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================
@ -71,6 +71,10 @@ diamonds
dynpred
example of using some of the built-in database handling methods
encodings
very simple example of using the new, experimental enconding/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

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================
@ -8,26 +8,20 @@ Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
To load this example and for sample queries, please see the SCRIPT file.
If your Prolog compiler does not support a module system, then edit the
loader.lgt file and comment out the directive that loads the module code.
In case your Prolog compiler supports a module system, you may need to
edit the code on the module.pl file and make any necessary compatibility
changes.
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 folder provides simple benchmarks for comparing Logtalk message
sending performance with direct calls to Prolog predicates and with
calls to module predicates. These benchmarks may also be used for
comparing Logtalk message sending performance across Prolog compilers.
This example is made of five source files:
This example is made of four source files:
benchmark.pl
benchmark.lgt
contains the benchmark predicates
plain.pl
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
module.pl (not loaded by default; see below)
contains the same definition of a list length predicate
encapsulated in a module
object.lgt
@ -37,8 +31,30 @@ This example is made of four source files:
contains predicates for testing the performance of the built-in
database methods assertz/1 and retract/1
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 just to
make it possible to load all the example code using a single call to the
logtalk_load/1 predicate.
The Prolog files above are loaded (from the loader.lgt file) by using
ensure_loaded/1 directives. If this directive is not supported on your
Prolog compiler, replace them by calls to the built-in predicate used
by your compiler to load Prolog code.
By default, the benchmark tests on the SCRIPT file use a list of 30 elements
as an argument to the list length predicates. 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.lgt file used to load the example code does not load
the module.pl file. Edit this file 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, specially when using imported predicates as opposed to
using explicit module qualification.

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================
@ -12,66 +12,67 @@ Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
...
% run the default set of benchmark tests:
| ?- benchmarks.
...
% or run specific benchmark tests individually as exemplified next...
% call the predicate my_length/0 defined in the Prolog database:
| ?- benchmark(my_length([1, 2, 3, 4, 5, 6, 7, 8, 9, 0], _)).
| ?- generate_list(30, List), benchmark(my_length(List, _)).
Number of repetitions: 100000
Loop time: 0.03 seconds
Goal time: 0.39 seconds
Average time per call: 3.6e-06 seconds
Number of calls per second: 277777.777777778
List = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29] ?
yes
% call the predicate object::length/2 from the top-level:
| ?- generate_list(30, List), benchmark(object::length(List, _)).
Number of repetitions: 100000
Loop time: 0.04 seconds
Goal time: 0.31 seconds
Average time per call: 2.7e-06 seconds
Number of calls per second: 370370.370370371
Goal time: 0.79 seconds
Average time per call: 7.5e-06 seconds
Number of calls per second: 133333.333333333
List = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29] ?
yes
% call the predicate module:mod_length/2 from top-level:
% compiled call of the predicate object::length/2 (simulates message sending
% from a compiled object to another object; thus with no top-level overhead):
| ?- benchmark(module:mod_length([1, 2, 3, 4, 5, 6, 7, 8, 9, 0], _)).
| ?- generate_list(30, List), benchmark('$lgt_send_to_object_nv'(object, length(List, _), user)).
Number of repetitions: 100000
Loop time: 0.04 seconds
Goal time: 0.31 seconds
Average time per call: 2.7e-06 seconds
Number of calls per second: 370370.37037037
Loop time: 0.0299999999999998 seconds
Goal time: 0.5 seconds
Average time per call: 4.70000000000001e-06 seconds
Number of calls per second: 212765.957446808
List = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29] ?
yes
% call the predicate list::length/2 from top-level:
| ?- benchmark(object::length([1, 2, 3, 4, 5, 6, 7, 8, 9, 0], _)).
Number of repetitions: 100000
Loop time: 0.0600000000000005 seconds
Goal time: 0.94 seconds
Average time per call: 8.79999999999999e-06 seconds
Number of calls per second: 113636.363636364
yes
% compiled call of the predicate list::length/2 (simulates message sending
% from a compiled object to another object; thus no top-level overhead):
| ?- benchmark('$lgt_send_to_object_nv'(object, length([1, 2, 3, 4, 5, 6, 7, 8, 9, 0], _), user)).
Number of repetitions: 100000
Loop time: 0.0499999999999972 seconds
Goal time: 0.510000000000002 seconds
Average time per call: 4.60000000000004e-06 seconds
Number of calls per second: 217391.304347824
yes
% compiled call of the predicate list::length/2 (simulates message sending
% compiled call of the predicate object::length/2 (simulates message sending
% from a compiled object to another object with event-driven programming
% support switched off and with no top-level overhead):
| ?- benchmark('$lgt_send_to_object_ne_nv'(object, length([1, 2, 3, 4, 5, 6, 7, 8, 9, 0], _), user)).
| ?- generate_list(30, List), benchmark('$lgt_send_to_object_ne_nv'(object, length(List, _), user)).
Number of repetitions: 100000
Loop time: 0.0500000000000007 seconds
Goal time: 0.43 seconds
Average time per call: 3.79999999999999e-06 seconds
Number of calls per second: 263157.894736843
Loop time: 0.0300000000000002 seconds
Goal time: 0.46 seconds
Average time per call: 4.3e-06 seconds
Number of calls per second: 232558.139534884
List = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29] ?
yes
@ -80,48 +81,56 @@ yes
| ?- benchmark((create_object(xpto, [], [], []), abolish_object(xpto))).
Number of repetitions: 100000
Loop time: 0.039999999999992 seconds
Goal time: 102.77 seconds
Average time per call: 0.0010273 seconds
Number of calls per second: 973.425484279178
Loop time: 0.0300000000000011 seconds
Goal time: 51.59 seconds
Average time per call: 0.0005156 seconds
Number of calls per second: 1939.48797517455
yes
% test assertz/1 and retract/1 performance in plain Prolog:
| ?- benchmark(db_test_plain).
Number of repetitions: 100000
Loop time: 0.0599999999999454 seconds
Goal time: 81.25 seconds
Average time per call: 0.000811900000000001 seconds
Number of calls per second: 1231.67877817465
Loop time: 0.0299999999999727 seconds
Goal time: 51.07 seconds
Average time per call: 0.0005104 seconds
Number of calls per second: 1959.24764890282
yes
% test assertz/1 and retract/1 performance in this:
% test assertz/1 and retract/1 performance on "this" database:
| ?- benchmark('$lgt_send_to_object_ne_nv'(database, db_test_this, user)).
Number of repetitions: 100000
Loop time: 0.0699999999999363 seconds
Goal time: 92.03 seconds
Average time per call: 0.0009196 seconds
Number of calls per second: 1087.42931709439
Loop time: 0.0299999999999727 seconds
Goal time: 63.37 seconds
Average time per call: 0.0006334 seconds
Number of calls per second: 1578.78118092832
yes
% test assertz/1 and retract/1 performance in self:
% test assertz/1 and retract/1 performance on "self" database:
| ?- benchmark('$lgt_send_to_object_ne_nv'(database, db_test_self, user)).
Number of repetitions: 100000
Loop time: 0.0599999999999454 seconds
Goal time: 111.92 seconds
Average time per call: 0.0011186 seconds
Number of calls per second: 893.974611121043
Loop time: 0.0299999999999727 seconds
Goal time: 71.3499999999999 seconds
Average time per call: 0.000713199999999999 seconds
Number of calls per second: 1402.13123948402
yes
% test assertz/1 and retract/1 performance using ::/2:
% test assertz/1 and retract/1 performance on another object database (using ::/2):
| ?- benchmark('$lgt_send_to_object_ne_nv'(database, db_test_obj, user)).
Number of repetitions: 100000
Loop time: 0.0600000000001728 seconds
Goal time: 114.37 seconds
Average time per call: 0.0011431 seconds
Number of calls per second: 874.814102003327
Loop time: 0.0299999999999727 seconds
Goal time: 68.97 seconds
Average time per call: 0.0006894 seconds
Number of calls per second: 1450.53669857847
yes

View File

@ -0,0 +1,122 @@
% 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)).

View File

@ -1,45 +0,0 @@
% benchmark a goal using a default number of repetitions and printing some
% useful statistics
benchmark(Goal) :-
N = 100000,
write('Number of repetitions: '), write(N), nl,
'$lgt_cpu_time'(Seconds1), % defined in the config files
benchmark(N, true),
'$lgt_cpu_time'(Seconds2),
Looptime is Seconds2 - Seconds1,
write('Loop time: '), write(Looptime), write(' seconds'), nl,
'$lgt_cpu_time'(Seconds3),
benchmark(N, Goal),
'$lgt_cpu_time'(Seconds4),
Goaltime is Seconds4 - Seconds3,
write('Goal time: '), write(Goaltime), write(' seconds'), nl,
Average is (Goaltime - Looptime)/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.
% 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
benchmark(N, Goal) :-
repeat(N), % another option would be to use a between/3 built-in predicate
call(Goal),
fail.
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).

View File

@ -1,12 +1,10 @@
% if your Prolog compiler does not support the ensure_loaded/1 directive
% then simply consult the files
% uncomment the next line if your Prolog compiler supports modules
%:- ensure_loaded(module).
:- ensure_loaded(benchmark).
:- ensure_loaded(plain).
% comment the next line if your Prolog compiler does not support modules
:- ensure_loaded(module).
:- initialization(logtalk_load([object, database])).
:- initialization(
logtalk_load([
benchmark,
plain,
object,
database])).

View File

@ -10,7 +10,7 @@
;
length(List, 0, Length).
make_list(0, []):-
make_list(0, []) :-
!.
make_list(N, [_| Tail]):-
M is N-1,

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================
@ -29,7 +29,7 @@ Value = descendant
yes
% if we retract the local definition, again the inherited definition form root
% if we retract the local definition, again the definition inherited from root
% will be used:
| ?- descendant::(retractall(p(_)), p(Value)).

View File

@ -0,0 +1,20 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.24.0
Copyright (c) 1998-2005 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. When browsing its code,
be sure to use a text editor that supports this encoding. In addition,
you may need to configure your text editor to open the source file using
this encoding. If you are using the SWI-Prolog GUI application on Windows,
be sure to select a font which supports Unicode characters.

View File

@ -0,0 +1,46 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.24.0
Copyright (c) 1998-2005 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

View File

@ -0,0 +1,29 @@
:- encoding(utf8).
:- 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, 'Hello wereld!').
hello_world(pt, 'Olá mundo!').
hello_world(ru, 'Здравствулте! мир!').
hello_world(zh, '你好世界!').
:- end_object.

View File

@ -0,0 +1,4 @@
:- initialization(
logtalk_load([
babel])).

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -6,9 +6,9 @@
:- info([
version is 1.0,
version is 1.1,
author is 'Paulo Moura',
date is 2000/7/24,
date is 2005/3/12,
comment is 'Default metaclass for all classes.']).
@ -83,7 +83,7 @@
atom_codes(Atom2, Codes2),
atom_concat(Functor, Atom2, Identifier),
atom_concat(Identifier, Atom, Prefix),
\+ current_predicate(Prefix/_),
\+ {current_predicate(Prefix/_)},
asserta(instance_counter_(Next)),
!.
@ -93,7 +93,7 @@
number_codes(Arity, Codes),
atom_codes(Atom, Codes),
atom_concat(Functor, Atom, Prefix),
\+ current_predicate(Prefix/_).
\+ {current_predicate(Prefix/_)}.
next_integer(N, N1) :-

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================
@ -23,12 +23,12 @@ As defined, the provided "libpaths.pl" file is already compatible with some
of the most popular Prolog compilers, running on both Windows, Unix, and
Unix-like operating-systems.
The Prolog integration scripts found on the "misc" directory generate scripts
and shortcuts that automatically load the copy of the "libpaths.pl" file from
the Logtalk end-user directory created by the "misc/cplgtdirs.*" scripts. See
the "INSTALL" and the "misc/NOTES" files for more details. Note that a few
Prolog compilers do not support the <library>(<entity>) notation. See the
"configs/NOTES" file for details.
The Prolog integration scripts found on the "scripts" directory generate
scripts and shortcuts that automatically load the copy of the "libpaths.pl"
file from the Logtalk end-user directory created by the "scripts/cplgtdirs.*"
scripts. See the "INSTALL" and the "scripts/NOTES" files for more details.
Note that a few Prolog compilers do not support the <library>(<entity>)
notation. See the "configs/NOTES" 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.
@ -53,4 +53,4 @@ Some Prolog compilers which imply editing the provided "libpaths.pl" file:
* JIProlog (does not support expansion of environment variables on paths)
* XSB (does not support expansion of environment variables on paths)
Feedback on other Prolog compilers are most appreciated.
Feedback on other Prolog compilers is most appreciated.

View File

@ -2,7 +2,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Logtalk - Object oriented extension to Prolog
% Release 2.23.1
% Release 2.24.0
%
% Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
%
@ -19,6 +19,7 @@
assertz(logtalk_library_path(dcgs, '$LOGTALKUSER/examples/dcgs/')),
assertz(logtalk_library_path(diamonds, '$LOGTALKUSER/examples/diamonds/')),
assertz(logtalk_library_path(dynpred, '$LOGTALKUSER/examples/dynpred/')),
assertz(logtalk_library_path(encodings, '$LOGTALKUSER/examples/encodings/')),
assertz(logtalk_library_path(engines, '$LOGTALKUSER/examples/engines/')),
assertz(logtalk_library_path(errors, '$LOGTALKUSER/examples/errors/')),
assertz(logtalk_library_path(hello_world, '$LOGTALKUSER/examples/hello_world/')),
@ -48,4 +49,5 @@
assertz(logtalk_library_path(shapes_ph, '$LOGTALKUSER/examples/shapes/ph/')),
assertz(logtalk_library_path(sicstus, '$LOGTALKUSER/examples/sicstus/')),
assertz(logtalk_library_path(symdiff, '$LOGTALKUSER/examples/symdiff/')),
assertz(logtalk_library_path(viewpoints, '$LOGTALKUSER/examples/viewpoints/')))).
assertz(logtalk_library_path(viewpoints, '$LOGTALKUSER/examples/viewpoints/')),
assertz(logtalk_library_path(contributions, '$LOGTALKUSER/contributions/')))).

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.23.1
Release 2.24.0
Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
=================================================================

Some files were not shown because too many files have changed in this diff Show More