tau-prolog
tau-prolog copied to clipboard
Documentation request: How indicate end of querying?
Disclaimer: Might have overlooked some existing docu.
The general template to use TauProlog seems to be:
// Consult
session.consult(program, {
success: function() {
// Query
session.query(goal, {
success: function(goal) {
// Answers
session.answer({
success: function(answer) { /* Answer */ },
error: function(err) { /* Uncaught error */ },
fail: function() { /* Fail */ },
limit: function() { /* Limit exceeded */ }
})
},
error: function(err) { /* Error parsing goal */ }
});
},
error: function(err) { /* Error parsing program */ }
});
Whats the recommended way to indicate that no more answers are requested?
Does the answer hook need to throw an exception or return false?
The answer
method just looks for the next answer. If you need more than one answer, you must call answer
again in the callback of the first answer. So if you don't need any more answers, you don't have to do anything.