[Python-Dev] switch-based programming in Python

Greg Ewing greg@cosc.canterbury.ac.nz
Mon, 19 Nov 2001 18:14:28 +1300 (NZDT)


Paul Svensson <paul@svensson.org>:

> Yes, it should work exactly like the loops do;
> The `else' clause is entered when the (explicit or implicit) test
> of the main statement fails.

Then I misunderstood you, which I think illustrates exactly
why trying to make any analogy at all with loops is a bad
idea -- different people will make the analogy in different
ways. My way of making the analogy would have had the "else"
clause always executing in addition to one of the cases,
unless a "break" was executed!

If and switch statements are not loops, and trying to
pretend they are would be confusing and error-prone,
IMO.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+