[LOGIC-129] matcha/matchu are not faithful to the semantics of conda/condu Created: 04/Apr/13 Updated: 09/Jun/13
|Reporter:||Austin Haas||Assignee:||David Nolen|
The semantics of conda and condu give special importance to the head of each clause, but the pattern matching macros in core.logic that are built on top of them merge the body into the head. That means that every expression in a body position is considered when deciding which line is chosen, rather than just the expression in the head position. This is because the entire clause is wrapped in a fresh expression to bind the implicitly specified lvars that appear in the pattern.
Ideally, we could devise a new system to marry the semantics of conda with pattern matching. At the very least, I think the offending macros should carry a warning in their docstring, stating this semantic difference.
I suspect this would also cause the "Third Commandment" warning to apply to the entire line, rather than just the head/question, but I have not investigated that issue.
Here's an example that demonstrates the difference in meaning:
|Comment by Austin Haas [ 04/Apr/13 2:35 PM ]|
From The Reasoned Schemer.
|Comment by David Nolen [ 04/Apr/13 5:16 PM ]|
Good catch I need to think about this one.
|Comment by David Nolen [ 09/Jun/13 12:11 PM ]|
The issue is that we rely on the `conde` macro which isn't very flexible. We should probably do something one step lower so can wrap each conde line in a `let` that constructs the logic vars and then ensure that all the head unifications are wrapped in one `fresh` so that the semantics of conda/u are preserved.