Ronald wrote:
> Any different? '(1 2) (list 1 2)
'(1 2) is the same as (quote (1 2)); it returns a literal list, created
at compile time.
(list 1 2) is an expression that can create a new list each time it's
evaluated.
It's similar to the difference between a literal string:
"foobar"
and a piece of code (in any language) that allocates a string and
stuffs the characters 'f' 'o' 'o 'b' 'a' 'r' into it.
> * Ronald <·········@163.pbz> [2006-12-26 13:55:03 +0800]:
>
> Any different? '(1 2) (list 1 2)
'(1 2) is a literal object, created once.
(list 1 2) is a function call, it returns a fresh (newly allocated) list
on each invocation.
(equal '(1 2) (list 1 2)) ==> T
(defun f () '(1 2))
(eq (f) (f)) ==> T
(defun g () (list 1 2))
(eq (g) (g)) ==> NIL
(equal (g) (g)) ==> T
you should _never_ modify literal objects,
see http://clisp.cons.org/impnotes/faq.html#faq-self-mod
--
Sam Steingold (http://sds.podval.org/) on Fedora Core release 6 (Zod)
http://memri.org http://israelunderattack.slide.com http://camera.org
http://jihadwatch.org http://ffii.org http://honestreporting.com
Programming is like sex: one mistake and you have to support it for a lifetime.