It’s not a bad idea, but one reason not to do this in Julia base is that it uses the & operator which normally means bitwise AND to mean logical AND. Or, in other words, if you wanted:
(<some_operator>)(f1, f2) = x -> f1(x) & f2(x)
what operator would you use? The & operator seems like the logical and obvious choice, but your proposal would use that to mean something different.
On the other hand, in your own code you could use and and or as function names without needing to pirate anything. Alas, you can’t use them as infix operators, but that may be ok if it makes your code a bit more obvious and free of type piracy.
Note that evaluation is “kind-of-short-circuiting”; you can’t replicate && with a function, since it’s control flow, but the evaluation of the function chain will exit early if it hits a false (or true, depending). Also, all arguments to ∨ and ∧ are evaluated when the anonymous function is created (like with ifelse).
As an exercise a while back I also wrote a macro version of this to overcome the mentioned limitations, but I still haven’t been able to think of a single case where using it would be worthwhile…
macro and(args...)
ex = Expr(:&&, first(args))
ex′ = ex
for i in 2:length(args)
push!(ex′.args, Expr(:&&, args[i]))
ex′ = last(ex′.args)
end
esc(ex)
end
edit: sorry, I didn’t find the right version of the macro, so the above doesn’t do what I said it does. Oh well…