Manual: Highlights of Release 3
Quintus Prolog Manual
A-2: Highlights of Release 3
This chapter summarizes the new functionality in Release 3.
A-2-1: Embeddability
Embeddability means the ability to embed a Prolog sub-program in a program written in some other language or languages. It is described in Chapter I-2. The specific features of this release which
contribute towards embeddability are:
- Callable Prolog: In earlier releases, Prolog could call routines written in other languages but the reverse was not possible. Now each language can call the other, allowing much greater freedom
in the way that multi-language programs can be organized. (Chapter I-4)
- Terms in C: Compound terms can be passed to and from C. Routines are provided for testing, unifying, comparing and constructing terms in C. (See section I-3-8)
- Access to C data structures: Arithmetic evaluation has been extended so that elements of C data structures can be accessed. Also, there is a new built-in predicate assign/2 which allows
assignment into C data structures. (Chapter L)
- Open OS Interface: The main interfaces between the Prolog system and the operating system are now open. That is, the I/O and memory management interfaces are a set of documented functions which
can be replaced by user-defined functions. Source code is supplied for the default versions of these functions. (See Chapter I-2)
- Discontiguous Memory Management: As in previous releases, the system requests memory from the operating system only as it needs it, and it frees it up again when possible. (This contrasts with
many other Prolog implementations in which all needed memory must be pre-allocated.) An important difference with this release is that the allocated memory need not be contiguous. This allows
Prolog to better co-exist with other components that share its process' address space.
- User-defined main(): There is no longer any necessity to use the main() routine supplied by Quintus. An application may call individual Prolog predicates and may never need to start an
interactive Prolog session (See Chapter I-2).
- Signal Handling: Prolog used to trap all signals and then call any signal handler that had been specified by a user. Release 3 does not intercept signals that are being handled by the user's
code.
A-2-2: QOF Loading and Saving
Since Release 2.5, the Runtime Generator compiler qpc has been made available as part of the Development System. qpc compiles Prolog files into QOF (Quintus Object Format) files. QOF files can be
linked together to make an executable file which is an extended version of the development system. If you have a Runtime Generator license, you have the alternative of linking your QOF files into a
runtime system which omits development features (the compiler and debugger) and which can be conveniently deployed to different machines since it requires no authorization code in order to be run.
Release 3 introduces the ability to load QOF files directly into a running Prolog system. Loading a QOF file is up to 100 times faster than compiling it from source. File loading has been adapted
to take advantage fo this new functionality. For instance, the form
| ?- [file].
now loads file.qof if it exists and is more recent than file.pl; otherwise it compiles file.pl.
The saved-state produced by save_program/1 is now a QOF file. This means that it is now portable between different hardware and operating systems as well as between all releases of Quintus Prolog.
It can still be executed as if it were an executable file, or it can be loaded into a running Prolog system. Another alternative is to call the QOF-linker qld on it to convert it to an executable
file. It is also possible to save individual predicates or modules into a QOF file.
Chapter G-4 and Chapter G-5 describe QOF loading and QOF saving respectively. See section H-1-1-5 for how to link QOF files to make an executable file.
A-2-3: QUI: An X-based Development Environment
The Quintus User Interface (QUI) is a new development environment based on the X-Windows system. QUI makes use of windows, buttons and menus to increase programmer productivity, and it includes an
internal editor, access to GNU Emacs and access to the on-line manual. See Part C.
A-2-4: Source-linked Debugger
The QUI also includes a source-linked debugger, allowing you to single-step through your source code. The debugger works by modification of compiled code, so there is no longer any need to
distinguish between "consulting" and "compiling"; all code is compiled unless declared dynamic.
The new debugger also helps you to find inefficiencies in your program by
- showing visually the creation of choice points, and
- distinguishing between determinate and non-determinate exit from a goal.
The debugger is documented in Chapter E.
A-2-5: Other New Features
- Exception Handler: Allows the programmer to specify a recovery action to be taken if an exception occurs during the execution of a particular goal. All errors detected by the system now cause an
exception to be raised; exceptions can also be raised by calling the built-in predicate raise_exception/1. (Chapter G-19)
- Message Handler: Allows customization of the text of system messages and of how they are displayed to the user. Major uses are customization or internationalization of error messages, and
building user interfaces. (See Chapter G-20)
- New I/O: The new I/O system has substantially faster character I/O and more efficient (buffer-based rather than character-based) user-defined streams. There is now no limit on the number of open
streams other than that imposed by the operating system.
- New Arithmetic: Standard 32-bit integers and 64-bit floats are supported. Exceptions are raised on overflows. Variables in arithmetic expressions can be bound to expressions (not just numbers).
- Advice Package: Allows a developer to associate consistency checks ("advice") to be performed whenever specified predicates are entered or exited. Advice checking can be enabled/disabled
selectively or globally during the development process. (Chapter E-4)
A-2-6: Compatibility Issues
A-2-6-1: Saved States
save/[1,2] are gone. Chapter G-5 explains why these have been removed. In most cases save_program/2 can be used in their place, with a little rearrangement of your code.
Foreign code is no longer included in saved-states. When a saved-state is used it needs to be able to find the relevant .o files and cause them to be linked in. Since this linking can be slow, it
will often be preferable to use qld to link your saved-state with its .o files into an executable file. See section H-1-1-5 for how to do this.
A-2-6-2: Error Reporting/Handling
In earlier releases, some errors caused simple failures. For example,
| ?- functor(A,B,C).
no
This is not logical, since it is easy to choose A,B,C such that functor(A,B,C) is true. Generally, built-in predicates should enumerate all their logical solutions or else raise an exception in cases
such as this one where enumeration is impractical. Thus you now get:
| ?- functor(A,B,C).
! Instantiation error in argument 2 of functor/3
! goal: functor(_530,_531,_532)
Existing code that relies on the old error behavior will need modification to take this into account. The insertion of appropriate nonvar/1 checks is usually all that is required.
A-2-7: New Built-in Predicates
See the Reference Pages for information on the following new predicates.
- absolute_file_name/3
-
generalization of absolute_file_name/2
- add_spypoint/1
-
add a spypoint
- add_advice/3
-
specify an advice action for a particular port of a predicate
- append/3
-
list concatenation relation
- assign/2
-
assign a value to a foreign data structure
- at_end_of_file/0
-
test if the current input stream is at end of file
- at_end_of_file/1
-
test if the specified stream is at end of file
- at_end_of_line/0
-
test if the current input stream is at end of line
- at_end_of_line/1
-
test if the specified stream is at end of line
- callable/1
-
test if the a term is syntactically valid as an argument to call/1; that is, not a variable, a number or a data base reference
- check_advice/0
-
enable advice-checking for all predicates with advice
- check_advice/1
-
enable advice-checking for the specified predicates
- compound/1
-
test if a term is a compound term
- current_advice/3
-
find out what advice exists
- current_spypoint/1
-
find out what spypoints exist
- db_reference/1
-
test if a term is a data base reference
- extern/1
-
declare predicate to be callable from C
- ground/1
-
test if a term is ground (contains no unbound variables)
- hash_term/2
-
produce a hash-value corresponding to a term
- initialization/1
-
declare a goal to be called when a file is loaded or when an executable file containing it is run
- load_files/1
-
load source or QOF files
- load_files/2
-
load source or QOF files with specified options
- nocheck_advice/0
-
turn off all advice checking
- nocheck_advice/1
-
turn off advice checking for specified predicates
- on_exception/3
-
execute a goal in the context of an exception handler
- open/4
-
open a file with specified options
- peek_char/1
-
return the next character in the current input stream without consuming it
- peek_char/2
-
return the next character in specified stream without consuming it
- print_message/2
-
print an error, warning, help, silent or informational message
- print_message_lines/3
-
auxiliary routine for message printing
- prompt/3
-
examine or change the prompt for a particular stream
- raise_exception/1
-
raise an exception
- read_term/2
-
read a term from current input stream
- read_term/3
-
read a term from specified stream
- remove_advice/3
-
remove advice for specified port of a predicate
- remove_spypoint/1
-
remove a spypoint
- save_modules/2
-
save a module or modules to QOF
- save_predicates/2
-
save a predicate or predicates to QOF
- save_program/2
-
save the program state and specify goal to be run on start-up
- seek/4
-
byte-oriented random access to files
- simple/1
-
opposite of compound/1; true of variables, atoms, numbers and data base references
- skip_line/0
-
skips characters on current input up to end of line
- skip_line/1
-
skips characters on specified stream up to end of line
- source_file/3
-
relation between source file, predicate and clause number
- volatile/1
-
declare that a predicate should be excluded when saving
- write_term/2
-
write a term to current output
- write_term/3
-
write a term to specified stream
A-2-8: New Hook Predicates
These predicates are called at appropriate times by the Prolog system and are defined by the user.
- user:display_help_file/3
-
define how on-line help is displayed
- user:message_hook/3
-
define how messages are displayed
- user:generate_message_hook/3
-
define the textual form of messages
- user:query_hook/2
-
define or bypass user-interaction
A-2-9: Removed Built-in Predicates
save/[1,2] has been removed as discussed above. Their names are still reserved so that we can use them in a future release.
The following predicates were supported only by the interpreter and have now been eliminated. If their functionality is required, it can be achieved by passing an explicit ancestors list to all the
predicates that need it as an extra argument.
ancestors/1
subgoal_of/1
maxdepth/1
depth/1
The following predicates which were previously provided only because they are defined in other Prolog systems have now been removed. The user may supply definitions for them if desired. (Many of
these just printed error messages in earlier releases.)
'LC'/0
'NOLC'/0
current_functor/2
incore/1
load_foreign_files/3
log/0
nolog/0
plsys/1
reinitialize/0
restore/2
revive/2
Copyright (C) 1998 SICS
contact:
product support
sales information