在iPhone上执行prolog代码 [英] Executing prolog code on an iPhone

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

问题描述

我目前需要在我正在制作的应用程序中执行prolog代码。我知道Apple可能永远不会在App Store中允许这样的东西,但这也不是意图。这是一个永远不会到达App Store的私人项目。

I currently have the need to execute prolog code in an application I am making. I am aware that Apple probably never would allow something like this in the App Store, but that is not the intention either. This is more a private project that will never reach the App Store.

目的

在这种情况下,prolog用于描述对象(例如电话)及其属性。将使用prolog脚本中指定的坐标使用OpenGL绘制对象。使用prolog的原因是我需要能够向程序查询该对象具有的一些功能,并且对此进行了大量修改。结论:我需要从我的应用程序查询prolog脚本。

In this case prolog is used to describe an object (like for example a telephone) and its properties. The object will be drawn with OpenGL using coordinates specified in the prolog script. The reason for using prolog is that I need the ability to query the program about some of the features this object has, and prolog eases this a lot. Bottom line: I "need" to query a prolog script from my app.

可能的解决方案


  • 嵌入用C编写的现有实现。我不确定这是否可行。

  • 在另一台机器上执行prolog代码并使用查询prolog的网络。

  • 似乎可以在应用程序内部运行某种Ruby VM(据我所知shinycocos使用它),这可能用于运行一个Ruby Prolog的实现?

  • 找一些Prolog的替代品。这需要给我一些与prolog相同的可能性。

  • Embed an already existing implementation written in C. I am unsure if this will even work.
  • Execute the prolog code on another machine and use the network to query prolog.
  • It seems that it is possible to run some sort Ruby VM inside the app (shinycocos uses this as far as I understand), could this be used to run one of the Ruby Prolog implementations?
  • Find some alternative to Prolog. This needs to give me some of the same possibilities I get with prolog.

可悲的是,谷歌让我几乎没有任何结果,所以我觉得我可能在这个项目上很孤单。如果有人有任何经验或线索,我会非常感激。

Sadly, google gives me close to no results at all, so I have a feeling that I might be quite alone on this project. If anyone have any experience or clue at all, I would be very thankful.

推荐答案

半年后,我想要提供一些有关这方面的见解。我最终用Java编写了一个带prolog接口的服务器,通过TCP接受prolog调用。它的工作方式几乎与现场prolog解释器SWI-prolog(以及其他)提供的一样,并且大部分工作得很好。但是,它远非最佳解决方案,因为您无法从prolog内部调用函数。你失去了进行双向沟通的可能性。

Half a year later, I would just like to provide some insight on this. I ended up writing a server with an interface to prolog in Java, accepting prolog calls through TCP. It works almost exactly like the live prolog interpreter SWI-prolog (among others) provides, and mostly works quite well. However, it is far from an optimal solution, as you can't call functions from inside prolog. You lose the possibility of having two-way communication.

如果我要重新开始,我当然会更努力地编译一个纯C实现iOS版。我给了它一个快速的去,但我缺乏经验阻止我甚至删除我得到的所有错误。从你不能在未经修改的iOS版本上作为后台进程运行的事实判断,必须进行一些重大的重写。因此,人们可能只需要从头开始编写一个新的实现(可能受到一些更轻量级的实现的启发)以获得完美的解决方案。

If I were to start all over again, I would certainly have tried harder to compile one of the pure C implementations for iOS. I gave it a quick go, but my lack of experience stopped me from even removing all of the errors I got. Judging by the fact that you cannot have prolog running as a background process on a unmodified version of iOS as well, some major rewriting would have to be done. Because of this, one might just have to write a new implementation (perhaps inspired by some of the more lightweight ones out there) from scratch to get the perfect solution.

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

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