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



josephoswaldgg@xxxxxxxxxxx wrote:
Nathan Baum wrote:

It only _looks_ like Lisp is similar to Mathematica because Lisp
expressions can evaluate to Lisp expressions. If Lisp was virtually the
same as Mathematica, programs could only be written to use
self-evaluating types: there'd be no lists or symbols.

  (print '(list + 1 2))

wouldn't print (LIST + 1 2), nor (+ 1 2), but 3. The initial evaluation
of QUOTE would produce (LIST + 1 2), which is not a self-evaluating form
and would therefore be evaluated to produce (+ 1 2), which is not a
self-evaluating form and would therefore be evaluated to produce 3,
which is a self-evaluating form and would therefore not be evaluated
because further evaluation would have no effect.


Careful; remember Common Lisp *has* a variable with the name + (which
evaluates to the previous form form evaluated at the REPL). I'm
surprised no one has been burned by this yet in this discussion.


Hmm. You mean that evaluation would proceed as

  (print '(list + 1 2))
  => (print (list + 1 2))
  => (print (list (print '(list + 1 2)) 1 2))
  => (print (list (print (list + 1 2)) 1 2))
  => (print (list (print (list (print '(list + 1 2)) 1 2)) 1 2))
  => (print (list (print (list (print (list + 1 2)) 1 2)) 1 2))
  => (print (list (print (list (print (list (print '(list + 1 2)) 1 2))
                          1 2)) 1 2))
  => ...

until we got a stack overflow or out of memory error, depending upon how the expansion was implemented.

Presumably, a Lisp which used Mathematica-style evaluation would want to be a Lisp-1, so this kind of problem could not occur.
.




Relevant Pages

  • Re: Lisps QUOTE and Mathematicas "Hold"
    ... So all Mathematica equivalents must be quoted at least ... So cannot be a Lisp equivalent of anything in Mathematica, ... >> not trying to say that the subsequent evaluation of the enclosing ... to implement Mathematica's capabilities in Lisp, i.e. using s-exprs. ...
    (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)
  • Re: Lisp and Scheme with fewer parentheses / Mathematica??
    ... Try to get out of lisp mindset, and view things from general humanity. ... whether, is it reasonable, to say that programing in mathematica is ... Lisp has a 'simpler' and more straight forward model evaluation model. ... is more to be a straight-forward implementation language ...
    (comp.lang.lisp)
  • Re: Lisp syntax vs. Mathematica syntax
    ... That is, in an ordinary lisp, ... If you want to quote x in Mathematica, ... of quote, evaluation, etc. because there are many items ... macro that reduces expressions like "3+10". ...
    (comp.lang.lisp)
  • Re: Lisps QUOTE and Mathematicas "Hold"
    ... > It only _looks_ like Lisp is similar to Mathematica because Lisp ... > expressions can evaluate to Lisp expressions. ... > which is a self-evaluating form and would therefore not be evaluated ... > because further evaluation would have no effect. ...
    (comp.lang.lisp)