4 ms·
Perl6 Loop Constructs
- protomyth 16y agoThe "repeat while EXPR { ... }" seems kinda goofy that it still evaluates after the loop runs once.
- ekiru 16y agoOn the plus side, since Perl 6's spec is not set in stone; goofy things like that can still be gotten rid of.
- masak 16y agoYes; just go to the #perl6 channel on freenode, request a commit bit, and edit it out of the spec. For this particular change though, I think you will meet a bit of resistance. Many people might agree that the feature is goofy, but few will probably agree that it's bad and should be gotten rid of.
- baddox 16y agoI don't think so. The first evaluation of the body is a given, the "repeat" means to do it more times while the EXPR is true.
- protomyth 16y agoIt just seems like "repeat while EXPR { ... }" would check EXPR before the loop and the other order "repeat { ... } while EXPR" would check check the EXPR after each loop. Not a big deal, but just kinda goofy (as in ordering doesn't mean evaluation ordering).
- baddox 16y agoI disagree. The truth value of the EXPR determines whether you repeat, meaning do an additional time. I agree that it may not be the immediate interpretation, but I think the vocabulary makes sense.
- astine 16y agoExcept that 'repeat' in English doesn't always mean to do something an additional time. For example, "Repeat this task three times," means to do a task three times, not four, unless specified by the context.
- someone_here 16y agoNot if you think of it as "do this but repeat while EXPR" EDIT: Perhaps renaming it to "again while EXPR { ... }" would be a better option.
- wvenable 16y agoI agree, only because the difference is pretty subtle: while EXPR { ... } repeat while EXPR { ... } This does two different things and the word "repeat" doesn't really imply the difference in semantics.
- masak 16y agoThe difference isn't more subtle than the difference between $x + $y and $x - $y.
- Finster 16y agoThis kind of stuff is why I love Perl. I just wish I still had an excuse to use it on a daily basis...