Re: Lisp's QUOTE and Mathematica's "Hold"
- From: Nathan Baum <nathan_baum@xxxxxxxxxxxxxx>
- Date: Sun, 21 Aug 2005 07:21:30 +0100
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))
.- Follow-Ups:
- Re: Lisp's QUOTE and Mathematica's "Hold"
- From: Jon Harrop
- Re: Lisp's QUOTE and Mathematica's "Hold"
- References:
- Very poor Lisp performance
- From: Jon Harrop
- Re: Very poor Lisp performance
- From: Jon Harrop
- Re: Very poor Lisp performance
- From: Ulrich Hobelmann
- Re: Very poor Lisp performance
- From: Jon Harrop
- Re: Very poor Lisp performance
- From: Brian Downing
- Re: Lisp's QUOTE and Mathematica's "Hold"
- From: Jon Harrop
- Re: Lisp's QUOTE and Mathematica's "Hold"
- From: Nathan Baum
- Re: Lisp's QUOTE and Mathematica's "Hold"
- From: Jon Harrop
- Re: Lisp's QUOTE and Mathematica's "Hold"
- From: Nathan Baum
- Re: Lisp's QUOTE and Mathematica's "Hold"
- From: Jon Harrop
- Re: Lisp's QUOTE and Mathematica's "Hold"
- From: Nathan Baum
- Re: Lisp's QUOTE and Mathematica's "Hold"
- From: Jon Harrop
- Very poor Lisp performance
- Prev by Date: Re: Lisp's QUOTE and Mathematica's "Hold"
- Next by Date: (month year) from universal-time
- Previous by thread: Re: Lisp's QUOTE and Mathematica's "Hold"
- Next by thread: Re: Lisp's QUOTE and Mathematica's "Hold"
- Index(es):
Relevant Pages
|