Wow.  The CTM doesn't really say that pattern matching is broken down into such primitive operations.
With my (erroneous) assumption, mainly that pattern-matching was some sort of unification-entailment hybrid, I thought problem 4(b), p. 107 of the CTM was impossible because you'd have to check if variables were bound (i.e. with 'IsBound', which is outside the declarative model).
Thanks very much for the info.

-- Harmon

On 8/31/05, Peter Van Roy <[EMAIL PROTECTED]> wrote:
Harmon Nine wrote:

> Something I don't understand:
>
> In this example (exercise 6, p. 108 of the CTM):
> -------------------
> proc {Test X}
>   case X of f(a Y c) then {Browse 'case'(1)}
>   else {Browse 'case'(2)} end
> end
> -------------------
>
> This suspends until X is bound:
> -------------------
> declare X Y {Test f(X Y d)}
> -------------------
>
> Why would this be, when it is clear that the 'd' in the input argument
> will not match the 'c' in the "Test" procedure, and thus the
> pattern-match will fail?
> Why does pattern matching not "look ahead" like entailment?

A case statement only looks at one variable at a time.
Here, it is X.  If you translate your example into the
kernel language, you get:

   case X of f(A Y C) then
      case A of a then
          case C of c then ...
          end
      ...
   ...
   end

The case statement is designed this way for
simplicity and efficiency.  It makes the case a very
nice primitive operation and also very efficient to
implement.  If you want the 'look ahead' you have
to do a unification or an entailment check explicitly.
It's smarter but also more costly to implement.

Peter


_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to