Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Perl6 Loop Constructs (perl.org)
25 points by someone_here on July 12, 2010 | hide | past | favorite | 11 comments


This kind of stuff is why I love Perl. I just wish I still had an excuse to use it on a daily basis...


The "repeat while EXPR { ... }" seems kinda goofy that it still evaluates after the loop runs once.


I 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.


The difference isn't more subtle than the difference between $x + $y and $x - $y.


Not 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.


I 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.


It 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).


I 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.


Except 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.


On the plus side, since Perl 6's spec is not set in stone; goofy things like that can still be gotten rid of.


Yes; 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: