Executing Mozart-Oz code in command line

一曲冷凌霜 提交于 2019-12-03 13:49:23

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/29178072/executing-mozart-oz-code-in-command-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!