Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing Mozart-Oz code in command line

Tags:

oz

mozart

I'm trying to use Mozart Oz. I download the execution binary from source forge: http://sourceforge.net/projects/mozart-oz/.

When launching Mozart.app, the emacs (aquamacs for Mac OS X) starts to do the coding within it.

For example, I can type in {Browse 'Hello World'} and execute Oz -> Feed Buffer to get the result in Tcl/Tk browser.

Then, how can I build or execute the Oz code in command line just like I do with Python or Ruby?

I found binaries in the bin directory.

/Applications/Mozart2.app/Contents/Resources/bin
    ├── oz
    ├── ozc
    ├── ozemulator
    ├── ozengine
    └── ozwish

However, when I execute the code with ozc -c hello.oz, I got %** variable Browse not introduced error. What might be wrong?

like image 672
prosseek Avatar asked Mar 16 '23 16:03

prosseek


1 Answers

You must use Browser.browse

Actually, every function must be imported/created when building application in oz. When you import Browser, you get a record with all the functions that the Browser object class export. (see https://mozart.github.io/mozart-v1/doc-1.4.0/browser/node2.html)

thus, your code is

functor
import
   Browser
define
   {Browser.browse 'Hello World'}
end

I should exit the application with {Application.exit 0} but it gives me a weird error... Anyway, I recommend not to use the Browser. Even if it's very powerful when using an interactive interpreter, it's heavy and buggy. Use System.showInfo instead, and build your own TK window if you really want one.

functor
import
    System
    Application
define
    {System.showInfo 'Hello World!'}
    {Application.exit 0}
end

you compile it with

$ ozc -c hello.oz

and then run it with

$ ozengine hello.ozf
like image 151
yakoudbz Avatar answered Mar 24 '23 22:03

yakoudbz