As far as I can tell, there is no ability to overload &&. It doesn’t seem to be a function defined in Base as other operators are. I assume this is because it doesn’t behave the way other functions do in that it short circuits (the 2nd argument is lazily evaluated). Is there any way around this?
Found the unusual position of the point by chance:
julia> [true, false] .&& false
2-element BitVector:
0
0
No, you can’t overload &&.
Hm, I can’t tell for the overloading.
What is then &&. ?
It throws an error in the example above.
julia> Meta.@lower true && false
:($(Expr(:thunk, CodeInfo(
@ none within `top-level scope`
1 ─ goto #3 if not true
2 ─ return false
3 ─ return false
))))
julia> Meta.@lower true .&& false
:($(Expr(:thunk, CodeInfo(
@ none within `top-level scope`
1 ─ %1 = Base.broadcasted(Base.andand, true, false)
│ %2 = Base.materialize(%1)
└── return %2
))))
No, the . above was just finishing the sentence. &&. doesn’t have a meaning in Julia. Like other binary operators, the . goes first: .+ .* .&&
No, it’s not a function at all but rather a control flow syntax similar to if or ? :.
Depends on what you are trying to accomplish. If you are willing to involve macros you have great possibilities to customize the meaning of anything that is syntactically valid.