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

Implement a 'repeat while' macro #160

Open
masak opened this issue Jul 14, 2016 · 3 comments
Open

Implement a 'repeat while' macro #160

masak opened this issue Jul 14, 2016 · 3 comments

Comments

@masak
Copy link
Owner

masak commented Jul 14, 2016

The repeat while loop from Perl 6 comes in two flavors:

repeat {
    # ...
} while some_condition();

repeat while some_condition() {
    # ...
}

These both have the same semantics (evaluate the condition after each iteration, not before), but they also don't fall under #80, and so they would seem to require some sort of is parsed functionality.

@masak
Copy link
Owner Author

masak commented Oct 5, 2017

Hm. I wonder if the following use case doesn't indeed push my from being a statement form (like in Python) to being a term (like in Perl 6):

repeat while !valid_command(my command = prompt("> ")) {
    say("Please input a command: ");
}
# do something reasonable with `command`

I hesitate to complicate the language needlessly, but this arguably mostly moves complexity around. Arguably #199 wouldn't survive such a change, though. (Or would it? Could a multiple-variable my co-exist on the statement level with a single-variable my on the term level? At the very least, it'd introduce some degree of grammar ambiguity.)

@masak
Copy link
Owner Author

masak commented Jul 2, 2018

Coming back and reading the previous comment more than half a year later, and especially in the face of #279 (seemingly) taking us the other direction, I don't see how just declaring my command; on top of the loop is that arduous. The variable is meant to be used after the loop anyway, so why not just declare it visibly above the loop?

@masak
Copy link
Owner Author

masak commented Jul 2, 2018

What I really came in here to say is that we should make sure that repeat while works fine with next and last from #325. Which, yes, implies that we have some control flow protocol à la #145.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant