Hi, On Tue, Feb 17, 2009 at 7:20 PM, Francesco Petrogalli <[email protected]> wrote: > Am I completely wrong with this schema? I thought the cdr of and an element > of a list was the "memory address" of the next element (well, in fact this > is no sense with garbage collection...), and that the list (2) returned by a > code like (cdr (list 1 2)) was just the the interpretation of the memory > address... something like "the value of (cdr (list 1 2)) is a pointer to a > list, SO I show you a list".
besides the good answer by Albert, I'd like to add a couple of subtle things which might interest you. Actually *both* the car and the cdr of a cons are "memory addresses" or better storage locations (which in the general case contain "pointers" although many Lisp implementations store certain types of values directly for efficiency - e.g. "fixnums", that is integers of fixed bit length). And, this has still much sense with garbage collection :) - reasonable gc algorithms do account for things like circular structures. The fact that a "chain" of conses terminated by NIL is a "list" is just a useful abstraction provided by Lisp. Happy Lisping, Alessio _______________________________________________ Gardeners mailing list [email protected] http://www.lispniks.com/mailman/listinfo/gardeners
