# Why @view add a "true &&" before the view call?

**URL:** https://discourse.julialang.org/t/why-view-add-a-true-before-the-view-call/43670
**Category:** Internals & Design
**Tags:** question
**Created:** [July 25, 2020, 2:05pm UTC](https://discourse.julialang.org/t/why-view-add-a-true-before-the-view-call/43670 "2020-07-25T14:05:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![N5N3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/n5n3/32/17663_2.png) [@N5N3](https://discourse.julialang.org/u/N5N3)
#### Post date: [July 25, 2020, 2:05pm UTC](https://discourse.julialang.org/t/why-view-add-a-true-before-the-view-call/43670/1 "2020-07-25T14:05:11Z")

</div>

I’m try to look into the `@avx` macro offered by [LoopVectorization.jl](https://github.com/chriselrod/LoopVectorization.jl), which replace the `Base.materialize(!)` with the auther defined function.

I want to use the same design to make my own module to support macro like `@par b .= f.(a)` to perform multithreads broadcast, then I found that the `@view` macro will add a `true &&` before the view call, leading to IR with `Core.GotoNode` and `Expr(:gotoifnot,true,...)`, while `@views` don’t.  
[LoopVectorization.jl](https://github.com/chriselrod/LoopVectorization.jl) will throw a error when this happen.

It confuse me that the meaning of `true &&` here. For macro I want, a replacement of `Expr(::&&)` before `Meta.lower()` is enough, but I still wonder why we need it.

---

<div class="post-metadata">

### Author: ![thofma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thofma/32/1691_2.png) [@thofma](https://discourse.julialang.org/u/thofma)
#### Post date: [July 25, 2020, 3:32pm UTC](https://discourse.julialang.org/t/why-view-add-a-true-before-the-view-call/43670/2 "2020-07-25T15:32:23Z")

</div>

This will probably be changing, see [https://github.com/JuliaLang/julia/pull/36780](https://github.com/JuliaLang/julia/pull/36780).

The comment says

```julia
# wrap in a let block to prevent accidentally redefining `view` if used on the LHS, e.g.
# @view(A[x]) = 2

```

Before the proposed change it was not a `let` block, but `true &&`, which had the same effect: To not redefine `view` by accident:

```julia
julia> view(A, :, a) = b
view (generic function with 1 method)

```
