How Function Create Variables?
- From: "daidongLY@xxxxxxxxx" <daidongLY@xxxxxxxxx>
- Date: Mon, 30 Jul 2007 03:17:37 -0700
The Common-User-Package's Function: copy-seq is not deep enough to
copy old list to a new list as it's more fit for sequence, So here is
a new deep-copy function:
(defun my-copylist (list)
(if (or (not list) (not (listp list)))
list
(cons (my-copylist (first list))
(my-copylist (rest list))))
This works well even for the lists like ( (a b) (c d) ), However I
don't know how can this function create these new cons cells. I still
remember, In C, returning new variables created in a function needs
"malloc" functions, and this new variable must be linked with the
outside variables. But in 'my-copylist' function, it seems that the
variable -- 'list' is bound from the parameter -- 'list'. Then how
could this new list be created?
I don't know whether i have clearly stated my question, so i wanted to
ask it again: What's the difference in local/dynamic variables
creating/binding inside a function? Between CL and the C-style
programming language...
.
- Follow-Ups:
- Re: How Function Create Variables?
- From: Alex Mizrahi
- Re: How Function Create Variables?
- Prev by Date: Re: erase files from LISP
- Next by Date: Re: How Function Create Variables?
- Previous by thread: erase files from LISP
- Next by thread: Re: How Function Create Variables?
- Index(es):
Relevant Pages
|