[NEXT] [PREV]    HANDBOOK / GENTLE PRIMER / Describing Computations /

Invocations and Rules

Gentle
Applications
Concepts
Examples
Handbook
Support
Download

A predicate is used to specify a computation. Such a computation is triggered by a predicate invocation. For example, if we have defined a predicate favorite that determines for a given Person the favorite Color, then we can write

   favorite(P -> C)
to ask for the favorite color C of P.

A predicate is described by rules. For example, the predicate favorite could have been defined by the following rules:


   'rule' favorite (jim -> red)
   'rule' favorite (julia -> blue)
   'rule' favorite (jane -> red)
   'rule' favorite (john -> yellow)
An item like favorite (jim -> red) here is called a rule heading (rule bodies, here empty, are discussed later).

An invocation


   favorite (julia -> C)
would define the variable C as blue because the second rule defines the output blue for the input julia.

A predicate may have input and output parameters. The input parameters come first, the output parameters being separated by an arrow. Here is a predicate with no output parameters:


   IsJimsColor(Val)
with rule

   'rule' IsJimsColor(red)
and one with no input parameters:

   JimsColor(-> Val)
with rule

   'rule' JimsColor(-> red)
If a list of input or output parameters is supplied, a comma is used to separate the members.





[NEXT] [PREV]