To what extent can JuMP's macro identify input expression and generate optimized backend codes?

JuMP’s macros are like magic black boxes to me. I’ve learned that one should generally make use of @variable, @constraints and @objective when constructing a model from scratch. But I have some small but nontrivial questions.

In the very introduction page of JuMP’s doc, there is this example code
@objective(model, Min, sum(residuals.^2))

To be honest I dislike the expression. Were residuals an Array of Float64, I would always write
sum(x -> x^2, residuals). I bet every experienced julia user would write it this style solely.

Now I’m curious: can I write @objective(model, Min, sum(x -> x^2, residuals)) when residuals is a Vector of decision variables? Can JuMP’s macro recognize this expression and generate optimized code to attain maximum performance?

According to my past experience, not all julia jargons are understood by JuMP’s macros. They may work, but left unoptimized. e.g. writing a mapreduce expression inside @expression (Am I right?).

Now return to the initial question: why did you choose to use the awkward expression sum(residuals.^2)? Because the JuMP macros can only recognize that particular form?

Another very similar question:
For numeric matrix it makes sense in julia to write sum(view(A, :, 1)) instead of sum(A[:, 1]). Can I also write sum(view(x, :, 1)) inside a macro (and get optimized)?