-
-
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
add isimmutabletype #18168
add isimmutabletype #18168
Conversation
Many functions in Julia accept both an object or a type. I would reuse the name |
I think that it does make sense to ask whether a type object itself is
mutable. I don't think that case is rare enough that it wouldn't cause
trouble for anyone if the two functions were merged.
|
The corresponding field is called |
I don't think there are any immutable type objects. I'd be surprised if there is code that checks whether type objects are immutable. |
I doubt that there is code that does that specifically for type objects. But there could be code that is generic across |
We can define |
Which actually means that those code won't really work for types anyway. I'm not sure why does code check mutability but for the two cases I can think of,
|
8f7df3c
to
2656cdb
Compare
I've updated the PR to make I can actually only find three packages that use |
With the introduction of |
I seriously doubt that |
I mean this from a code readability viewpoint, not an efficiency viewpoint. Perhaps |
@StefanKarpinski, I noticed that |
@TotalVerb, from a readability standpoint, |
But |
The new I recall a discussion somewhere about a function for testing conventional mutability --- for example many types like |
Maybe such a concept should be separated into separate concepts for each kind of mutability, like for example |
I think that's the domain of protocols/traits, and out of scope here. |
@@ -156,7 +159,7 @@ This section lists changes that do not have deprecation warnings. | |||
and `step::FloatNN` to rationals and construct a `StepRangeLen` | |||
that internally uses twice-precision arithmetic. These two | |||
outcomes exhibit differences in both precision and speed. | |||
|
|||
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.
whitespace
Should this be |
Also, after #20418, it would be more logical to call this |
Determines whether a type was declared using `mutable struct`. Naming follows from the `ismutable` query we already have, analogous to `isbits`/`isbitstype`. Replaces #18168.
I've done a moral rebase of this in #39037. |
Determines whether a type was declared using `mutable struct`. Naming follows from the `ismutable` query we already have, analogous to `isbits`/`isbitstype`. Replaces #18168.
Determines whether a type was declared using `mutable struct`. Naming follows from the `ismutable` query we already have, analogous to `isbits`/`isbitstype`. Replaces JuliaLang#18168.
As discussed on julia-users recently, there is an
isimmutable
function to check whether a value is immutable, but nothing to check whether a type is immutable, which forces you to look in the internalmutable
field of a type. This PR adds anisimmutabletype
function to fill this gap.It also inlines some documentation, and removes an obsolete special-case for
Tuple
from theisimmutable
function.