The challenge here is that several things can get returned: true([with answers])
, false
, or an exception()
. It seemed to me that keeping a consistent model where the result on the Prolog side is a single term that gets converted into Prolog using the standard serialization simplified understanding of the protocol and made handling of the responses on the language library side easier.
It also doesn’t feel too onerous on the Python side, for example. Here’s my library code that converts the true()
answers into a form that is more like what I think you’re suggesting.
answerList = []
for answer in prolog_args(jsonResult)[0]:
if len(answer) == 0:
answerList.append(True)
else:
answerDict = {}
for answerAssignment in answer:
# These will all be =(Variable, Term) terms
answerDict[prolog_args(answerAssignment)[0]] = prolog_args(
answerAssignment
)[1]
answerList.append(answerDict)