Re: Lisp's QUOTE and Mathematica's "Hold"



Jon Harrop wrote:

So the first example should be:

Release[Hold[3+3]] ==> 3+3        ( ==> 6)
eval ''(+ 3 3)     ==> (+ 3 3)

As Mathematica's built-in rules are not the same as Lisp's, we should not
let the Lisp evaluator evaluate anything for us. You are quite right that
Lisp's evaluator works for (+ 3 3) but it should also work for '(+ 3 a 3),
to give '(+ 6 a), for example.

With the equivalence that I'm proposing you would then have:

3                  ==> 3
'3                 ==> 3

Hold[3]            ==> Hold[3]
''3                ==> '3

Release[Hold[X]]   ==> X
(eval ''x)         ==> X
>
> Release[Hold[{2, Hold[1+1]}]] ==> {2, Hold[1+1]}
> (eval '`,(list 2 '(+ 1 1)))   ==> (2 (+ 1 1))

But in that expression, Hold[X] is not longer equivalent to ''X: in the outermost Hold it's equivalent to '`,X, and in the innermost 'X.

If we rewrite the example to obey your equivalence:

  (eval ''('2 ''(+ 1 1)))
    ==> ('2 ''(+ 1 1))

which is like Mathematica's

  ReleaseHold[Hold[{Hold[2], Hold[Hold[1 + 1]]}]]
    ==> {Hold[2], Hold[Hold[1 + 1]]}

and not at all like

  ReleaseHold[Hold[{2, Hold[1+1]}]]
    ==> {2, Hold[1+1]}

We see again that the comparison between Release/Hold and EVAL/QUOTE is ill-founded. It's like saying multiplication and addition are equivalent because 2 + 2 == 2 * 2.
.