in reply to Re: Useful uses of redo?
in thread Useful uses of redo?
loop { # do something last if $done; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Useful uses of redo?
by BrowserUk (Patriarch) on Aug 27, 2004 at 09:04 UTC | |
Okay, we've traded a simple, extensible, easily used and self-documenting construct for YAKW and less self documenting code. I often use
Sometimes, when debugging I need to see what is going on, so I wrap the code and add some debug:
Once I'm done debugging, I can just comment out the print lines and I am back to where I was. In p6, I will have to completely change the coding of the single line with modifier version of the loop to an alien and less clear construct when I need to debug, and convert it back once I have the logic correct. Or leave as that strangly Fortran IV-ish form:
I know "LW is always right" and "LW is always right even when he is wrong", but on this I think he has never been more right. | [reply] [d/l] [select] |
by TimToady (Parson) on Aug 31, 2004 at 00:50 UTC | |
| [reply] [d/l] |
by BrowserUk (Patriarch) on Aug 31, 2004 at 01:53 UTC | |
Mea culpa. Actually, the example code I typed in doesn't make much sense in any case. I should have taken the time to produce a tested example. I wasn't trying to disprove anything, just commenting in keeping with the thread. However, perhaps I should state my objection more directly. The transition from test-before to test-after is (to my knowledge) unique with this combination of do BLOCK and while. In every other case, the modifier is evaluated before the statement that is modified. I understand (or at least I think I do), that this was done to provide for the pascal-style test-after loop construct. My problem with the decision to ban the while modifier on do blocks is that it is (IMO) the wrong way to fix the misconception that I so nicely fell into with my examples. I think that the misconception arises because in every other case, substituting a do block for a single statement has exactly the effect of grouping its contained statements that one expects. So, it's the special case that causes the problem. So rather removing what would otherwise be a useful construct, I'd prefer that the special case was removed. As the loop keyword has been designated, would it be too confusing to use ? Don't feel the need to debate this further. I missed (and haven't found despite having looked for the original decision point a couple of times), the arguments behind the decision, but I accept that you've probably given this much more thought than I, and you usually get these things right. I also fit in that camp of people that would like to use multiple statement modifers, but accept you have good reasons for your distaste for those also. | [reply] [d/l] |