in reply to Re^2: GOTO or not GOTO
in thread GOTO or not GOTO
So here's the next example, what does the following do:
for ( my $i = 0; $i < 10; $i++ ) { my $j = $i; if ( $i == 5 ) { goto nextpoint; } } for ( my $k = 0; $k < 10; $k++ ) { my $m = $k; nextpoint: print( "$m\n" ); }
Well I tried it, but the point is I didn't know what it would do before hand. If that is "bragging one's ignorance" then so be it. Rightly or wrongly I came from a C background where if you tried risky behaviour like this you got into real trouble. Perl is far more forgiving.
I do prefer to program in a manner that has a degree of portability between languages; as I said before, goto is risky: if you consider yourself an expert in the language at the time and the compiler behaviour and implications (if any) to the stack then by all means go ahead. I'll stick to what I know is safe.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: GOTO or not GOTO
by JavaFan (Canon) on Jan 27, 2009 at 12:37 UTC |