Post
by Paul Donnelly » Mon May 04, 2009 9:38 pm
If we're looking at the same example, it works as follows.
"input to REST" and "Result of REST" are both pointers — that is, values which indicate some specific object. In the first diagram, "Input to REST" is pointing to the cons whose car is "THE". In the second, "Result of REST" is pointing to the cons whose car is "BIG". Think of a pointer as an address that gets passed around. If we have:
1 Memory Lane: A cons containing THE and another cons.
2 Memory Lane: A cons containing BIG and another cons.
3 Memory Lane: A cons containing BOPPER and NIL.
What actually get passed around are these addresses, and each cons (and symbol, and other object) stays where it always was. So "Input to REST" is "1 Mem. Ln.", and "Result of REST" is "2 Mem. Ln.". The zigzag arrow depicts this graphically. Rest was given the first address, it examined the cons and returned the second address. The arrows aren't showing the flow of data, rather the structure of the data at particular moments in time.
Clearer?
In languages like C, pointers are variables which hold literal memory addresses, and a programmer has to explicitly look up the data a pointer points to to get at it. In Lisp, pointers are all implicit, partly because who cares where in memory objects actually lie, and partly because attempting to use that knowledge would likely end poorly, since the garbage collector could rearrange all our objects at any time, maintaining only the structure of who points to whom.