-
Notifications
You must be signed in to change notification settings - Fork 142
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
MultiPatterns #168
MultiPatterns #168
Conversation
In the right hand side, I think I can only express equality to a variable bound in the lhs. In the Applier impl for MultiPattern, I would think one should allow creating new bindings only in the |
let mut added = vec![]; | ||
for mat in matches { | ||
for subst in &mat.substs { | ||
let mut subst = subst.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unfortunate clone, but I don't see an elegant way around it without changing interface of matches to be &mut
or something.
This was merged, but I guess the fast-forward make github not see it. |
Multipatterns are multiple possibly disjoint patterns to seek out in a search process. They are distinct from guards in that they may bind new variables. This pull request attempts to implement somewhat efficient multipatterns in a backwards compatible way.
The pattern compiler can remain mostly as is. Compiler state about what patterns are where in the subst map needs to be retained between each single pattern compilation.
Multipatterns require changes to the abstract machine because scanning for roots of the 2nd pattern onwards becomes required.
Extending the interface to be able to give pattern names to the root of the pattern itself enables significant extra modelling power. Note that labelled multipatterns allows one to implement efficient manual scheduling of search even for single patterns via flattening or breaking the pattern trees up.
This PR is still a work in progress, but examples can be found in the
datalog.rs
test. The syntax for creating multipatterns might change, but it looks this currently:Closes #39