Running Oz

This page is organized as follows:

  1. Running Oz on Olympus
  2. Running Oz on Your Home Machine
  3. Troubleshooting
  4. Advanced Topics

We recommend using the Mozart/Oz system for this class, since it corresponds closely to the van Roy and Haridi book, Concepts, Techniques, and Models of Computer Programming.

Running Oz on Olympus

The Olympus system is the recommended platform for course work, but the Mozart/Oz system should run the same everywhere, so the choice is up to you.

You can login to your account at olympus.eecs.ucf.edu using your NID as your login. Your default password is of the form Pyymmdd, where yymmdd is your birth year, month and day.

To access olympus, use an ssh client like putty from anywhere on campus. From off-campus, you will need a VPN connection to UCF first. For a VPN account and help, they can go to http://www.noc.ucf.edu/VPN/default.htm

Starting Mozart

On olympus Mozart/Oz system is found in /usr/bin/, which should be in your PATH by default. (Thus you shouldn't have to do anything special to set this up.)

To start the Mozart/Oz system, simply issue the command oz at the shell's prompt.

Exiting Mozart/Oz

Mozart runs under Emacs, so to quit, use the File menu, or type C-x C-c.

Return to top

Running Oz on Your Home Machine

The Mozart/Oz system works on a home machine in the same way as on the Olympus system.

Getting Mozart/Oz for your Home Machine

The Oz interpreter used for this course is available on many platforms, including Unix, Macintosh, and Windows. You can download it from mozart-oz.org. Follow the installation instructions carefully, in particular define the OZEMACS variable in your environment if you don't have a program named "emacs" that runs the emacs editor in your PATH. (To set environment variables in Windows XP, start the control panel, then click on "System", then the "Advanced" tab, then click on "Environment Variables".)

Note, however, that the version of emacs on the Mozart/Oz web page is version 20.7, which is very old. There are significant advantages to using the latest version, which you should get from ftp://ftp.gnu.org/gnu/emacs/windows/. (That is, don't use the one available from the Mozart/Oz web page.)

Return to top

Troubleshooting

Showing Strings as Strings Instead of Lists of Character Codes

The following is adapted from http://www.ling.gu.se/~lager/kurser/Programming/Exercises/warmup.htm.

To Browse a string like "foo" and have it display the string as a string in the Browser, in the browser window click on Options then on Representation and check the box Strings. Then mark the list of Ints (Chars) and click on Selection then Rebrowse.

To show strings as text in the emulator, instead of using Show, use System.showInfo.

\insert Doesn't Work

If it seems that \insert isn't working for you, then the problem may be that you aren't starting Oz from the same directory as the files live in when you are trying to \insert. This can happen if you start Mozart's OPI (the Oz Programming Interface) from a shortcut that uses a different starting directory.

Here are some fixes, each of which should work, that you can try in order from easiest to more involved:

  1. Start the Mozart OPI by double clicking on a .oz file that is in the directory where your files and the tests are, instead of just starting Mozart. You could just double click on the test file, for example. This will cause the Emacs and Oz current directory to be the directory where the file is.
  2. Change the starting directory in the shortcut from which you start the Mozart OPI to use the directory you have your files and the test files in.
  3. Define the environment variable OZPATH to include the directory you have the files you want to \insert in. On Windows this path would be a semicolon (;) separated list of directory names. (To set environment variables in Windows XP, start the control panel, then click on "System", then the "Advanced" tab, then click on "Environment Variables".) You'll have to restart the OPI before this takes effect. You can check what's in your OZPATH environment variable by executing: {System.showInfo {OS.getEnv "OZPATH"}} .

Arity Errors

If you get an error message about "illegal arity in application" or "wrong arity in application", then you have made a mistake either in calling a procedure or function with the wrong number of arguments or in using a procedure call as an expression or a function call as a statement. See ArityError.oz for details.

This can also happen if you think you are writing a function (with an expression in its body) but you use proc, or if you think you are writing a procedure (with a statement in its body) but you use fun.

Illegal Record Label Errors

If you get an error message about "illegal record label" or a runtime "type error" with a complaint from Tuple.make that it expected a literal, then you have made a mistake in your function or procedure calling syntax. See TupleError.oz and TupleError2.oz details.

Don't see any Output

If you don't see any output from our tests cases after you feed our tests to Oz, it may be because you are looking at the wrong Emacs buffer. (This especially happens when your tests don't throw any uncaught exceptions, i.e., when you haven't made any gross coding errors.) To see the output from our testing files, you must tell Emacs to switch to the *Oz Emulator* buffer. In that buffer you should see the test output. From the Oz menu use Show/Hide then select Emulator. (By default you can also type C-. e to Emacs from an Oz Window.)

Solve isn't Loading

If you aren't getting the Solve procedure for chapter 9 to work for you, you need to get it from the textbook's basic system supplements file. This will be loaded automatically if you save it as your .ozrc file in your home directory (or have your .ozrc file load it).

Return to top

Advanced Topics

For some problems in the book, you will the Mozart initialization file, which should be saved as .ozrc in your home directory.

See the Mozart/Oz web site for more about the interface. See also the course resources page for links to more Oz resources.

Windows Keystrokes in Emacs

If you like to use the standard Windows keystrokes for cut, paste, and copy, customize Emacs to use CUA-mode by default. (This assumes that you have Emacs version 22 or later. The one on the Mozart/Oz web page is version 20.7, which is old.) Use the menu "Options", select "Customize Emacs", and from there the select "Top Level Customizations". then select the "Convenience" group by clicking on the "go to group" link, and then go to the Cua group.

If you would rather do it the hard way, or if you have a version of Emacs previous to 22, put the following in your emacs initialization file, ~/.emacs.el. (The lines that start with a semicolon are comments, and can be omitted.)

(if (< emacs-major-version 22)
  (progn
    ;; Make emacs more like standard windows applications in terms of
    ;; mouse selections (this is similar to pc-select).
    ;; One advantage is this is that it makes Dragon Dictate work with Emacs.
    (require 'cua)
    ;; Make the behavior of emacs on C-c, C-v, C-x, and C-z to be
    ;; just like that of be as in standard window apps, so you can use
    ;; these keys to copy, paste, and select when there is a selection
    ;; active, then uncomment the following.
    (CUA-mode t)
    ;; Make C-c leave the region active, which is what happens under Windows.
    (setq CUA-mode-keep-region-after-copy t)
  )
  ;; The same for emacs version 22 (and hopefully higher...)
  (progn
    (cua-mode)
    (setq cua-enable-cua-keys t)
    (setq cua-mode-keep-region-after-copy t)
  )
)

Alternatively, you can use Gary Leavens's .emacs.el file which includes the above lines and several other things. It should be saved into .emacs.el in your home directory. (On Windows you may not have a home directory yet, so pick one. You also have to set HOME in the environment; this is automatic in Unix and hence on Mac OS X, but needs to be done by hand in Windows.)

Running Oz from Within Emacs

To run Oz from within emacs, you can use the following lines in your ~/.emacs.el file.

;;; Oz program mode with Mozart/Oz.
;;; You have to arrange for the Oz-related emacs lisp (.el) files
;;; to be in emacs's load-path, for its bin directory to be in the PATH,
;;; and for the OZHOME environment variable to be set properly.
(add-to-list 'auto-mode-alist '("\\.oz\\'" . oz-mode))
(add-to-list 'auto-mode-alist '("\\.ozg\\'" . oz-gump-mode))
(autoload 'run-oz "oz" "" t)
(autoload 'oz-mode "oz" "" t)
(autoload 'oz-gump-mode "oz" "" t)
(autoload 'oz-new-buffer "oz" "" t)

You can get the above code from Gary Leavens's mode-customizations.el file. The above code makes some assumptions; in particular it assumes that the emacs-lisp files for Mozart/Oz are in the emacs load-path. You can add directories to this load-path by putting the following code near the beginning of your ~/.emacs.el file.

(setq load-path
 (cons "~/emacs"
	 (append load-path
		(list (if (eq system-type 'windows-nt)
			"c:/cygwin/usr/local/mozart/share/elisp"
		        "/local/gnu/share/elisp")))))

The above adds the directory where the Mozart/Oz install has these emacs-lisp files to the load-path, depending on the kind of system being used.

See the Mozart/Oz documentation for more bullet-proof emacs customization code that only relies on OZHOME being set properly.

Making Emacs find your Customization File

On Linux machines, it seems that there is no problem getting the oz command to use your ~/.emacs.el file; you just have to have it in your home directory. On Windows machines, if the emacs started by the oz command is not finding your ~/.emacs.el file, it is because it doesn't know where your home directory is. To do this, you have to set your environment variable HOME to the right directory. (If you use cygwin, you can also make a shortcut in a shell script.)

For Vi Users

If you are a vi user, you may want to use viper-mode in emacs to get the vi keystrokes and still use the Mozart Oz Programming Interface. To do this, put the following in your .emacs.el file:

(viper-mode)

Return to top

Last modified Monday, October 6, 2008.

This web page is for the Fall 2008 offering of COP 4020 at the University of Central Florida. The details of this course are subject to change as experience dictates. You will be informed of any changes. Please direct any comments or questions to Gary T. Leavens. Some of the policies and web pages for this course are quoted or adapted from other courses I have taught, in partciular, Com S 342.