[Python-ideas] Fwd: Pattern Matching Syntax

steven at rigetti.com steven at rigetti.com
Sat May 12 14:03:06 EDT 2018


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 
> <javascript:>> wrote:
>
>> Great! Also emailed you with logistics.
>>
>> On Sat, May 12, 2018, 01:43 Jelle Zijlstra <jelle.z... at gmail.com 
>> <javascript:>> wrote:
>>
>>> 2018-05-11 22:01 GMT-04:00 Robert Roskam <raider... at gmail.com 
>>> <javascript:>>:
>>>
>>>> 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/JelleZijlstra/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/topic/python-ideas/nqW2_-kKrNg/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> python-ideas... at googlegroups.com <javascript:>.
>>> For more options, visit https://groups.google.com/d/optout.
>>> _______________________________________________
>>> Python-ideas mailing list
>>> Python... at python.org <javascript:>
>>> 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/topic/python-ideas/nqW2_-kKrNg/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> python-ideas... at googlegroups.com <javascript:>.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> _______________________________________________
>> Python-ideas mailing list
>> Python... at python.org <javascript:>
>> 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/20180512/39d53e1f/attachment-0001.html>


More information about the Python-ideas mailing list