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

Evaluate argument to instant/atomic atomically, as a special case #2271

Merged
merged 5 commits into from
Jan 6, 2025

Conversation

byorgey
Copy link
Member

@byorgey byorgey commented Jan 6, 2025

Since Swarm is strict, the way an application instant c works is as follows:

  1. Evaluate the LHS instant to a value (immediately succeeds since it is just a constant)
  2. Evaluate the RHS c to a value
  3. Perform the function application instant c, by atomically executing the command represented by c

Usually, step (2) succeeds almost instantly as well. For example if c is something like move; move; turn right; move then it just instantly turns into a command value. However, c could be something like def x = (expensive pure expression) end; other stuff in which case evaluating c will cause the definition of x to be (expensively) evaluated.

This PR rectifies the situation by ensuring that not only are instant/atomic executed atomically, but also their argument is evaluated atomically. Fixes #2270.

@byorgey byorgey requested a review from kostmo January 6, 2025 02:41
@byorgey byorgey changed the title *Evaluate* argument to instant/atomic atomically, as a special case Evaluate argument to instant/atomic atomically, as a special case Jan 6, 2025
@byorgey byorgey added the merge me Trigger the merge process of the Pull request. label Jan 6, 2025
@mergify mergify bot merged commit 0ad3582 into main Jan 6, 2025
14 checks passed
@mergify mergify bot deleted the feature/instant-eval branch January 6, 2025 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

instant seems to have no effect when wrapped around definitions
2 participants