On Fri, 30 Oct 2020 at 18:30, Mark Shannon <m...@hotpy.org> wrote:
>
> Hi Brandt,
>
> On 30/10/2020 4:09 pm, Brandt Bucher wrote:
> >> Can we discuss whether we want pattern matching in Python and the broader 
> >> semantics first, before dealing with low level details?
> >
> > This is a huge step backward. These discussions have already taken place, 
> > over the last 10 years.
>
> So what you are saying is that I'm not allowed to voice my opinions,
> because it is outside a time frame of your choosing?

I certainly wouldn't say that, but I do think that if you're not
taking into account the extended history of ideas and of people
expressing a desire for some kind of pattern matching in Python, then
you shouldn't be surprised if people consider your objections
insufficiently well-informed.

> >
> > Here's just a sampling:
> >
> > - 
> > https://mail.python.org/archives/list/python-id...@python.org/thread/IEJFUSFC5GBDKFIPCAGS7JYXV5WGVAXP/
> > - 
> > https://mail.python.org/archives/list/python-id...@python.org/thread/GTRRJHUG4W2LXGDH4AU46SI3DLWXJF6A/
> > - 
> > https://mail.python.org/archives/list/python-id...@python.org/thread/EURSG3MYEFHXDDL2474PQNQZFJ3CUIOX/
> > - 
> > https://mail.python.org/archives/list/python-id...@python.org/thread/NTQEL3HRUJMULQYI6RDBTXQ2H3KHBBRO/
> > - 
> > https://mail.python.org/archives/list/python-id...@python.org/thread/NEC54II2RB3JRGHDP6PX3NOEALRAK6BV/
> > - 
> > https://mail.python.org/archives/list/python-id...@python.org/thread/T3VBUFECTLZMB424MBBGUHCI24YA4FPT/
> >
> > We read all of these and more back way in March, before we even started 
> > brainstorming syntax and semantics.
> >
> >> Do we want a fancy switch statement, or a powerful expression?
> >
> > It's right here that you lose me. Anyone who reduces pattern matching to "a 
> > fancy switch statement" probably isn't the right person to be discussing 
> > its semantics and usefulness with. It seems that some people just can't 
> > separate the two ideas in their mind. It's like calling a class a "fancy 
> > module".
>
> Pattern matching is a fancy switch statement, if you define "fancy"
> appropriately ;)

Everything is a goto if you want to play reductionist games. In
practice, though, the proposed match statement feels more like the
constructs in recent languages like Rust than like the C switch
statement.

> Reducing pattern matching to some sort of switch statement is exactly
> what a good implementation should do. It's what compilers are for.
> The comparison seems entirely reasonable to me.

Yes, the implementation might do this. But the *semantics* are what
matter here, and they are firmly in the area of "how developers should
think about the construct". Anyone thinking about pattern matching
with the C switch statement in mind is going to miss a huge amount of
the power and expressiveness of the construct.

> OOI, what is the reasoning for choosing a statement, not an expression?
>
> >
> > It's okay that you feel that way, but hopefully you'll understand if people 
> > start to tune out messages that contain these sorts of comments.
> >
>
> What does "these sorts of comments" mean?
> Ones that you disagree with?

Personally, I'm likely to tune out messages that seem to be ignoring
or dismissing big chunks of the discussion. Not "because I disagree",
but because there's no option for discussion or compromise if you
don't address the arguments already made in favour of pattern
matching.

To give one example, you say "Can we discuss whether we want pattern
matching in Python and the broader semantics first". I'd say yes we
do. There are many examples in the discussions so far on the PEPs (and
plenty more in the 10 years of history that Brandt mentioned) where
people have said they like how a given piece of code looks as a match
statement. You may not agree, but language features don't have to be
something that *everyone* likes, as long as there's sufficient value
to a sufficiently large user base to offset the costs of the feature.

Can you provide a counter-argument, or are you just asking that we go
round that discussion again, with no new information to add?

> If I am wrong, please explain why in an as objective a fashion as possible.

You are wrong that there is no support for pattern matching. See the
number of posts in support. You are wrong that pattern matching is
"just a fancy switch" - see examples in the PEP of many things a C
switch can't do (destructuring, for a start). If you want to claim
that's just "fancy", then I'd ask for a clarification of how far you
consider "fancy" to go, and why you consider a sufficiently fancy
switch to be useless based on an assumption that a non-fancy switch
would be. Hopefully that's a start towards objectively explaining why
I consider that you are wrong.

> >> What special method(s) should be added?
> >
> > None. PEP 622 originally added one, but even that is more than we need 
> > right now. Some people may need to register their mappings or sequences as 
> > Mappings or Sequences, but otherwise that's it.
>
> Much of the language uses special methods. Why should pattern matching
> be so different?
>
> Why make this opt-out, rather than opt-in, given the potential for
> unwanted side effects?
>
> >
> >> I would ask anyone who wants pattern matching adding to Python, to not 
> >> support PEP 634.
> >
> > Seriously?
>
> Yes. Absolutely.
> PEP 634 is seriously flawed.

I'm not going to make a decision like that just because you say so. I
have considered the PEP and am basically in favour of it. If you're
telling me I've made an incorrect judgement, then surely the onus is
on you to offer me additional data to convince me to change my mind,
not simply to state "PEP 634 is seriously flawed" without backing that
up. (Or at least, without backing it up any more than you have done in
previous posts on the matter, which I have read and so you can assume
didn't convince me).

I guess that's my explanation for why I'm likely to tune out your
posts on this. I'm not finding anything new in them, I'm afraid.

Paul
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/IQCMZVPOMRKLN5HAHPNNEB3HYAVWGCVK/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to