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