Hi, Daniel!
If only for efficiency reasons, you should go for 'case' whenever it is
applicable. The other two commands are specific to (concurrent) logic
programming and I guess have no functional programming counterpart. You
really have to understand the notion of a subspace and its usage in order
to grasp their behaviour ('case' use no such concept).
For a start, the "guards" in 'case' (patterns) are completely different
entities to those in 'or' and 'and' (arbitrary statements). 'or' just
makes sense when all but one guards are likely to fail (if two become
entailed nothing happens), in which case the system commits to the
remaining one _EVEN IF_ it is not entailed. 'cond' is not a
non-deterministic 'case', while it is true that it might be used to
implement 'case' in a non-deterministic fashion (guards are run
concurrently and the first whose entailment is detected "wins").
Cheers,
Jorge.
Daniel Zingaro escreveu:
> Greetings,
>
> I'm trying to decide whether to use 'or', 'case' or 'cond' to pattern
> match over a term language and having trouble fully understanding the
> differences. (I could just use 'case', but that would be no fun! ...)
>
> 'Case' seems to mimic the 'case' that we'd see in functional
> languages: successively evaluate guards until one of them succeeds,
> then evaluate the associated statement. If more than one guard would
> succeed, use the first one.
>
> But what is the difference between this, and 'or' and 'cond'? These
> two seem to concurrently execute the guards and then execute the
> statement associated with the one that succeeds (so I can't rely on
> textual order of guards anymore). What happens, though, if multiple
> branches of the 'or' or 'cond' succeed? We'd have two choices for the
> statement to execute... ?
>
> Thanks for any insights,
> Dan
>
>
>
>
> _________________________________________________________________________________
> mozart-users mailing list
> [email protected]
> http://www.mozart-oz.org/mailman/listinfo/mozart-users
>
Jorge M. Pelizzoni
ICMC - Universidade de São Paulo
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users