Yes, Defer
can be confusing because in a notebook, evaluating Defer[1+1]
seems to give 1+1
. This is merely an illusion. On the command line you get Defer[1+1]
as the output, i.e. Defer
behaves just like Hold
.
This is because Defer
is formatted in a special way in notebooks, but formatting is entirely orthogonal to evaluation or the storage of expressions. Basically, the output looks like 1+1
, but if you previously assigned it to a variable, and use Head
on it, you will see that it still has the head Defer
. However, if you copy that 1+1
and paste it back, or just edit the 1+1
in the notebook, it becomes something that is subsequently interpreted as Plus[1,1]
and not Defer[Plus[1,1]]
.
This is an additional source of confusion that has nothing to do with the HoldAll
property of Defer
.
This is why I suggested to experiment with Hold
only for now, and once you understand it well, you can look at the specially formatted constructs like Defer
and Interpretation
.
There is also HoldForm
, which is basically an always-invisible Hold
. It's invisible even in command-line mode.
You would normally use HoldForm
and Defer
when you care about presentation, and care about what happens when the displayed expressions are copied by a user.
You would use Hold
when you simply want to manipulate expressions that may never be displayed to a user unfamiliar with the workings of your program (or when you want to see the expression as it really is and not in disguise).
I don't know Lisp, but I am aware of the single-quote feature of Maple, which is superficially similar to Unevaluated
, but in reality very very different.
The Maple docs say,
After each evaluation, one level of single quotes is stripped off.
'x'
becomes x
and ''x''
becomes 'x'
.
There is no single-step evaluation in Mathematica. Mathematica will always keep applying transformation rules for as long as the expression cannot be changed anymore. If we have an expression that removed one level of itself, e.g. f[x_] := x
, then Mathematica will keep applying this rule again and again for as long as it can. So f[f[f[x]]]
will always become x
.
See also:
https://mathematica.stackexchange.com/questions/334/how-do-i-evaluate-only-one-step-of-an-expression