One of my biggest pain points in Julia is that [...] makes a copy.
Using the macro in nested expressions needs parentheses which makes it not as quick to type:
julia> .+(x[1:3], x[2:4])
3-element Vector{Float64}:
-0.7509311698949941
1.709855739076295
0.7021749402293793
julia> .+(@view x[1:3], @view x[2:4])
ERROR: LoadError: ArgumentError: Invalid use of @view macro: argument must be a reference expression A[...].
Stacktrace:
[1] var"@view"(__source__::LineNumberNode, __module__::Module, ex::Any)
@ Base ./views.jl:138
in expression starting at REPL[11]:1
julia> .+(@view(x[1:3]), @view(x[2:4]))
3-element Vector{Float64}:
-0.7509311698949941
1.709855739076295
0.7021749402293793
julia> .+(@view(x[1:3]), @view(x[2:4]))
I wonder actually, why this does not work. The @. propagates fully into the whole call, @view does not:
julia> @view x[1:3] .+ x[1:4]
ERROR: LoadError: ArgumentError: Invalid use of @view macro: argument must be a reference expression A[...].
Stacktrace:
[1] var"@view"(__source__::LineNumberNode, __module__::Module, ex::Any)
@ Base ./views.jl:138
in expression starting at REPL[13]:1