tau-prolog icon indicating copy to clipboard operation
tau-prolog copied to clipboard

Documentation request: How indicate end of querying?

Open ghost opened this issue 3 years ago • 1 comments

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?

ghost avatar May 17 '21 09:05 ghost

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.

jariazavalverde avatar May 17 '21 10:05 jariazavalverde