There are two separate issues here, which you are confusing.
Does function call via @ ignore HoldFirst attribute?
No, it doesn't. f[x]
and f@x
are different textual representations of the very same expression. Writing it either way has absolutely no effect on evaluation. The parser converts both into the very same internal representation. The evaluator works with this internal representation and doesn't know how you wrote the code originally, as f[x]
or f@x
.
I was trying to test whether using func[x,y]
is the same as func[#,y]&@x
This is an entirely different question, and has nothing to do with using the @
character. It's about using a pure function. Note that func[#,y]&@x
and func[#,y]&[x]
are exactly the same thing. The latter has no @
in it.
By default, any pure function behaves as if it had no attributes (such as HoldAll
, etc.). Demo:
Hold[#] &[1 + 1]
(* Hold[2] *)
Let's write this using its FullForm:
Function[Hold[#]][1 + 1]
If you look up Function
, you will see that we can construct a funtcion with the same behaviour using the following syntaxes too:
Function[x, Hold[x]]
or
Function[Null, Hold[#]]
If we write it this way, we get access to the third argument, where we can specify attributes. See the Function
documentation page for more information.
Function[x, Hold[x], HoldAll][1 + 1]
(* Hold[1 + 1] *)
(1 + 2 - 3)
is evaluated before being passed. You can trytest[#, 5 - 5] &@Defer[(1 + 2 - 3)]
to prevent evaluation of(1 + 2 - 3)
. $\endgroup$Defer
. The most important thing to remember is that it deal with formatting and not evaluation. It is only useful in a notebook and only if you mean to copy the output or edit it otherwise in a notebook. In a way it is for user interaction. It is not useful for programming and expression manipulation and has no effect when running the kernel without a front end. You example is effectively the same astest[#, 5 - 5] &@HoldForm[(1 + 2 - 3)]
. The headHoldForm
orDefer
stays there it just doesn't print. $\endgroup$Interpretation
. It's all about formatting and user interaction within a notebook and has nothing to do with expression manipulation or programming, nor does it have any effect when there is no notebook environment. $\endgroup$