Russ,

As an Oz novice, I too was puzzled by your examples, but remembering that the variables introduced in patterns are fresh variables (see 5.6.1 and 5.6.2 of the OZ tutorial) for the scope of the then statement does I think, clear up your questions.

From: Russ Abbott
In
local X in
  case X of 3 then {Browse X} end
%%% 3 can't be made the same as the undefined X, so suspend until we know more about X
  case 3 of X then {Browse X} end
%%% The fresh undefined X  can be made equal to 3 no problem
end
the first of these suspends while the second succeeds. And in

local A
  proc {Pair X Y}
     case X of Y then {Browse X#Y} end
%%% The Y in "of Y" is a fresh undefined var and not the procedure argument Y
%%% so it can be made the 3 of {Pair 3 A} no problem
%%% and is just as undefined as the A of {Pair A 3}
  end
in
  {Pair 3 A}
  {Pair A 3}
end
both succeed although they give different results: 3#3 and _#_ respectively! (Why didn't the second call not suspend, and since it didn't suspend, why didn't it bind Y to 3?)

%%%%
Re-writing as follows may make things clearer...

local X in
  case X of 3 then {Browse X} end
  case 3 of X1 then {Browse X1} end
% or perhaps
  case 3 of !X then {Browse X} end
end

local A
  proc {Pair X Y}
     case X of Y1 then {Browse X#Y#Y1} end
  end
in
  {Pair 3 A}
  {Pair A 3}
end

Cheers
Bryan

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

Reply via email to