Russ Abbott wrote:

As a new Mozart-Oz user, I have what's probably a simple question. (I have a number of simple questions, but I'll start with this one.) Why is it necessary to declare local variables in procedures and functions. Considering how much effort was put into making Oz an easy language to write, why force explicit declarations? After all, the compiler could implicitly declare any variable at the procedure level if it is not otherwise declared. This would parallel the way that variables on the right-hand-side of prolog clauses are implicitly declared.

You raise several issues here! Explicit declarations avoid the bug when the variable already exists in the surrounding context. BTW, this does not mean you have to do any extra typing, since you
can declare and initialize the variable at the same time, e.g.:

  local X=12 in {Browse X} end

Prolog does not have lexical scoping (it is a *flat* language). All variables in the clause body are implicitly universally quantified. This is not so nice if you want to have local variables in a clause
body: you can't!

Thanks.
By the way, to push myself to use Oz, I decided to teach an AI course with it. My plan is to work our way through the book and use Oz computational capabilities to write one or more Sudoku solving programs. If anyone is interested, the course web page is: http://cs.calstatela.edu/~wiki/index.php/CS-460-1.Fall-2005:Main_Page <http://cs.calstatela.edu/%7Ewiki/index.php/CS-460-1.Fall-2005:Main_Page>. This is a wiki. If you have anything useful to add, please do so. -- Russ Abbott

This looks very nice. Using Oz to solve Sudoku can lead you well into constraint programming! Did you see Raphael Collet's program on solving the minesweeper using constraint programming: http://www.info.ucl.ac.be/~raph/minesweeper/ (see the MOZ 2004 proceedings,
Springer LNCS 3389).

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

Reply via email to