-
Notifications
You must be signed in to change notification settings - Fork 22
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
[RFC] add setproperties!! #25
Conversation
Codecov Report
@@ Coverage Diff @@
## master #25 +/- ##
==========================================
- Coverage 100% 93.75% -6.25%
==========================================
Files 1 1
Lines 23 32 +9
==========================================
+ Hits 23 30 +7
- Misses 0 2 +2
Continue to review full report at Codecov.
|
I would like to respond to the @tkf comment
I think Also I think neither |
function setproperties!!(obj, patch::NamedTuple) | ||
if ismutablestruct(obj) | ||
setproperties!(obj, patch) | ||
else | ||
setproperties(obj, patch) | ||
end | ||
end |
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.
OK, so setproperties!!
I had in BangBang.jl haven't implemented the full functionalities I wanted to add. I'm trying to do it in JuliaFolds/BangBang.jl#23
Translating to setproperties!!
, it would be something like this:
function setproperties!!(obj, patch::NamedTuple{pnames}) where pnames
if ismutablestruct(obj) && all(n -> patch[n] isa fieldtype(typeof(obj), n), pnames)
setproperties!(obj, patch)
else
setproperties(obj, patch)
end
end
I think my point was rather |
Okay I agree, |
Hmm... I think I get it but it's rather unsatisfactory that we have |
Unfortunately I need indexing as well :(. These C structs are nested 3-4 structs in, and the inner most field may be an StaticArray/NTuple. |
Do we want |
After jw3126/Setfield.jl#95, we have enough machinery to solve jw3126/Setfield.jl#92 and this PR is not the only way to do implement jw3126/Setfield.jl#92 anymore. In this case, I prefer to let this API evolve outside the core construction API. I think it even makes sense to add |
Okay, then I close this PR for now. |
Over at
Setfield
we have a PR that wants to add lenses that work on mutables and immutables.This requires
setproperties!!
, which currently lives inBangBang
(or more preciselysetproperty!!
).This PR investigates adding
setproperties!!
here instead. See also this comment