On Wed, May 01, 2002 at 09:03:42AM -0500, Jonathan Scott Duff wrote:
> 
> Hmm.  I wonder why the python community (apparently) have no problems
> with elses on loops:
> 
>         7.2 The while statement
> 
>       The while statement is used for repeated execution as long as an
>       expression is true: 
>       
>       while_stmt ::= "while" expression ":" suite
>                       ["else" ":" suite]
> 
> That's straight from http://www.python.org/doc/current/ref/while.html.
> If you read the page though, you'll see that their meaning isn't
> dwimmery at all. The else block is executed whenever the expression
> evaluates to false which could be if there's nothing to iterate over
> or just after the last iteration.

If you abstract the meaning of C<else> to "execute when the condition in
the previous block is false" this makes perfect sense. It's just not
very useful. This is actually a good reason for Perl to use a different
keyword than "else" with loops. You avoid that interpretation entirely.
You also avoid totally annoying Pythonists who occasionally use (and
might be converted to) Perl. :)

Allison

Reply via email to