Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #69785

Re: Yet Another Switch-Case Syntax Proposal

References <8084-1396540962-768613@sneakemail.com> <CALwzidmw0QbUbNw5PvwmHh+4ghguUhpEnY8TbBZYYyjZkpLBsw@mail.gmail.com> <CABbU2U8fcwZYBuDA6JNOdWgwkNaTWiPvCnR1Be4wCvF0vecU1g@mail.gmail.com> <CAPTjJmqjDL8+pNGv6pBhkh6LGzBAGmYghNQXzf8X=k_q0L=h7A@mail.gmail.com> <5341B56A.40004@gmail.com>
Date 2014-04-07 09:16 +1000
Subject Re: Yet Another Switch-Case Syntax Proposal
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.8965.1396826189.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Apr 7, 2014 at 6:13 AM, Michael Torrie <torriem@gmail.com> wrote:
> On 04/06/2014 12:07 PM, Chris Angelico wrote:
>> This has a slight oddity of parsing (in that an expression can
>> normally have a comparison in it); if you really want to use the
>> result of a comparison inside a case block, you'd have to parenthesize
>> it. But it's easy enough to explain to a human.
>
> This syntax is almost identical to the if/elif/else syntax, though, no?

Like I said, it's a short-hand for an if/elif tree, nothing more. Most
of the proposals have effectively been that anyway. There are
differences, though; the case target gets evaluated only once, for
instance. I'm not pushing strongly for its addition to the language.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Yet Another Switch-Case Syntax Proposal Chris Angelico <rosuav@gmail.com> - 2014-04-07 09:16 +1000

csiph-web