-
-
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
#34518 - rename isimmutable to ismutable #34652
Conversation
base/reflection.jl
Outdated
@@ -417,7 +417,28 @@ julia> isimmutable([1,2]) | |||
false | |||
``` | |||
""" | |||
isimmutable(@nospecialize(x)) = (@_pure_meta; !typeof(x).mutable) | |||
function isimmutable(@nospecialize(x)) |
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.
We generally don't start introducing "live" depwarns of exported functions in the middle of a stable release. Instead you should move this to the end of base/deprecated.jl
but don't actually issue the depwarn. Most or all of the "live" depwarns there are for types or methods that were never exported in the first place and therefore not protected by the "no breaking changes" rule. Thus, those deprecations are not necessary but are there as a kindness. In contrast, this is part of Julia's public API.
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! moved isimmutable
from reflections.jl
to the bottom of deprecated.jl
in 6b76c59
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.
Looking good. One more ask and I would approve this for merging. (Oh, but please do add the NEWS and a test of ismutable
directly.)
|
||
Return `true` iff value `v` is immutable. See [Mutable Composite Types](@ref) | ||
for a discussion of immutability. Note that this function works on values, so if you give it | ||
a type, it will tell you that a value of `DataType` is mutable. |
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.
Sorry I didn't mention this before, but perhaps it would be good to add
!!! warning
Consider using `!ismutable(v)` instead, as `isimmutable(v)` will be replaced by `!ismutable(v)` in a future release.
Then the last step for a truly awesome contribution would be to add ismutable
to https://github.com/JuliaLang/Compat.jl.
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.
Warning message added in a77d03a
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.
Compat PR JuliaLang/Compat.jl#686
@timholy sure!
In the PR , I changed the tests in Is there somewhere else I should test |
base/deprecated.jl
Outdated
""" | ||
isimmutable(v) -> Bool | ||
!!! warning | ||
Consider using `!ismutable(v)` instead, as `isimmutable(v)` will be replaced by `!ismutable(v)` in a future release. |
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.
Would be good if this mentioned that ismutable was introduced in Julia v1.5.
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.
added in (Since Julia 1.5) in a252f5e
base/deprecated.jl
Outdated
false | ||
``` | ||
""" | ||
isimmutable(@nospecialize(x)) = (@_pure_meta; !typeof(x).mutable) |
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.
Maybe this could now be implemented as
isimmutable(@nospecialize(x)) = (@_pure_meta; !typeof(x).mutable) | |
isimmutable(@nospecialize(x)) = !ismutable(x) |
but perhaps not that important.
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.
changed in eed8b67
base/exports.jl
Outdated
@@ -642,6 +642,7 @@ export | |||
isbits, | |||
isequal, | |||
isimmutable, |
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.
You could move this export to where the function is defined in deprecated.jl
such that we don't forget to remove it once the function definition is removed (that has happened before).
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.
export moved to deprecated.jl
in 28f7f9f
@@ -159,6 +159,7 @@ Base.isdispatchtuple | |||
|
|||
```@docs | |||
Base.isimmutable | |||
Base.ismutable |
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.
Maybe switch the order and put ismutable
first?
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.
order switched in aba863f
Thanks @ssikdar1! |
PR for issue #34518.
Created a
ismutable
inbase/reflection.jl
and added adepwar
toisimmutable
.Result in REPL:
Switched
isimmutable
toismutable
in other parts of the code.isimmutable
isimmutable
toismutable
Didn't add any new tests but
test/reflection.jl
passed.