Re: Lisp's QUOTE and Mathematica's "Hold"
- From: Jon Harrop <usenet@xxxxxxxxxxxxxx>
- Date: Sun, 21 Aug 2005 05:32:21 +0100
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
.
- Follow-Ups:
- 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
- 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
- Very poor Lisp performance
- Prev by Date: Re: Lisp's QUOTE and Mathematica's "Hold"
- Next by Date: Re: Lisp's QUOTE and Mathematica's "Hold"
- 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
|