# Mutating a view (not the underlying array)

**URL:** <https://discourse.julialang.org/t/mutating-a-view-not-the-underlying-array/111089>\
**Category:** General Usage\
**Created:** [March 3, 2024, 11:58am UTC](https://discourse.julialang.org/t/mutating-a-view-not-the-underlying-array/111089 "2024-03-03T11:58:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgaure](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgaure/32/14779_2.png) [@sgaure](https://discourse.julialang.org/u/sgaure)\
**Post date:** [March 3, 2024, 11:58am UTC](https://discourse.julialang.org/t/mutating-a-view-not-the-underlying-array/111089/1 "2024-03-03T11:58:05Z")

</div>

I have a question about views.

I have a vector `P::Vector` in which I want to find a subset with a specific property. This can be done incrementally. I use a loop like this:

```julia
idxs = collect(eachindex(P))
Psubset = view(P, idxs)
while !itworks(Psubset)
    # update idxs by deleteat! or keepat! or resize!, e.g.
    deleteat!(idxs, somevector)
end

```

I’m wondering what kind of guarantees are given that this will continue to work in future versions? I.e. changing `idxs` and expecting it to show up in the view `Psubset`? I can’t find anything in the documentation, though I may have missed it.

It does for instance not work if `idxs` is a `Vector{Bool}`, because such indexing is converted to integer indices. I could of course add a `Psubset = view(P, idxs)` at the end of the loop, but then I risk an allocation, and this is deep in a parallel run where allocations will profoundly impact performance. I could also do this in some other way, avoiding views altogether, that is however not the question here.
