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



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

> Mathematica has no _real_ equivalent of Lisp's QUOTE, since Mathematica
> 'fully evaluates' every expression: i.e. keeps evaluating it until
> further evaluation will not produce a different value. Hold is possible
> precisely because Hold[x] evalutes to Hold[x].

But "fully evaluating" to the same expression is the same as leaving
unevaluated?

> Another example of the difference between QUOTE and Hold: = holds its
> first argument, so assuming b doesn't have a value,
>
> a = b
>
> assigns b to a, but Evaluate overrides Hold so
>
> Evaluate[a] = 42
>
> assigns 42 to b, the result of evaluating a. (Or so the Matgematica
> documentation tells me)
>
> The Lisp function setq quotes its first argument, so
>
> (setq a 'b)
>
> assigns 'b to a. But eval _doesn't_ override this, and
>
> (setq (eval a) 42)
>
> is an error.

Yes. The Lisp equivalent is probably:

(eval (list `setq a 42))

which sets b to 42.

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.

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com
.



Relevant Pages

  • Re: Trying to understand macros
    ... quote stops evaluation and thus macroexpansion. ... is not appropriately evaluated by first evaluating the inner ... The very meaning of QUOTE is "do not evaluate this", ...
    (comp.lang.lisp)
  • Re: acceptable obsessions
    ... Best I can tell, this quote is implausible for X=SF, at least in common ... for values of "young" less than my age. ... The line I draw for that is age twenty. ... Evaluating all GUIs by the example of Windows is like evaluating all cars ...
    (rec.arts.sf.fandom)
  • Re: Stock price downloader
    ... I have already looked at ashkon and quote and ... evaluating them. ... Can you post the link to Interactive Brokers and esignal? ... Joe ...
    (borland.public.delphi.non-technical)
  • Re: Stock price downloader
    ... > I have already looked (only browsed the interface) at ashkon and ... > quote and evaluating them. ...
    (borland.public.delphi.non-technical)