-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Clarify default values: Position vs Keyword #32020
Conversation
Tries to address my confusion and that of David Klaffenbach here: https://discourse.julialang.org/t/define-f-with-keyword-arguments-function-f-does-not-accept-keyword-arguments/24186 Maybe others also too sheepish to speak-up publicly?
Just linking that any resolution of issue #9498 will likely require this section of the docs to be updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification. The level of alarm seems somewhat overstated. Could you tone it down a bit?
Fix compilation with external LLVM
Added an example of issue JuliaLang#9498 - since it is not scheduled to be fixed until Julia 2.0. Kept the example of ambiguous/last-seen default code being run because that is the core use case for default values.
I am still not sure what the confusion in https://discourse.julialang.org/t/define-f-with-keyword-arguments-function-f-does-not-accept-keyword-arguments/24186 actually is and how the manual does not explain it. Is it #9498? In that case I suggest just adding a short sentence to that issue. If it is something else, it would be good to pinpoint exactly what the manual fails to convey and try to more "surgically" insert that into the text. |
It seems that most of the confusion in that thread came from reusing the same REPL session in which other methods of julia> f(a=1,b=2)=5
f (generic function with 3 methods)
julia> f(;a=1,b=2)=10
f (generic function with 3 methods) is given here as if this was some weird or surprising aspect of keyword/positional arguments, when it is just an artifact of defining the zero-argument method of |
The only real connection between the issue of REPL session reusage and default arguments is that defining methods with defaults is a particularly good way to redefine a previously defined method in an obscure way and confuse yourself. That is probably enough of a common hazard to warrant mention here, but it's not specific to method definitions or default argument values—it's something to be aware of in general when using the REPL. |
The tiers of support are now maintained in one place, i.e. on the downloads page on the website. It was difficult to have an accurate list of tiers for master, and much simpler to have support tiers for the latest stable release instead. Thus, the downloads page is the right place to host this information and curate it.
From my PoV the REPL issue was not the source of confusion, fact it served to signal something out of the ordinary was going on. Issues with the current document:
I agree with @StefanKarpinski #9498 must be mentioned. It will give more understanding and not less, lead to fewer issues and not more - but will leave this to you. I agree with @StefanKarpinski that the downside of positional defaults needs to be made explicit:
What is the Julian recommended way to handle default values? My 2c: It seems to me, at this point, that what I would have appreciated is something like the following take away/impression (until 2.0):
|
Tries to address my confusion and that of David Klaffenbach here: https://discourse.julialang.org/t/define-f-with-keyword-arguments-function-f-does-not-accept-keyword-arguments/24186 Maybe others also too sheepish to speak-up publicly?
Added an example of issue JuliaLang#9498 - since it is not scheduled to be fixed until Julia 2.0. Kept the example of ambiguous/last-seen default code being run because that is the core use case for default values.
Hmm, editing in github then locally is getting messy. May retry this if I think I have some concrete insight that adds value. |
Tries to address my confusion and that of David Klaffenbach here:
https://discourse.julialang.org/t/define-f-with-keyword-arguments-function-f-does-not-accept-keyword-arguments/24186
Maybe others also too sheepish to speak-up publicly?