in reply to Re^2: GOTO or not GOTO
in thread GOTO or not GOTO

You don't say why you find the goto version more attractive. I guess because of the separate declaration and initialization of $status. However:

my $status; do { $status = getstore (ask_url (), $file); } while $status == 200 && !-s $file && --$max_tries > 0;

makes it clear that there is a loop involved and what the conditions on the loop are. Having $status declared outside the loop makes it clear that $status is required after the loop has terminated.


Perl's payment curve coincides with its learning curve.

Replies are listed 'Best First'.
Re^4: GOTO or not GOTO
by JavaFan (Canon) on Jan 27, 2009 at 22:17 UTC
    But that suggests the loop is "normal". It isn't. Repeating a piece of the code is the exception - it may be repeated once every couple of thousand of times. Normal program flow just goes top to bottom. Using a rare construct (goto) signifies that. Using a regular loop doesn't.

    And I prefer not to have a separate declaration and initilization. But that only plays a part in the decision.