A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-April/052801.html below:

[Python-Dev] Re: switch statement

[Python-Dev] Re: switch statementMichael Walter michael.walter at gmail.com
Thu Apr 21 14:46:42 CEST 2005
On 4/21/05, Nick Coghlan <ncoghlan at gmail.com> wrote:
> Michael Chermside wrote:
> > Now the pattern matching is more interesting, but again, I'd need to
> > see a proposed syntax for Python before I could begin to consider it.
> > If I understand it properly, pattern matching in Haskell relies
> > primarily on Haskell's excellent typing system, which is absent in
> > Python.
> 
> There's no real need for special syntax in Python - an appropriate tuple
> subclass will do the trick quite nicely:

You are missing the more interesting part of pattern matching, namely
that it is used for deconstructing values/binding subvalues. Ex.:

case lalala of
  Foo f -> f
  Bar (Baz brzzzzz) _ meep -> (brzzzzz, meep)

or Python-ish:

match doThis() with:
  Foo as f: return f
  (_,* as bar,_): return bar
  Baz(boink as brzzz, meep=10): return brzzz

"* as bar" is Not Very Nice (tm) :/

Michael
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4