What is the difference between '(abc) and (list' a 'b' c)?
I read "On lisp" and ran into this code (I simplified it a bit).
CL-USER> (defun foo () '(abc)) FOO CL-USER> (foo) (ABC) CL-USER> (nconc * '(DE)) (ABCDE) CL-USER> (foo) (ABCDE) CL-USER> (defun foo () (list 'a 'b 'c)) STYLE-WARNING: redefining FOO in DEFUN FOO CL-USER> (foo) (ABC) CL-USER> (nconc * '(DE)) (ABCDE) CL-USER> (foo) (ABC) What does
*mean? Is this a previous function call? Can I use code in the real world?Why
(nconc * '(DE))change the return value of the first functionfoo?I always thought that
(list 'a 'b 'c)and'(abc)match? What is the difference?
When LIST is called, a new list is created each time it is computed. A list literal can be placed in a read-only memory segment after compilation. Destructive updating in lists using NCONC is then problematic, possibly with undefined consequences (segmentation error, literal change for future links or nothing at all).
The variables * , ** and *** are indicated by the standard language, and they are very useful when testing things. They are a feature of REPL, and therefore they should not and should not be useful in "real-world code."