Re: Lisp's QUOTE and Mathematica's "Hold"
- From: Nathan Baum <nathan_baum@xxxxxxxxxxxxxx>
- Date: Sun, 21 Aug 2005 06:44:34 +0100
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.
.
- 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: Peter Seibel
- 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: josephoswaldgg@xxxxxxxxxxx
- Very poor Lisp performance
- Prev by Date: Re: Lisp's QUOTE and Mathematica's "Hold"
- Next by Date: Re: Very poor Lisp performance
- 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
|