But Defer
isn't like Lisp single quote. Single quote is a simple thing, while Defer
is actually quite complicate and subtle.
FullForm[Defer[1 + 1]]
yields
Defer[Plus[1,1]]
Note that Defer
has not actually gone away, unlike Lisp single quote. Normally, the front end hides it: here, FullForm
has revealed it. But its really odd behavior is that the front end hides it from cut and paste, unlike HoldForm
which gets picked up by cut and paste.
The most fundamental difference between Lisp and Mathematica is that the Lisp evaluator evaluates an expression once when invoked. The Mathematica evaluator re-evaluates the result, and continues until the result stops changing. This makes quoting a more complicated problem in Mathematica.
Apply
isn't really doing what you imagine. Apply[f,expr]
is essentially equivalent to (cons f (cdr expr))
in Lisp. Now, in Lisp, this wouldn't do much. It works in Mathematica because the evaluator then evaluates the resulting expression, so its behavior is superficially like apply
in Lisp. Once you understand how this works, you can do Apply
-like things more surgically. For example, expr/.List->Plus
to apply Plus
to every List
in an expression.
The flip side is that Lisp
gets upset with undefined functions, but Mathematica
simply ignores expressions for which it has no rewrite rules.
Symbols bound to rewrite rules may look similar to Lisp functions, but rewrite rules much more flexible than lambda bindings.
f_[whoCalled] ^:= f
Sin[whoCalled]
yields
Sin
You can, of course write things that superficially resemble Lisp using things like Apply
or things that superficially resemble C using For
, but you can also trip yourself up doing that, and you won't be exploiting Mathematica
's special capabilities.