-
-
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
improved function partial application design #56518
base: master
Are you sure you want to change the base?
Conversation
83d2606
to
ac0a69e
Compare
3549ca3
to
0ea9693
Compare
look, I'm not trying to be the bad guy on all your PRs. but I feel like you are misrepresenting the status quo
this is already not possible with
|
I'm not misrepresenting anything, this is the (embarrassing) behavior on master: julia> Base.Fix{-1}
Base.Fix{-1} |
try constructing it? |
Could you please take your off-topic chatting to Discourse or wherever? |
it was a direct and objective refute to one of the primary motivations you provided in the commit message. it feels pretty on topic to me. that being said, you clearly don't want my input, so I'll stop providing it (as, I suspect, will everyone else) |
This replaces `Fix` (xref JuliaLang#54653) with `fix`. The usage is similar: use `fix(i)(f, x)` instead of `Fix{i}(f, x)`. Benefits: * Improved type safety: creating an invalid type such as `Fix{:some_symbol}` or `Fix{-7}` is not possible. * The design should be friendlier to future extensions. E.g., suppose that publicly-facing functionality for fixing a keyword (instead of positional) argument was desired, it could be achieved by adding a new method to `fix` taking a `Symbol`, instead of adding new public names. Lots of changes are shared with PR JuliaLang#56425, if one of them gets merged the other will be greatly simplified.
0ea9693
to
8b2e9ef
Compare
Why does every PR now try to push in this "typed domain numbers" package into Base..? As has been said regarding
so it is unclear what is being improved here. I don't really understand what the other benefit means. |
From what I can tell, this PR comprises three changes that are related, but could be considered independently:
I agree that 1. might make future extensions to e.g. fixing keyword arguments more seamless, but could just be introduced when the time is ripe. If we expect the type to change in the future, this function might give the needed indirection to make that less breaking, but that is quite speculative. |
The benefit of 3. is type safety, as mentioned in the OP. I'm confused by the apparently wide disregard for correctness. |
If I understand correctly, currently Julia does check for correctness (as shown above), but currently that check is done at runtime, and the idea of this PR (specifically, change 3) is to move that check from runtime to compile-time? What are the advantages and disadvantages of doing this check at compile-time vs runtime? |
The benefit is type safety for the first type parameter (fixed argument position) of the The drawback is more code in IMO the unnecessary lack of type safety in the current version of PS: I labeled with do-not-merge because this PR currently fails |
Also, to respond to @adienes and @KristofferC directly, clearly error checks in a constructor are irrelevant for type safety, which is why I called the discussion off-topic. |
Hm, but We also have julia> Array{Float64,-7}
Array{Float64, -7} and I don't think that has caused much grief, has it? Maybe even worse, we also allow |
@nsajko, what do you mean when you say "type safety" w.r.t Julia? How will a user be happier? |
This replaces
Fix
(xref #54653) withfix
. The usage is similar: usefix(i)(f, x)
instead ofFix{i}(f, x)
.Benefits:
Fix{:some_symbol}
orFix{-7}
is not possible.fix
taking aSymbol
, instead of adding new public names.Lots of changes are shared with PR #56425, if one of them gets merged the other will be greatly simplified.