Skip to content
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

make amb-collect reliable #531

Merged
merged 3 commits into from
Jun 2, 2020
Merged

make amb-collect reliable #531

merged 3 commits into from
Jun 2, 2020

Conversation

vyzo
Copy link
Collaborator

@vyzo vyzo commented Jun 2, 2020

This would sometimes fail, because the required clause is be outside the collect scope:

(begin-amb-random (let (x (amb 0 1 2)) (required (not (= 0 x))) (all-of x)))

This fixes the issue by introducing a parameter that prescribes the behaviour of amb-fail; when set, it is a thunk that continues at the end of the collection; otherwise it just raises.

Note that we have completely deviated from the original chicken egg that served as inspiration at this point; there, all-off is a scope construct (not really, but almost because it uses mutation of global variables and it's also completely undocumented) that collects from ambs within the expression context.
In the Gerbil implementation, all-of just appears within an amb scope to perform a collect+cut.

cc @eraserhd

@vyzo vyzo merged commit e57f2cb into master Jun 2, 2020
@vyzo vyzo deleted the fix-amb-collect branch June 2, 2020 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant