Case Statements

Marko Rauhamaa marko at pacujo.net
Wed Mar 16 08:21:09 EDT 2016


BartC <bc at freeuk.com>:

> On 16/03/2016 11:07, Mark Lawrence wrote:
>> but I still very much doubt we'll be adding a switch statement --
>> it's a "sexy" language design issue
>
> That's the first time I've heard a language feature common in C
> described as sexy.

Scheme has a "switch" statement (a "case" form). However, it is slightly
better equipped for it than Python:

 * Scheme has an atom type ("symbol"). It corresponds to interned
   strings and is supposed to be compared by reference.

 * Scheme has defined three equality operators: "eq?", "eqv?" and
   "equal?". Python only has two: "is" (~ "eq?") and "==" (~ "equal?").
   The "case" form makes use of the operator "eqv?" that is missing from
   Python ("eqv?" compares numbers numerically but is otherwise the same
   as "eq?").


Marko



More information about the Python-list mailing list