Executing prolog code on an iPhone

后端 未结 5 1467
感动是毒
感动是毒 2021-02-04 04:46

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 i

相关标签:
5条回答
  • 2021-02-04 04:59

    Having faced similar difficulties calling prolog code, albeit in a different situation, I'd recommend checking out the castor c++ library. This allows you to write logic paradigm code in native c++ without needing to extend the language at all. As castor is a header only library it is easy to compile wherever c++ is available.
    Castor website: http://www.mpprogramming.com/cpp/default.aspx

    0 讨论(0)
  • 2021-02-04 05:01

    You can download SWI-Prolog's source code and compile it with XCODE for iOS platform. I've never done that, but it's certainly technically possible.

    Once you do that, there are a lot of examples on how to run prolog code from C/C++, hence, you will be able to run prolog from Objective-C.

    0 讨论(0)
  • 2021-02-04 05:06

    I do not know if this has been tried but there is the possibility to use the combination of NodeJS for Mobile Apps & TauProlog:

    • https://code.janeasystems.com/nodejs-mobile
    • https://github.com/JaneaSystems/nodejs-mobile

    enter image description here

    and

    • http://tau-prolog.org/

    enter image description here

    0 讨论(0)
  • 2021-02-04 05:08

    FYI, you can quite easily bi-directionally make calls between Java and SWI-Prolog if you use JPL:

    http://www.swi-prolog.org/packages/jpl/

    It is also fully re-entrant, so you can instantiate prolog code from java, which in turn instantiates java code etc...

    I did this for a number of commercial projects a few years ago when I was required to connect a Prolog based Reasoning Engine to a lot of Java code.

    It does use JNI (the Java Native Interface), so you need to be careful about how you compile and link to the native api. Though if you compile it appropriately for each platform you can make it work cross platform. I had it working on OS-X, Windows, Linux & Solaris.

    0 讨论(0)
  • 2021-02-04 05:09

    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.

    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.

    0 讨论(0)
提交回复
热议问题