![]() |
YAP 7.1.0
|
We next describe how to invoke YAP in Unix systems
Most often you will want to use YAP in interactive mode Assuming that YAP is in the user's search path, the top-level can be invoked under Unix with the following command:
All the arguments and flags are optional and have the following meaning:
M
bytesL
IP_HOST
port
connect standard streams to host IP_HOST
at port port
Note that YAP will output an error message on the following conditions:
When restoring a saved state, YAP will allocate the
same amount of memory as that in use when the state was saved, unless a different amount is specified by flags in the command line By default, YAP restores the file startup.yss from the current directory or from the YAP library
YAP will try to find library files from the YAPSHAREDIR/library directory
YAP can also be used to run Prolog files as scripts, at least in Unix-like environments A simple example is shown next (do not forget that the shell comments are very important):
The #!
characters specify that the script should call the binary file YAP Notice that many systems will require the complete path to the YAP binary The -L
flag indicates that YAP should consult the current file when booting and then halt The remaining arguments are then passed to YAP Note that YAP will skip the first lines if they start with #
(the comment sign for Unix's shell) YAP will consult the file and execute any commands
A slightly more sophisticated example is:
The initialization
directive tells YAP to execute the goal main after consulting the file Source code is thus compiled and main
executed at the end The is useful while debugging the script as a Prolog program: it guarantees that the syntax error will not propagate to the Prolog code
Notice that the --
is required so that the shell passes the extra arguments to YAP As an example, consider the following script dump_args
:
If you this run this script with the arguments:
the script will start an YAP process with stack size 10MB
, and the list of arguments to the process will be empty
Often one wants to run the script as any other program, and for this it is convenient to ignore arguments to YAP This is possible by using L --
as in the next version of dump_args
:
The --
indicates the next arguments are not for YAP Instead, they must be sent directly to the argv built-in Hence, running
will write test
on the standard output