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



Jon Harrop wrote:
Nathan Baum wrote:

Jon Harrop wrote:

Nathan Baum wrote:

You misunderstand me. I mean that the Mathematica equivalent of 'X,
which I suppose is just (X), would behave that way.

I don't understand. The Mathematica equivalent of 'X is Hold[X]?

No. Because Mathematica has a wildly different evaluation model, its equivalent of 'X is simply (X) -- Mathematica keeps evaluating until an expression doesn't change. 'X changes when it is evaluated, and therefore, from Mathematica's point of view, 'X is equivalent to (X).


I think this is an important point: all Mathematica values are equivalent to
Lisp s-exprs. So all Mathematica equivalents must be quoted at least once.
So (X) cannot be a Lisp equivalent of anything in Mathematica, AFAIK.

Not all. Literals are, by definition, self-evaluating. ``3'' is the same thing in Lisp and Mathematica, and 3 and '3 will evaluate to the same thing. 3 and ''3 won't, however.


Are 3 and Hold[3] the same thing.


Note that this has nothing to do with the similarity between QUOTE and
Hold. This is entirely to do with evaluation semantics, which are
definitely not the same.

How do you propose to judge the similarity of QUOTE and Hold _without_ considering how they effect the evaluation of expressions?


I'm just comparing the effect of eval on QUOTE and Release on Hold. I'm not
trying to say that the subsequent evaluation of the enclosing expression
works in the same way.


Perhaps in terms of the relationship between EVAL and ReleaseHold they are similar.


The two do, of course, do quite different things, and it is only when used with QUOTE in this limited way that EVAL/QUOTE behaves like ReleaseHold/Hold.

EVAL evaluates its argument, whilst ReleaseHold simply makes its argument available for evaluation and then Mathematica's normal evaluator causes it to be evaluated.

If Lisp had Mathematica's evaluation semantics, EVAL/QUOTE would be quite unlike ReleaseHold/Hold: it would be like Peter Seibel's implementation of RELEASE and HOLD.

In my view, it is flawed to say that EVAL and ReleaseHold serve similar purposes just because the semantics of the language mean that they can appear in similar expressions which evaluate to the same thing.

Yes,

  ReleaseHold[Hold[3 + 3]]          ==> 3, and
  (EVAL (QUOTE (+ 3 3))             ==> 3

but

  ReleaseHold[Hold[A + B]]          ==> A + B, whilst
  (EVAL (QUOTE (+ A B))             ==> Error

and also

  Hold[3]                           ==> Hold[3], whilst
  (QUOTE 3)                         ==> 3

and of course

  ReleaseHold[X]                    ==> X, whilst
  (EVAL X)                          ==> Error

additionally,

  ReleaseHold[{2, Hold[1 + 1]}]     ==> {2, 2}, whilst
  (EVAL (VECTOR 2 (QUOTE (+ 1 1)))) ==> #(2 (+ 1 1))
.



Relevant Pages

  • Re: Lisps QUOTE and Mathematicas "Hold"
    ... So all Mathematica equivalents must be quoted at least ... So cannot be a Lisp equivalent of anything in Mathematica, ... >> not trying to say that the subsequent evaluation of the enclosing ... to implement Mathematica's capabilities in Lisp, i.e. using s-exprs. ...
    (comp.lang.lisp)
  • Fundamentals of the Mathematica Programming Language note set by Richard J. Gaylord available
    ... to give you a flavor of what i am trying to emphasize in the note set, ... Mathematica Programming Fundamentals: ... When the lhs of a rewrite ... Evaluation then proceeds by searching for further matching ...
    (sci.math.symbolic)
  • Re: Lisp and Scheme with fewer parentheses / Mathematica??
    ... Try to get out of lisp mindset, and view things from general humanity. ... whether, is it reasonable, to say that programing in mathematica is ... Lisp has a 'simpler' and more straight forward model evaluation model. ... is more to be a straight-forward implementation language ...
    (comp.lang.lisp)
  • Re: Lisps QUOTE and Mathematicas "Hold"
    ... If Lisp was virtually the same as Mathematica, programs could only be written to use ... and would therefore be evaluated to produce, which is not a self-evaluating form and would therefore be evaluated to produce 3, which is a self-evaluating form and would therefore not be evaluated because further evaluation would have no effect. ... Presumably, a Lisp which used Mathematica-style evaluation would want to be a Lisp-1, so this kind of problem could not occur. ...
    (comp.lang.lisp)
  • Re: Very poor Lisp performance / about Mathematica
    ... his personal experience interacting with Mathematica. ... assume that Jon has the language design and semantics experience to ... , the order of evaluation is not specified, but the ... > Just as you use quote in a Lisp macro. ...
    (comp.lang.lisp)