# Overload x\[0:0.5:0.5\] .= 1 when x is not AbstractVector

**URL:** <https://discourse.julialang.org/t/overload-x-0-0-5-0-5-1-when-x-is-not-abstractvector/26980>\
**Category:** General Usage\
**Tags:** question\
**Created:** [July 30, 2019, 2:14pm UTC](https://discourse.julialang.org/t/overload-x-0-0-5-0-5-1-when-x-is-not-abstractvector/26980 "2019-07-30T14:14:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dlfivefifty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlfivefifty/32/1959_2.png) [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)\
**Post date:** [July 30, 2019, 2:15pm UTC](https://discourse.julialang.org/t/overload-x-0-0-5-0-5-1-when-x-is-not-abstractvector/26980/1 "2019-07-30T14:15:00Z")

</div>

I have a custom type [QuasiArray](https://github.com/JuliaApproximation/QuasiArrays.jl) that implements broadcasting, and expected

```julia
x[0:0.5:0.5] .= 1

```

to lower to the functioning

```julia
view(x,0:0.5:0.5) .= 1

```

Unfortunately this is not working as expected, and `x[0:0.5:0.5] .= 1` appears to be lowering to

```julia
broadcast!(identity, x[0:0.5:0.5], 1)

```

which does not modify `x` in place.

Is there some other overload needed?

---

<div class="post-metadata">

**Author:** ![jmert](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmert/32/3161_2.png) [@jmert](https://discourse.julialang.org/u/jmert)\
**Post date:** [July 30, 2019, 2:28pm UTC](https://discourse.julialang.org/t/overload-x-0-0-5-0-5-1-when-x-is-not-abstractvector/26980/2 "2019-07-30T14:28:52Z")

</div>

I’d guess you need to overload `Base.dotview`:

```julia
julia> using Base.Meta

julia> Meta.lower(Main, :(x[0:0.5:0.5] .= 1))
:($(Expr(:thunk, CodeInfo(
1 ─ %1 = 0:0.5:0.5
│ %2 = (Base.dotview)(x, %1)
│ %3 = (Base.broadcasted)(Base.identity, 1)
│ %4 = (Base.materialize!)(%2, %3)
└── return %4
))))

```

Then considering the default methods available for `dotview`:

```julia
julia> methods(Base.dotview)
# 2 methods for generic function "dotview":
[1] dotview(B::BitArray, i::BitArray) in Base.Broadcast at broadcast.jl:1037
[2] dotview(args...) in Base.Broadcast at broadcast.jl:1067

julia> @edit Base.dotview(Float64[])

```

there’s a comment on the catch-all definition saying:

```julia
# x[...] .= f.(y...) ---> broadcast!(f, dotview(x, ...), y...).
# The dotview function defaults to getindex, but we override it in
# a few cases to get the expected in-place behavior without affecting
# explicit calls to view. (All of this can go away if slices
# are changed to generate views by default.)

Base.@propagate_inbounds dotview(args...) = Base.maybeview(args...)

```
