Executing Mozart-Oz code in command line
Asked Answered
C

1

5

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?

Caine answered 21/3, 2015 at 1:2 Comment(0)
U
9

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
Uzzi answered 23/3, 2015 at 9:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.