Moe Aboulkheir wrote:
Hi,

If there is a more appropriate place for me to ask these questions, please let me know.

I'm currently working through CTM, and am enjoying it very much. I was confused by the answers to question #6 at the end of chapter #2 (the answers obtained by running the code snippets to verify my guesses).

I can't find a section that explains the blocking of a case statement when there are unbound variables in the value given as the first argument.

Dear Moe,

Here is some more explanation.  When doing pattern matching,
the case statement looks at exactly one argument at a time.  It will
then either block, pick the alternative, or reject the alternative and
go on to look at the next argument.

When you have a complicated case like:
  case foo(bar:X baz:baz) of foo(bar:bar baz:Y) then ... end
the way to understand it is to translate it into the kernel language:
  case X of bar then
      case baz of Y then ...
      else ... end
  else ... end
The kernel language has a simplified case statement that only
looks at one argument, something like this:
  case X of f(l1:X1 ... ln:Xn) then ... else ... end

Hope this helps,

Peter


_________________________________________________________________________________
mozart-users mailing list                               
mozart-users@ps.uni-sb.de
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to