Searches

Syntax

Search =
     Source "$iter" Source
          [ "::" HardExpression ] [ Rest ].

Evaluation

The goal of evaluating the path
     S'' $iter S' :: He R
is to find such values for the variables appearing in He that the evaluation of R succeeds, in which case the result obtained is taken to be the result of evaluating the whole construct.

An empty hard expression He may be omitted along with the key word ::. If the rest R is an empty delimited path (which always returns an empty ground expression), it may be omitted.

     S'' $iter S'  =>=>  S'' $iter S' :: ,

     S'' $iter S' R  =>=>  S'' $iter S' :: R

     S'' $iter S' :: He  =>=>  S'' $iter S' :: He ,

The initial values for the variables appearing in He are obtained by evaluating the source S'', whereas the evaluation of S' enables the new variable values to be obtained from the previous ones.

The sources S'' and S' are considered to be at the zero level.

The search for the variable values proceeds as follows. First, the initial variable values are found by evaluating the source S'' and matching the ground expression Ge obtained against the pattern He. Then an attempt is made to evaluate the rest R in the new environment. If the value returned is a failure $fail(0), then S' is evaluated and a ground expression obtained is matched against He, and then a new attempt is made to evaluate R, etc.

    S'' $iter S' :: He R  =>=>
              S'' :: He, \{ R; S' $iter S' :: He R; }

Examples

If the values of the variables eA and eB are not defined in the current environment, the match
   eX : $l eA eB,
     <Writeln eA>, <Writeln eB> $fail
is equivalent to the search
   ()(eX)
     $iter \{ eB : t1 e2 = (eA t1)(e2); }
       :: (eA)(eB),
     <Writeln eA>, <Writeln eB> $fail
Related concepts
Sources
Hard Expressions
Rests