Skip to content
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 that modifyproperty! does not call convert currently #45218

Merged
merged 3 commits into from
May 13, 2022

Conversation

tkf
Copy link
Member

@tkf tkf commented May 7, 2022

Re-applying #45178 (which was reverted in #45209) and also clarifying that this is a limitation of the current implementation.

@vtjnash What do you think?

@tkf tkf added docs This change adds or pertains to documentation multithreading Base.Threads and related functionality labels May 7, 2022
@tkf tkf requested a review from vtjnash May 7, 2022 08:23
@@ -2758,6 +2758,11 @@ The syntax `@atomic! max(a().b, c)` returns `modifyproperty!(a(), :b,
max, c, :sequentially_consistent))`, where the first argument must be a
`getfield` expression and is modified atomically.

In the current implementation, the default implementation of `modifyproperty!` does not call
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically documentation is written in the imperative tense, and tries to avoid conditional modifiers of this sort.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any suggestions? How about something like

Invocation of op(getproperty(x, f), v) must return a value that can be stored in the field f of the object x. In particular, unlike the default behavior of setproperty!, the convert function is not called automatically. However, this limitation may be removed in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that reads better. I think remove the comment about "in the future" though (we also can change errors -> working as a rule, so it is unnecessary to state it)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also can change errors -> working as a rule

Yeah, it would greatly simply documentation like this. But some exceptions (e.g., LinearAlgebra.SingularException, Base.IOError) are used as an "output" of a function. So, I think we need to exclude some functions if we set this as a rule. Also, to handle APIs that want to guarantee to return an error with information in certain cases, I think we need something like Union{Ok,Err} convention #45080. After that, it'd be nice to define that changing throwing to not-throwing is non-breaking but changing return value, including Union{Ok,Err}, is breaking.

@tkf tkf force-pushed the modifyproperty-convert branch from 334ff83 to dfe5eea Compare May 11, 2022 14:14
@tkf
Copy link
Member Author

tkf commented May 11, 2022

@vtjnash I added the commit to use the version in #45218 (comment), without the "in the future" part.

@vtjnash vtjnash added the merge me PR is reviewed. Merge when all tests are passing label May 11, 2022
@aviatesk aviatesk merged commit 4dcf178 into JuliaLang:master May 13, 2022
@tkf tkf deleted the modifyproperty-convert branch May 13, 2022 03:39
@giordano giordano removed the merge me PR is reviewed. Merge when all tests are passing label May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation multithreading Base.Threads and related functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants