Well, I'll admit to being a bit mind twisted. (Actually I like that state.) I learned prolog about 2 decades ago and have not kept up with newer developments.  I think in terms of Edinburgh prolog.  I use setof/3, etc. (But I don't do asserts.)  But I'm still not convinced that the way case is defined is the best approach.
 
For example, on p 80 in CTM we see that
local <pattern> = <_expression_> in ... end
does full unification even though it is not recommended to use it that way.
 
In
local X in
   case
X of 3 then {Browse X} end
   case
3 of X then {Browse X} end
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
   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?)
 
I still think the semantics of case should be re-analyzed.
 
-- Russ
_____________________________________________
Russ Abbott
Professor, Computer Science
California State University, Los Angeles
o Check out my blog at http://russabbott.blogspot.com/

 
On 9/26/05, Raphael Collet <[EMAIL PROTECTED] > wrote:
Russ Abbott wrote:
> One solution would be to have two versions of the case statement (case
> and caseunify), one that suspends if the pattern aribiter is not
> completely bound and one that does full unification.

No, this is definitely not a good idea.  Prolog does pattern matching by
*speculative* unification!  It works only because Prolog is *sequential*
and search is built-in.

Oz is concurrent, and search is encapsulated.  The latter makes that we
don't need a "cut" statement in Oz.  Unification is more the functional
style one.

> Not only would
> that offer a nice feature, it would solve the problem that new-comers
> tend to get confused about this. If both language features were
> presented together in the documentation, there would be no confusion.

Most newcomers are not from the Prolog world, and many find the "case"
statement quite natural.  Prolog programmers are sometimes a bit
mind-twisted, and need some rehabilitation to normality ;-)  I am sure
you will quickly get used to Oz.

Cheers,
raph

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

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

Reply via email to