What's the difference between PUSH and CONS?
Also, what does the free-list register do?
Also, what does the free-list register do?
The free list holds all the cons cells not in use. Note that in this machine, there is no way to create or destroy cons cells - that's the whole point! Rather, when you need to cons some values, you pull a cell off the free list and populate it (see the implementation of CONS), and when you want to throw a cons cell away, you put it back on the free list (see the implementations of POP and FREE).
CL-USER> (let ((list (list 1 2 3 4)))
(cons 5 list)
list)
(1 2 3 4)
CL-USER> (let ((list (list 1 2 3 4)))
(push 5 list )
list)
(5 1 2 3 4)