|Did you know ...
|Pack canny_tudor -- prolog/canny/situations.pl
An important side effect occurs for ground Situation terms. The
implementation creates the situation's temporary module and
applies default options to its new dynamic predicates. The
module(Module) term unifies with the newly-created or existing
The predicate's determinism collapses to semi-determinism for
ground situations. Otherwise with variable Situation components,
the predicate unifies with all matching situations, unifying
fix/0 fixes the pending situation
changes at some future point. The
now/1 form applies Now to
Situation at the current Unix epoch time.
Uses apply_to_situation/2 when Situation is ground, but uses property_of_situation/2 otherwise. Asserts therefore for multiple situations if Situation comprises variables. You cannot therefore have non-ground situations.
was/2 dynamic facts (clauses without rules). Second, it adds,
replaces or removes the most current Current-When pair. This
allows detection of non-events, e.g. when something disappears.
Some types of situation might require such event edges. Finally,
fixating broadcasts situation-change messages.
The rule for fixing the Current-When pair goes like this: Is
there a new
now/2, at least one? The latest becomes the new
current. Any others become Previous-When. If there is no
now/2, then the current disappears. Messages broadcast
accordingly. If there is more than one
now/2, only the latest
becomes current. Hence currently-previously only transitions
once in-between fixations.
fix/1 is a shortcut for
now(Now, At) and
becomes the current Unix epoch time. Fixes but does not retract
was/2 clauses for all matching Situation terms.
retract(_, Delay) retracts all
was/2 history terms using
the last term's latest time stamp. In this way, you can retract
situations without knowing their absolute time. For example, you
can retract everything older than 60 seconds from the last known
history term when you
The second argument Apply can be a list of terms to apply, including nested lists of terms. All terms apply in order first to last, and depth first.
You can replace the When term with
for(Seconds) in order to
measure elapsed interval since fixing Situation. Same applies to
previously/2 except that the current situation time stamp serves
as the baseline time, else defaults to the current time.
was(Was, When) where Situation is
effectively a primitive condition coordinate, Was is a sensing
outcome and When marks the moment that the outcome transpired.