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

Fix #53 with ismutable default #67

Merged
merged 3 commits into from
Sep 4, 2020
Merged

Fix #53 with ismutable default #67

merged 3 commits into from
Sep 4, 2020

Conversation

Tokazama
Copy link
Member

This makes it so that ismutable has a default now, which is to use the mutable field of a type.

Default behavior is to use the `mutable` field of a type
@ChrisRackauckas
Copy link
Member

I'm not sure we should do this. It's almost guaranteed to not be correct for wrapper types.

@Tokazama
Copy link
Member Author

It doesn't change any of the current behavior for wrapper types. It simply provides a fall back. If we want to account for wrappers I could replace the current ismutable(::Type{<:AbstractArray}) = true with

function ismutable(::Type{T}) where {T}
    if parent_type(T) <: T
        return T.mutable
    else
        return ismutable(parent_type(T))
    end
end

...and then we could explicitly define the mutability of each type.

@Tokazama
Copy link
Member Author

Tokazama commented Sep 2, 2020

I added the recursive version that searches for a parent structure. I still haven't changed any of the tests, because the behavior is essentially the same.

@Tokazama
Copy link
Member Author

Tokazama commented Sep 4, 2020

@ChrisRackauckas, is this PR still problematic?

@ChrisRackauckas
Copy link
Member

I think that works.

@ChrisRackauckas
Copy link
Member

Could it get a test? Fake wrapper

@Tokazama
Copy link
Member Author

Tokazama commented Sep 4, 2020

So instead of testing a fake wrapped array I just tested views of StaticArrays. Turns out this actually fixes views on immutable arrays (which previously just assumed mutability).

@ChrisRackauckas
Copy link
Member

I'm convinced.

@ChrisRackauckas ChrisRackauckas merged commit c83328b into JuliaArrays:master Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants