[Python-ideas] Fwd: Pattern Matching Syntax

Andrés Delfino adelfino at gmail.com
Sun May 13 11:17:17 EDT 2018


Is some sense, yes, but await isn't part of the "async def" structure.
await is just an independent statement, related to async def, yes, but
independent. My proposal links match with case/else statements as a single
flow control structure, and it writes them as such, like if/for/while/try.

My proposal didn't *require* a suite to be multi-line, it just allowed it.
I do see that it doesn't make sense for it to be multi-line, though.
Perhaps multi-line can be a SyntaxError?

I too think, like you, that this doesn't feel 100% pythonic either, but I
felt that it was... less unpythonic? that the proposals seen until now.

On Sat, May 12, 2018 at 3:03 PM, <steven at rigetti.com> wrote:

> In some sense async and await are like this group you describe, the
> keyword "await" doesn't have meaning outside a function annotated with
> "async".
>
> The issue I'd have with your proposal is that it requires the "suite" to
> be an expression-based multi-line statement, ie. where the last statement
> becomes the value that is matched against. Similar to the original proposal
> that started this thread: these sorts of expression-based constructs don't
> feel that natural for Python.
>
> On Saturday, May 12, 2018 at 2:50:49 PM UTC, Andrés Delfino wrote:
>>
>> I find it weird for case statements to be "inside" match statements.
>> There's isn't a statement "group" that works this way right now, AFAIK.
>>
>> This would also be weird:
>>
>> match X:
>> case Y:
>> ...
>>
>> I thought a form based on try would make more coherent:
>>
>> match:
>>     suite
>> case x:
>>     suite1
>> else:
>>     suite2
>>
>> suite would be executed, and the last expression would be checked against
>> each case. If no matching case is found, suite2 would be executed.
>>
>> Does it make sense?
>>
>> On Sat, May 12, 2018 at 8:51 AM, Steven Heidel <ste... at rigetti.com>
>> wrote:
>>
>>> Great! Also emailed you with logistics.
>>>
>>> On Sat, May 12, 2018, 01:43 Jelle Zijlstra <jelle.z... at gmail.com> wrote:
>>>
>>>> 2018-05-11 22:01 GMT-04:00 Robert Roskam <raider... at gmail.com>:
>>>>
>>>>> Hey Steven,
>>>>>
>>>>> I'm also at PyCon. Shall we take this off list and attempt to meet up
>>>>> and discuss?
>>>>>
>>>>> I'm also at PyCon and interested in meeting about this. I just wrote
>>>> up a basic and incomplete implementation for pattern-matching yesterday
>>>> between and after: talks: https://github.com/Jell
>>>> eZijlstra/cpython/blob/matchcase/Lib/test/test_matching.py. It's
>>>> nowhere near complete, but an implementation like this can help inform what
>>>> the syntax should look like.
>>>>
>>>> --
>>>>
>>>> ---
>>>> You received this message because you are subscribed to a topic in the
>>>> Google Groups "python-ideas" group.
>>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>>> pic/python-ideas/nqW2_-kKrNg/unsubscribe.
>>>> To unsubscribe from this group and all its topics, send an email to
>>>> python-ideas... at googlegroups.com.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>> _______________________________________________
>>>> Python-ideas mailing list
>>>> Python... at python.org
>>>> https://mail.python.org/mailman/listinfo/python-ideas
>>>> Code of Conduct: http://python.org/psf/codeofconduct/
>>>>
>>>> --
>>>>
>>>> ---
>>>> You received this message because you are subscribed to a topic in the
>>>> Google Groups "python-ideas" group.
>>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>>> pic/python-ideas/nqW2_-kKrNg/unsubscribe.
>>>> To unsubscribe from this group and all its topics, send an email to
>>>> python-ideas... at googlegroups.com.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> _______________________________________________
>>> Python-ideas mailing list
>>> Python... at python.org
>>> https://mail.python.org/mailman/listinfo/python-ideas
>>> Code of Conduct: http://python.org/psf/codeofconduct/
>>>
>>>
>>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180513/e8fe923f/attachment-0001.html>


More information about the Python-ideas mailing list