Re: Lisp's QUOTE and Mathematica's "Hold"
- From: Jon Harrop <usenet@xxxxxxxxxxxxxx>
- Date: Sun, 21 Aug 2005 04:19:59 +0100
Brian Downing wrote:
> In article <43062cf8$0$22943$ed2619ec@xxxxxxxxxxxxxxxxxxxxxxxxxx>,
> Jon Harrop <usenet@xxxxxxxxxxxxxx> wrote:
>> Right. I think that's exactly the same as "Hold" in Mathematica.
>
> Not really.
Both QUOTE and Hold retain subexpressions in unevaluated form. Perhaps the
similarity ends there...
> (defparameter *test* (quote (+ 2 2))) ==> *TEST* contains (+ 2 2).
>
> test = Hold[2 + 2] ==> test contains Hold[2 + 2]
>
> i.e., Hold "sticks" with the expression, whereas QUOTE is just a signal
> to the evaluator to pass its contents through unevaluated. You can't
> build something as simple as QUOTE in Mathematica because the evaluator
> will keep evaluating until it stops changing - the CL QUOTE would be a
> noop in the Mathematica evaluator.
You can see Hold in Mathematica but not QUOTE in Lisp but isn't that more a
function of the pretty printer rather than the evaluation?
> Note also that CL has a very strong sense of object identity. If I say
> (quote (+ 2 2)), I get the exact same (EQ) cons out that I put in. I
> don't think Mathematica has anything like EQ, so I'm not sure how you'd
> test to see if the Plus[2, 2] in a hold is the same Plus[2, 2] you put
> in earlier.
In[1]:= Hold[2+2] === Hold[2+2]
Out[1]= True
In[2]:= Hold[a+b] === Hold[b+a]
Out[2]= False
So the Mathematica:
Release[Hold[expr]]
is equivalent to the Lisp:
(eval (quote expr))
Beyond that, evaluation is completely different. But just looking at QUOTE
and Hold, there is an uncanny resemblance.
--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com
.
- Follow-Ups:
- Re: Lisp's QUOTE and Mathematica's "Hold"
- From: Nathan Baum
- Re: Lisp's QUOTE and Mathematica's "Hold"
- From: Peter Seibel
- Re: Lisp's QUOTE and Mathematica's "Hold"
- From: Brian Downing
- Re: Lisp's QUOTE and Mathematica's "Hold"
- From: Nathan Baum
- 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
- Very poor Lisp performance
- Prev by Date: Re: TELNET (was: Lisp/Unix impedance [a programming challenge])
- Next by Date: Re: Hypercube in lisp (newbie)
- Previous by thread: Re: Very poor Lisp performance
- Next by thread: Re: Lisp's QUOTE and Mathematica's "Hold"
- Index(es):
Relevant Pages
|