-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do we feel about removing tuple unpacking in lambda lists? #1589
Comments
Just to make sure, this means removing support for following or something completely else?
It's handy, but I don't see that so often. I don't have (strong) objections on removing it. |
Yeah, that's what I mean. I didn't even realize you could write it as |
I guess one could in theory combine that with optional parameters:
But then we would have to have a special case for
is both |
#1328, (or its successor) could pretty much replace this. Let's get it out of the compiler. I stalled when implementing that mainly because of #1414. But now that we have a |
I dislike that this change applies to
|
That should be doable more easily with a comprehension (#1626). |
OK so it would be I'm still hesitant as I don't see how to fit the new-style comprehensions into the threading macros. |
Right. |
I intended to replace the lambda-list unpacking with more a more general destructuring macro from #1328, which would also give you the ability to unpack mappings. There are still some open questions though, particularly #1411. But the new pattern matching stuff from the compiler might also lead to an even more general alternative. Think Haskell-style unpacking instead of Clojure, maybe. Though Clojure has an experimental pattern matching library that might be worth emulating. I'll have to look into it more.
Can you elaborate on that with some concrete examples? The new comprehensions should work in the threading macros about as well as Clojure's |
I realize this is not as nice as the pending macro would be, but in the meantime, you can still unpack inside the
Though in the case of |
I'm working on #1573 and I've noticed that without this feature, lambda lists would be a lot simpler. The fundamental unit, particularly for mandatory arguments, would be just a symbol. As is, the fundamental unit can be a symbol or it can be an arbitrarily nested list of symbols. Currently, this is already broken because of the conflict with the syntax for default values (#1410). It's also worth noting that this feature was present in Python 2 but removed for Python 3; to bridge the gap, Hy implements it with temporary variables instead of Python 2's native support.
Unpacking, including much more general unpacking capabilities, could still be provided by macros (e.g., #1328).
The text was updated successfully, but these errors were encountered: