views:

106

answers:

2

Hello,

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.

Purpose

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.

Possible solutions

  • 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.

+2  A: 

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.

Pablo Santa Cruz
I gave it an honest try, but sadly my knowledge about C, C++ and compilation without an IDE is limited, if not non existing. I ended up implementing a network solution with sockets and a server acting as a knowledge base instead.
Bendik
Awesome Bendik. Glad you solved your issue.
Pablo Santa Cruz
+1  A: 

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

shuttle87
Although it sounds like a good solution, my supervisor sadly would not accept it. We already have a large knowledge base in prolog, and porting it would take too much time.
Bendik