-
Notifications
You must be signed in to change notification settings - Fork 67
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
Break in while/for #11
Comments
Hi, for, while, and if are now quite stable, at least we didn't receive bug reports related to them. unfortunately, there is no break. Thinking on that, I guess we could explore the idea of "cut" (symbol ! in Prolog) to implement it. Since these loops are a kind of backtracking on all solutions of a query, to "cut" the backtracking seems natural. We also miss the "cut" in the rules part of Jason.... It is certainly a good improvement for new versions of Jason. |
Note however that in some cases, the logical programming can handle that. For instance, the code
can be recoded as
|
Would the recoded |
Hi, I am not sure I've got the details of the question... but the semantics is: if there is a solution for the query, run the block. To find the solution for the query, jason backtracks all possibilities (sequentially and lazily). Since .member has 5 possible answers for X, it tries the first, checks hasProperties(X), if ok, the query is finished. Otherwise, the second answer for X is considered... and so on. If no answer for X succeeds, the query fails. |
Then the answer is yes. Thanks for the infomations. For me this issue is closed, but I'll leave the decision to you whether to close it or leave it open as a reminder for |
As title says, is there a way to break from
while
andfor
in Jason?Also, it is reported here that these feature are experimental. As of version 2.2, it safe to use them, or it's better to use plan recursion?
The text was updated successfully, but these errors were encountered: