Fun fact: we've had pattern matching on 2.7 using MacroPy for a year now

class Nil():

class Cons(x, xs):

def reduce(op, my_list):
    with switch(my_list):
        if Cons(x, Nil()):
            return x
        elif Cons(x, xs):
            return op(x, reduce(op, xs))

On Tue, Apr 22, 2014 at 4:29 PM, Andrew Barnert <> wrote:
On Apr 22, 2014, at 15:20, Oleg Broytman <> wrote:

> On Tue, Apr 22, 2014 at 03:06:55PM -0700, Devin Jeanpierre <> wrote:
>> Why is it that every time someone brings up switch/case, they're being
>> inspired by C and Java instead of ML or Haskell?
>   How many people know imperative, procedural and OO languages? And how
> many know functional or logic-based languages?

I think most people know multi-paradigm languages. C++ has similar features, even if many of them are restricted to it's compile-time template engine. Most JavaScript programs are all about passing anonymous functions to higher-order functions as callbacks, of abstractions on top of that like futures. And so on.

Anyway, people don't have a problem learning map, any, comprehensions, unpacking, or other functional-derived features in Python even if they come from C; in fact, those features are often why they don't want to go back to C. The issue is always finding the right balance, borrowing features that fit into the language well and make code easier to read but not trying to encourage recursive folds over loops or rebuild I/O around monads or pure but nondeterministic functions.
Python-ideas mailing list
Code of Conduct: