Re: Preserving query data in foreign interface
Paul Singleton <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Organization | Jambusters Ltd |
| Message-ID | <[email protected]> |
On 11/08/2013 11:39, Abramo Bagnara wrote: > I'm calling from Java a Prolog query and I need to avoid that returned > data is lost. The "high level" interface does that for you > I'm using low-level interface to avoid term_t <-> Term copying and the > very deep stack recursion that this implies when handling long lists. Then you'll have to implement your own non-recursive term_t <-> Term copying - please donate this to JPL :-) > If I use Prolog.close_query the binding is lost and we have no > Prolog.cut_query available. Hmm, if your hypothetical Prolog.cut_query retains the binding, then we can't reuse the engine until you explicitly close it; I don't think this is the way to go... > That apart, I also have noted that in both java interface and C > interface it is missing an helper to do deep copy of answers so to > preserve multiple results of nondet queries. JPL has this; Query#allSolutions returns an array of maps from variable names to copied bindings > I've missing something? There are other ways to do what above? Until term_t <-> Term copying is reimplemented non-recursively (or otherwise ingeniously), the best workaround for copying long lists is to use a Prolog-side wrapper for long-list-returning predicates which converts them to trees (or atoms?), then convert them again Java-side. Paul Singleton