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

Rewrite the (while ..) macro. #23

Merged
merged 1 commit into from
Oct 9, 2022
Merged

Rewrite the (while ..) macro. #23

merged 1 commit into from
Oct 9, 2022

Conversation

skx
Copy link
Owner

@skx skx commented Oct 9, 2022

This now allows the use of an arbitrary body, as can be seen in the following test:

(set! p 4)

(while (<= p 10)
    (print "Pxx: %s" p)
    (set! p (+ p 1) true)
)

The new approach defines a local lambda, with a random name, and calls that recursively when the conditional is true.

This closes #21, though we still need to use the three-argument form of (set!) as our scoping/environment is confused - that is tracked in #22.

This now allows the use of an arbitrary body, as can be seen
in the following test:

```
(set! p 4)

(while (<= p 10)
    (print "Pxx: %s" p)
    (set! p (+ p 1) true)
)
```

The new approach defines a local lambda, with a random name, and
calls that recursively when the conditional is true.

This closes #21, though we still need to use the three-argument
form of (set!) as our scoping/environment is confused - that is
tracked in #22.
@skx skx self-assigned this Oct 9, 2022
@skx skx merged commit eb1d98c into master Oct 9, 2022
@skx skx deleted the 21-while branch October 9, 2022 15:35
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.

While function should allow arbitrary body
1 participant