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



In article <4307f387$0$1285$ed2619ec@xxxxxxxxxxxxxxxxxxxxxxxxxx>,
Jon Harrop <usenet@xxxxxxxxxxxxxx> wrote:
> Both QUOTE and Hold retain subexpressions in unevaluated form. Perhaps the
> similarity ends there...

Indeed.

> Brian Downing wrote:
> > (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?

Absolutely not. QUOTE is /gone/. It has served its purpose. Lisp only
evaluates things once.

> > 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

CL-USER 14 > (eq (quote (+ 2 2)) (quote (+ 2 2)))
NIL

CL-USER 15 > (defparameter *plus-two-two* (quote (+ 2 2)))
*PLUS-TWO-TWO*

CL-USER 16 > (eq *plus-two-two* *plus-two-two*)
T

-bcd
--
*** Brian Downing <bdowning at lavos dot net>
.



Relevant Pages

  • Re: Very poor Lisp performance
    ... I think that's exactly the same as "Hold" in Mathematica. ... i.e., Hold "sticks" with the expression, whereas QUOTE is just a signal ... to the evaluator to pass its contents through unevaluated. ... Prev by Date: ...
    (comp.lang.lisp)
  • Re: Lisp Beginner question
    ... >> because QUOTE works on lists as well as atoms. ... Using ' as an abbreviation for QUOTE ... A question I kept asking myself for the first few dozen hours of my lisp ... experience was "How does the evaluator know when to stop evaluating?" ...
    (comp.lang.lisp)
  • Re: Lisps QUOTE and Mathematicas "Hold"
    ... > Both QUOTE and Hold retain subexpressions in unevaluated form. ... >> to the evaluator to pass its contents through unevaluated. ... >> noop in the Mathematica evaluator. ...
    (comp.lang.lisp)
  • Re: Lisps QUOTE and Mathematicas "Hold"
    ... Both QUOTE and Hold retain subexpressions in unevaluated form. ... > to the evaluator to pass its contents through unevaluated. ... > noop in the Mathematica evaluator. ...
    (comp.lang.lisp)
  • Re: Lisps QUOTE and Mathematicas "Hold"
    ... Jon Harrop wrote: 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. ...
    (comp.lang.lisp)