Runtime & Environment

This section contains predicates for:

  • Setting Runtime Modes
  • Error Handling in Prolog
  • Miscellaneous Predicates
  • Special Predicates for the Prolog Listener
  • Setting Runtime Modes

    The following predicates turn on and off the modes that control the behavior of the Prolog runtime system. The modes are described in detail in the section on arun.

    get_mode(Mode, Value)

    get_mode/2 retrieves the current setting of Mode, unifying Value the atoms 'on' and 'off' as appropriate.

    set_mode(Mode, Value)

    set_mode/2 sets the named Mode to the Value, either 'on' and 'off.'

    Miscellaneous Predicates

    Various predicates are provided for getting information about the operation of the Prolog engine and the computer environment.

    abort(Severity)

    abort does the following based on the value of Severity:

    0
    closes any open files (after flushing them), resets the Prolog environment and restarts the application.
    1
    closes any open files (after flushing them) and behaves as halt.
    2
    closes any open files (after flushing them) and behaves as halt except that the value returned to the operating system indicates an abnormal return has occurred.

    current_prolog_flag(FlagAV, ValueNV)

    current_prolog_flag returns various system limits. Currently flags are: max_atoms, max_integer, min_integer.

    date(MonthNV, DayNV, YearNV)

    date returns the Month, Day and Year if unbound. If bound, then it unifies with them. For example:

    highwater(Heap, Local, Control, Trail)

    highwater predicate returns the highwater marks used by these four control structures. These values can then be used when initializing the Logic Server, to minimize the amount of resources taken.

    pro_heap(Top, Pos)

    pro_heap/2 returns the size, Top, and current position, Pos, of the heap.

    pro_control(Top, Pos)

    pro_control/2 returns the size, Top, and current position, Pos, of the control stack.

    pro_local(Top, Pos)

    pro_local/2 returns the size, Top, and current position, Pos, of the local stack.

    pro_trail(Top, Pos)

    pro_trail/2 returns the size, Top, and current position, Pos, of the trail stack.

    pro_db(Allocated, Used)

    pro_db/2 returns the amount of dynamic database storage allocated by the Prolog engine at this point in time, and the amount of that storage actually used. This predicate is for information only, as the Logic Server allocates dynamic memory blocks as it needs them.

    stack_sizes(Heap, Control, Local, Trail)

    stack_sizes returns the number of cells in use on each of the respective stacks.

    system(CmdA)

    system/1 executes an operating system command or program.

    CmdA must be instantiated to an atom representing a command or program that can be executed by the operating system. The call to system/1 succeeds if the command "succeeded". For example:

    time(Hour, Min, Sec)

    time/3 succeeds by unifying Hour, Min, and Sec to the current time-of-day (hours, minutes, and seconds respectively). If any of these are given as integers, then time/3 can be used as an alarm clock, failing until the conditions are met.

    timer(Ticks)

    timer/1 succeeds if Ticks can be instantiated to floating point seconds since some implementation dependent time.

    It is intended primarily for timing executions

    Note that timings can also be done using the built-in atom, cputime. The value of cputime is the current elapsed time in floating point seconds. It can be used in arithmetic expressions.

    version(String)

    version/1 returns a string with the current Amzi! version.

    Special Listener Predicates

    These predicates, except pp and user_pp can be entered only at the ?- prompt in the listener.

    add

    Allows you to add clauses to the dynamic database. This is equivalent to consult.

    consult_project(ProjectFile)

    Consults all the files and libraries in a project file. Note that if a project is already the current project, consult automatically does a reconsult.

    debug

    Enters the Debugger. See the Debugger section for more information.

    pp(Term), user_pp(Term)

    pp first tries to prove user_pp(Term). If this fails then it will pretty print Term at the user terminal (labeling variables using numbervars/3 and printing separate goals on separate lines).

    quit

    Exits the current listener.

    reconsult_project(ProjectFile)

    Reconsults a project file.

    replace

    Allows you to replace clauses in the dynamic database. This is equivalent to reconsult.

    replace expects a sequence of clauses, followed by [ctrl-z] or 'quit.' rather than a single clause.

    Copyright ©1987-2000 Amzi! inc. All Rights Reserved.