Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'syntax': 0.04; 'explicitly': 0.05; 'matches': 0.07; 'contexts': 0.09; 'here?': 0.09; '(1,': 0.16; '3:51': 0.16; 'assignment.': 0.16; 'clauses': 0.16; 'propose:': 0.16; 'subject:Case': 0.16; 'wrote:': 0.18; 'do.': 0.18; '>>>': 0.22; '>>>': 0.24; '>': 0.26; 'first,': 0.26; 'switch': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'second,': 0.31; 'bugs': 0.33; 'problem': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'doing': 0.36; 'next': 0.36; 'wrong': 0.37; 'skip:& 10': 0.38; 'to:addr:python- list': 0.38; 'skip:& 20': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'expression': 0.60; 'solve': 0.60; 'first': 0.61; 'more': 0.64; 'natural': 0.68; 'day': 0.76; 'subject:Proposal': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Z5nPu5/1NJy2hxEJhQmYUo1heZ6f1kDFMkLyAy8+Z8c=; b=BGuc9F/I1GlMLN2zLWQWQrfTOfw/DF4pXfpAqt7/QL3XgFAba1hk6wVQLORffG/BWm etSStI/E31w01Ww8df32PmJWyNlD08xhy+eh0GmPyPkFpH/Ew8w/OTCwIyR1tQLw56sO D/pdDFYBjVP1GqZSBOe4OwoEfx5V9CL8wh0z8Hgj6656B88ggBOrjKBsNyuEFSEOSaD8 Hee1gZCzlEtP/wGw41/aotLtzf29vF3cH9J1ZWxu1jJ5v2lGgg2+abdeNwS48eF1G1Yh Rbw1cmf+QW9NAgGTwckZoAD6oFd3bECLSVQbIj2BJns0eAYEJnHq5N6Knn7CmGwlS04b uaUg== MIME-Version: 1.0 X-Received: by 10.66.240.70 with SMTP id vy6mr15880491pac.80.1396627341568; Fri, 04 Apr 2014 09:02:21 -0700 (PDT) In-Reply-To: <87ioqpqvef.fsf@elektro.pacujo.net> References: <8084-1396540962-768613@sneakemail.com> <533e6e58$0$29993$c3e8da3$5496439d@news.astraweb.com> <87ioqpqvef.fsf@elektro.pacujo.net> Date: Fri, 4 Apr 2014 10:02:21 -0600 Subject: Re: Yet Another Switch-Case Syntax Proposal From: Ian Kelly To: Python Content-Type: multipart/alternative; boundary=047d7b15aba993edcb04f639a45d X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 73 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1396627349 news.xs4all.nl 2936 [2001:888:2000:d::a6]:41531 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69671 --047d7b15aba993edcb04f639a45d Content-Type: text/plain; charset=ISO-8859-1 On Apr 4, 2014 3:51 AM, "Marko Rauhamaa" wrote: > > >>> switch day casein ("Monday", "Thursday", "Wednesday", "Tuesday", > >>> "Friday"): > >>> gotowork = True > >>> continue > >>> casein ("Monday", "Thursday", "Wednesday", "Tuesday", "Friday"): > >>> daytype = "ferial" > >>> casein ("Saturday", "Sunday") > >>> daytype = "festive" > > That "casein" next to "switch" bugs me. Did I already propose: > > switch: local_sabbath() > case (1, 2, 3) as sabbath: > ... > case 6: > ... > else: > ... I don't get what this is intended to do. First, why is the expression in the first line after the colon? That doesn't match any existing block syntax (as you note it matches lambda, but that's an expression-level syntax). What's wrong with the much more natural "switch local_sabbath():"? Second, "as" clauses are used in other contexts for local assignment. What is the purpose of doing that here? How does this solve the problem of explicitly denoting case multiplicity? --047d7b15aba993edcb04f639a45d Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


On Apr 4, 2014 3:51 AM, "Marko Rauhamaa" <marko@pacujo.net> wrote:
>
> >>> switch day casein ("Monday", "Thursday&quo= t;, "Wednesday", "Tuesday",
> >>> "Friday"):
> >>> =A0 =A0 =A0gotowork =3D True
> >>> =A0 =A0 =A0continue
> >>> casein ("Monday", "Thursday", "W= ednesday", "Tuesday", "Friday"):
> >>> =A0 =A0 =A0daytype =3D "ferial"
> >>> casein ("Saturday", "Sunday")
> >>> =A0 =A0 =A0daytype =3D "festive"
>
> That "casein" next to "switch" bugs me. Did I alre= ady propose:
>
> =A0 =A0switch: local_sabbath()
> =A0 =A0case (1, 2, 3) as sabbath:
> =A0 =A0 =A0 =A0...
> =A0 =A0case 6:
> =A0 =A0 =A0 =A0...
> =A0 =A0else:
> =A0 =A0 =A0 =A0...

I don't get what this is intended to do. First, why is t= he expression in the first line after the colon? That doesn't match any= existing block syntax (as you note it matches lambda, but that's an ex= pression-level syntax). What's wrong with the much more natural "s= witch local_sabbath():"?

Second, "as" clauses are used in other contexts fo= r local assignment. What is the purpose of doing that here? How does this s= olve the problem of explicitly denoting case multiplicity?

--047d7b15aba993edcb04f639a45d--