Cuts

Syntax

Cut =
     "\!" Path.

Evaluation

The evaluation of the rest \! Q proceeds as follows. The path Q is evaluated. If the result obtained is a failure $fail(k), then the "strengthened" failure $fail(k+1) is taken to be the result of the whole construct. Otherwise, the result of evaluating Q is taken to be the result of the whole construct.

The path Q is evaluated at the level m-1, where m is the level at which the whole construct is evaluated.

     Env,m,St |- Q => Ge,St'
     ----------------------------
     Env,m+1,St |- \! Q => Ge,St'


     Env,m,St |- Q => $fail(k),St'
     ------------------------------------
     Env,m+1,St |- \! Q => $fail(k+1),St'


     Env,m,St |- Q => $error(Ge),St'
     ------------------------------------
     Env,m+1,St |- \! Q => $error(Ge),St'

Examples

The evaluation of the following path results in the character string 'ABD' being printed, and the result '2' being returned.

    {
      \? {
        <Print 'A'> $fail;
        <Print 'B'> \! $fail;
        <Print 'C'> = '1';
        };
      <Print 'D'> = '2';
    }
Related concepts
Paths
Restrictions on the Use of Cuts