Article View: comp.lang.prolog
Article #2258Re: "Embedded Prolog" in C code
From: Ted Dunning
Date: Mon, 27 May 1991 16:00
Date: Mon, 27 May 1991 16:00
51 lines
2642 bytes
2642 bytes
In article <1991May26.231138.13000@brolga.cc.uq.oz.au> exnirad@brolga.cc.uq.oz.au (Nirad Sharma) writes: Is it possible to write Prolog progams and have them integrated into a c program ? yes, but ... see below. BTW, if anyone can suggest a similar system with, say, Lisp I'd be glad to know. also... same comments it is generally _MUCH_ easier (as in the supplier supports it) to embed c code into a running prolog program. there are number of reasons for this, chief of which is that the memory models of most prolog interpreters/runtimes is pretty involved and most programmers simply can't be trusted to set it all up correctly. on significant exception to this generalization is quintus prolog which allows the user bidirectional embedding, c in a prolog program, or prolog in a c program. the first is still much easier to make work. most commercial lisp implementations allow the former style of embedding of c code. if you have source, then you might be reasonably able to embed the other way. many publically available scheme (elk, and scm a prominent examples) interpreters allow full intercallability. you should consider the fact that embedding will almost always seriously compromise debugging of the embedded code. this is especially true of embedding c in a more advanced language. there are two reasonable outs for this, one is to start the higher level language from inside a c debugger (this assumes that you have unstripped executables or .o files) and then after loading your c-code into prolog (lisp) you break back to the debugger and set up breakpoints and such. the other reasonable solution is to implement some form of remote procedure call which would allow you to debug your prolog program and your c program with their native debuggers. an automatic generator of stubs and argument marshalling code is very helpful with this approach. -- Offer void except where prohibited by law.
Technical Details
Message-ID:
<TED.91May27100027@ithaka.nmsu.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!src.honeywell.com!msi.umn.edu!cs.umn.edu!ariel.unm.edu!nmsu!opus!tedReferences:
<1991May26.231138.13000@brolga.cc.uq.oz.au>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!src.honeywell.com!msi.umn.edu!cs.umn.edu!ariel.unm.edu!nmsu!opus!ted From: ted@nmsu.edu (Ted Dunning) Newsgroups: comp.lang.prolog,comp.lang.c,comp.sources.wanted Subject: Re: "Embedded Prolog" in C code Message-ID: <TED.91May27100027@ithaka.nmsu.edu> Date: 27 May 91 16:00:27 GMT References: <1991May26.231138.13000@brolga.cc.uq.oz.au> Sender: news@NMSU.Edu Followup-To: comp.lang.prolog Organization: Computing Research Lab Lines: 51 In-reply-to: exnirad@brolga.cc.uq.oz.au's message of 26 May 91 23:11:38 GMT