Tuesday, December 30, 2008

Predicates

While discussing language design, a predicate is an expression that evaluates to a boolean.

The purpose of the predicate is to allow branching within the code.

There are multiple ways to define how you would like to identify the predicate structure. One of the most common is the utilization of the if command

i.e.
if predicate
command-block

additionally

if predicate
command-block
else
command-block

You can also define predicate structure in far more interesting designs

expression if predicate

predicate do command-block

Predicates are also used for conditional looping;

such as whiles

while predicate
command-block

while predicate
command-block
then
command-block

or Do structures

do
command-block
while predicate