Hi Rob, thank you! :)
I think I understand the point, but I still don't agree with it. I find it hard 
to come up with a concrete use case where you would like to name a parameter 
without specifying it. Suppose we want
case Status(user, n_messages, replies, unicode:=_)
Then it might be a little useful for us to type the non-captured arguments 
explicitly because it's easier to remember the signature that way. 
Alternatively, if you want to capture an arg like this and you have more than a 
few positional arguments, you should probably just match on a keyword argument 
(or refactor your code so your API's are simpler).
Also, what would we type if we wanted to capture a keyword argument? Something 
like this?
case Status(user, n_messages, replies, unicode=unicode:=_)
Surely that must be a horrible joke! (N.B. I suppose this is an argument 
against this specific syntax rather than capturing)

Additional potentials I came up with are checking for the number of arguments 
(when it's a lot, so typing all the underscores becomes hard to count), like:
match pt:
    case (a, b, c, d, e, f, g, h):
        manage_len_8(pt)
    case (a, b, c, d, e, f, g, h, i, j, k):
        manage_len_11(pt)
But in that case why not use an if-else, like so.
if len(pt)==8:
    manage_len_8(pt)
elif len(pt)==11:
    manage_len_11(pt)
There must be use cases I haven't thought of, but I think they will all fall 
prey to similar objections as the above two. I'm open to being proven wrong, 
though!

The thing about explicitness is, sure, it is better than implicitness. But 
beautiful is also better than ugly, and simple better than complex, etc. etc. I 
think they mean nothing without specific use cases to know what it actually 
means for this thing in this context.
I think case(x:=_, y:=_, z) is exactly as explicit as case(x, y, _) (it names x 
and y explicitly), with the added drawbacks of
- Confusing the meaning of "_", which (at least in my mind) means "discard".
- Deviating from other languages with pattern matching (which, presumably, also 
have bikeshedded on this point), increasing the surprise level for people who 
are either coming to Python from there, or going from Python to there.
- Requiring extra (weird-looking) syntax for the default case of capturing 
variables.

Again, maybe I'm just having trouble finding good use cases (either that, or I 
have no intuition for programming :P). Let me know if you have some!

Rik

P.S. If I'm out of line or violating etiquette with anything, please let me 
know. I'm open to help.
_______________________________________________
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/N4H42GTG237PBG5B4N6ZF4DQAX4X3HEE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to