在命令行中执行Mozart-Oz代码 [英] Executing Mozart-Oz code in command line

查看:125
本文介绍了在命令行中执行Mozart-Oz代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Mozart Oz . 我从源伪造下载执行二进制文件: http://sourceforge.net/projects/mozart-oz/.

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

启动Mozart.app时,emacs(Mac OS X中为aquamacs)开始在其中进行编码.

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

例如,我可以输入{Browse 'Hello World'}并执行Oz -> Feed Buffer在Tcl/Tk浏览器中获取结果.

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

然后,如何像在Python或Ruby中一样在命令行中构建或执行Oz代码?

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

我在bin目录中找到了二进制文件.

I found binaries in the bin directory.

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

但是,当我使用ozc -c hello.oz执行代码时,出现了%** variable Browse not introduced错误.可能是什么问题?

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

推荐答案

您必须使用Browser.browse

实际上,在以oz格式构建应用程序时,必须导入/创建每个功能.导入浏览器时,会获得一条记录,其中包含浏览器对象类导出的所有功能. (请参见 https://mozart.github.io/mozart -v1/doc-1.4.0/browser/node2.html )

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)

因此,您的代码是

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

我应该使用{Application.exit 0}退出应用程序,但这给了我一个奇怪的错误... 无论如何,我建议不要使用浏览器.即使在使用交互式解释器时功能非常强大,它也很笨重且有故障.改用System.showInfo,如果您真的想要一个,则构建自己的TK窗口.

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

您使用

$ ozc -c hello.oz

然后使用

$ ozengine hello.ozf

这篇关于在命令行中执行Mozart-Oz代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆