-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add session.query_all #116
base: master
Are you sure you want to change the base?
Conversation
Wow! I only have a small question about the name: Would |
Hi @gilbert. First of all, thank you very much for your PR. Tau Prolog already has a function that fetches all solutions for a given query:
I think it is important to separate all these aspects that you provide in your |
Thanks for the response! I don't know how I missed
|
The problem appears when
Ok, it's a good idea!
Agree. I'll think of another name. Suggestions? |
I'm running into a use case issue with phase(round(1, vote)). If I query for it like However, my application needs the full data within On further thought, I might be able to use a list instead. But is it ideal to have to change my data structures to get around this limitation? |
I could extend |
Allowing both might be good, but we should probably discuss a default. I would think having data as the default makes sense. If one wanted a string representation, couldn't there be a predicate for that? e.g. |
I would prefer to keep the default string option for compatibility reasons. |
By compatibility, do you mean with some part of the ISO standard? |
No. Compatibility with old versions of Tau Prolog. |
Version numbers can take care of this, and Tau is not 1.x yet. If there is a better alternative, now is the best time to consider it. I will create a new issue for this topic since it's separate from this PR. |
First off, let me know if you'd like me to change anything. I am very willing to work within the needs of the project.
Motivated by #111 and access patterns for my own project, this PR adds a
session.query_all
method that fetches all solutions for a given query. For example:Notice the tagged template syntax. This allows Tau to intercept and escape values interpolated by the user:
In this example, Tau escapes three values for this query. One being the
end
list, and the other two being its members. This is especially useful for strings with spaces, such as thean end
string in our example; the user does not need to worry about wrapping anything in quotes.Note that for queries with no variables,
query_all
will return an empty object for every found solution.Big thanks to @jlturner for writing the original
answer_obj
function.