I'm new to common lisp, so hope someone would clarify this to me:
say we have a list and want to add an item with push
to modify it:
CL-USER> (defparameter xx '(1 2 3))
XX
CL-USER> xx
(1 2 3)
CL-USER> (push 100 xx)
(100 1 2 3)
CL-USER> xx
(100 1 2 3)
as expected. But when i try to do the same with the function, it doesn't modify a list:
CL-USER> (defun push-200 (my-list)
(push 200 my-list))
PUSH-200
CL-USER> (push-200 xx)
(200 100 1 2 3)
CL-USER> xx
(100 1 2 3)
so i tried to compare argument and my list like this:
CL-USER> (defun push-200 (my-list)
(format t "~a" (eq my-list xx))
(push 200 my-list))
WARNING: redefining COMMON-LISP-USER::PUSH-200 in DEFUN
PUSH-200
CL-USER> (push-200 xx)
T
(200 100 1 2 3)
CL-USER> xx
(100 1 2 3)
it says the objects are identical. So the question is: what was the thing I've overlooked here?