Porting Amzi prolog to ECLiPSe

While Amzi Prolog has the best debugger I’ve seen for any flavor of Prolog (and I’ve evaluated many flavors), it’s become clear that my project needs the ability to constrain variables before committing to particular values. This is the key feature difference that leads me to want to port to ECLiPSe, a flavor of Prolog where constraint propagation is the main focus. And there are other features of ECLiPSe that are very appealing:

  • Easily embedded in a Java application (via a jar that implements a JNI bridge to the native ECLiPSe executable) that allows for loose coupling through queues-and-listeners or even asynchronous queues.
  • Similar library support for manipulating terms, strings, lists, etc as other Prolog flavors
  • An Eclipse IDE plugin, Saros. (It’s not quite usable for me in its current stage but I hear a new version is imminent. And it has a Tk-based UI including debugger that’s pretty good.)

Here are the changes I had to make to my Amzi code so it would run in ECLiPSe:

  • Changed all calls using consult/1 or debug_consult to [...comma-separated filenames...]
  • Changed ‘/’ when used in predicate names to ‘_’
  • Changed import(list) to import(lists)
  • Changed all abolish calls to retractall (although this doesn’t seem absolutely necessary)
  • Changed string_term(String,Term) to term_string(Term,String)
  • Changed stringlist_concat calls to concat_string
  • Discovered that many of my variables were singletons, and changed them to start with ‘_’ (so they would be self-documenting singletons and not trigger a compiler warning)
  • Added dynamic declarations for all my dynamic predicates (Amzi probably doesn’t provide a warning when these are asserted or retracted without having been so declared)
  • Changed my (retractall(predicate(_,...)) ; true) pattern to just retractall(predicate(_,...)), since retractall never fails in ECLiPSe

I’m grateful to Dennis Merrit and Chip Eastman of Amzi for all their help in getting my initial Amzi app working, and for their excellent documentation of Prolog and Building Expert Systems.

Print Friendly, PDF & Email