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

Add 'concrete?' function #183

Closed
wants to merge 1 commit into from
Closed

Add 'concrete?' function #183

wants to merge 1 commit into from

Conversation

anishathalye
Copy link
Contributor

I think this is a useful function for symbolic reflection. It gives the same results as (empty? (symbolics _)), but it's more efficient because it returns as soon as it finds an expression or union. The pattern arose frequently enough in my code that this was a useful optimization.

This is a draft PR; if you think this would be a useful addition, I can add tests/docs.

@emina
Copy link
Owner

emina commented Mar 2, 2021

Adding concrete? is a good idea.

It's a bit tricky to implement though. For example, this implementation will run forever in the presence of cycles:

(define b (box 0))
(set-box! b b)
(concrete? b)

The current implementation of symbolics avoids the issue with cycles, but it has other inefficiencies. These are fixed in the new version of Rosette that will be released soon :) I'll add a concrete? function to the new version!

@emina emina closed this Mar 2, 2021
@anishathalye
Copy link
Contributor Author

Thank you!

emina added a commit that referenced this pull request Mar 12, 2021
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.

2 participants