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



Jon Harrop wrote:
Nathan Baum wrote:

This distinction is very significant, because QUOTE only 'protects'
against one round of evaluation.

(EVAL A)   => <the result of evaluating the value of A>
(EVAL 'A)  => <the value of A>
(EVAL ''A) => A

In a hypothetical Mathematica-like dialect of Lisp,

A          => <the value of A>
'A         => <the value of A>
''A        => <the value of A>
(EVAL A)   => <the value of A>
(EVAL 'A)  => <the value of A>
(EVAL ''A) => <the value of A>


No:


You misunderstand me. I mean that the Mathematica equivalent of 'X, which I suppose is just (X), would behave that way.


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

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



Relevant Pages

  • Fundamentals of the Mathematica Programming Language note set by Richard J. Gaylord available
    ... to give you a flavor of what i am trying to emphasize in the note set, ... Mathematica Programming Fundamentals: ... When the lhs of a rewrite ... Evaluation then proceeds by searching for further matching ...
    (sci.math.symbolic)
  • Re: Very poor Lisp performance / about Mathematica
    ... his personal experience interacting with Mathematica. ... assume that Jon has the language design and semantics experience to ... , the order of evaluation is not specified, but the ... > Just as you use quote in a Lisp macro. ...
    (comp.lang.lisp)
  • Re: Very poor Lisp performance / about Mathematica
    ... > The site uses Mathematica to do its math. ... backquote and comma in CLTL. ... So,,@q means ``the value of q is a list of forms; splice the list ... available at the time of second evaluation, that is, when the ...
    (comp.lang.lisp)
  • Re: Where comes the myth that Lisp is interpreted?!
    ... operations of Mathematica in OCaml. ... A.4.1 The Standard Evaluation Sequence ... Unless h has attribute HoldAllComplete strip the outermost of any ...
    (comp.lang.lisp)
  • Re: Lisps QUOTE and Mathematicas "Hold"
    ... >> You can see Hold in Mathematica but not QUOTE in Lisp but isn't that more ... At least in Lisp case, the QUOTE form was evaluated and it ... However, despite the difference in method of evaluation, the results are ...
    (comp.lang.lisp)