-
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
Better &optional
, &rest
, &kwonly
, and &kwargs
docs.
#1722
Comments
Recapitulating the fine details of Python's argument handling is not a good idea—we should link to the relevant parts of the Python language reference instead—but there are definitely some outright errors and omissions in the current descriptions, such as the implication that |
Makes sense. To provide a little more insight, I'll say that my understanding after reading the docs was as follows:
An example case like the following:
Would help greatly. |
Now that I think about it, should we really have (Also hey look, I'm not dead.) |
That's not a bad idea. I think the status quo is just because that's how Lisps have traditionally specified optional parameters. |
I don't particularly like the status quo here, and have mulled over alternatives. #1411 Ideally, I'd like Clojure-style destructuring to work in the lambda lists. This may be incompatible with just using brackets instead of |
On the thread of more concise arguments, thoughts on not having |
So e.g. (defn print [&rest values &kwonly end] ...) is written instead as (defn print [&rest values :end] ...) I would be against this in Common Lisp, because "keywords" are symbols, by Hy treats keywords differently anyway. |
The documentation for these four constructs is, in my opinion, lacking. I got tripped up not realizing that
&optional
affected not only the next argument but also all those afterwards.Undocumented bits include:
&optional
affects all succeeding arguments&rest
be used with&optional
?&kwonly
affects all succeeding arguments (I assume, since this is how it works in Python)&kwargs
argument?The interactions between these things is not particularly simple and, though understandable after a bit, can be difficult for a beginner (in Python and Hy or in Hy but not Python, like me). Further, the error message (at least for the
&optional
interaction) is not particularly enlightening, so it's hard to figure out what's going wrong beyond just trial&error.The text was updated successfully, but these errors were encountered: