Block Declarations

Author(s): Rémy Haemmerlé.

Version: 0.1 (2008/25/5) This package provides compatibility with SICStus' block declarations

Usage and interface

  • Library usage:
    :- use_package(block). or :- module(...,...,[block]).
  • New operators defined:
    block/1 [1150,fx].
  • New declarations defined:

Documentation on new declarations


Usage: :- block(BlockSpecs).

  • Description: In this declaration BlockSpecs specifies a disjunction of conditions. Each condition is of the form predname(C1, ..., CN) where each CI is either a `-' if the call must suspend until the corresponding argument is bound, or anything else otherwise.

  • Convention: The recommended style is to write the block declarations in front of the source code of the predicate they refer to. Indeed, they are part of the source code of the predicate and must precede the first clause. Moreover it is suggested to use `?' for specifying non conditioned arguments.

  • Example : The following definition calls to merge/3 having uninstantiated arguments in the first and third position or in the second and third position will suspend.

    :- block merge(-,?,-), merge(?,-,-).
    merge([], Y, Y).
    merge(X, [], X).
    merge([H|X], [E|Y], [H|Z]) :- H @< E,  merge(X, [E|Y], Z).
    merge([H|X], [E|Y], [E|Z]) :- H @>= E, merge([H|X], Y, Z).
  • The following properties hold at call time:
    (basic_props:sequence_or_list/2)BlockSpecs is a sequence or list of callables.