-
Notifications
You must be signed in to change notification settings - Fork 134
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
Unexpected scope of cut in a If-Then construct #2739
Comments
Does it make sense to have a 'cut' in this position at all? Because: Or What I mean is this: |
From my perspective, reporting things like this is not much about the practical-coding sense, but about how can we be sure, that this problem is not a sign of some other problem with more practical consequences. |
@haijinSk Can you give us an example where 'if !' is false? |
@flexoron, I apologize if my tone here sounds offensive. I appreciate and admire your work in this project, and work of others as well. I don't know how a Prolog system should work in cases like this, I can only give examples of other Prolog systems, where the cut/! inside "If-then" in this position will not "preven[t] alternative solutions to calls before the cut being considered" (Lee Naish), as it prevents in the example and as it normally does/prevents (I have the Naish's words from the normal case), when the cut is not inside the "If-then-else" in this position. |
By definition @flexoron Regarding your question it might happen in more nefarious test cases like this one: ?- !, false -> write(a); write(b). What do you expect this query to produce? |
That, and also: Even if such code may currently occur rarely in practical examples, it may very well arise frequently by automated code generation, program transformations etc., so it is also important to correct in its own right. |
On the other hand I don't care on the spread of cut side-effects in this particular case, but at least it should be consistent as I've shown in first post. |
@hurufu Depends on the associativity and precedence of operators.
|
One more word... Even if Scryer were the only Prolog system in the world, I think, it can be seen as a plain erroneous behavior, because of the logical inconsistency: one behavior if the |
Recommendation:
|
@hurufu What do you expect here?
Ahh, sorry. You answered above already. see: once/1 :-) And thanks for pointing at this: (you're right).
|
Given the following test file:
This query seems to cut too many choice points:
I've expected it to succeed 2 times, but it succeeds only once.
On the other hand the query that must be equivalent behaves as expected:
The text was updated successfully, but these errors were encountered: