Assume a=(0). When you push 1 to a, you will exchange a by (1 . (0)), then you replace b by ((1 . (0)) . b) and then you replace a by (2 . (1 . (0))).

You have to try it in a different way. One thing I could think of is to write an own push-macro which pushes the values on both lists. You could try to use structs which point to another object, and set this pointer to another value. Or to implement a similar data structure by your own.

If [xy] is a cons cell and _ is nil, then a trace of your code looks likea=_b=_a=[1a]=[1_]b=[ab]=[[1_]_]a=[2a]=[2[1_]]where the lisp printer hides nil when it ends a list.

In the last step, A now points to a different object; B still points to the old A. If you want B to see the new definition of A, you must change the structure A refers to, not simply bind a new value to A...

I am sorry for the confusion, I know that I am getting what I am suppose, my question was if there is a way to handle something like pointers in C, which is normally done using * and &.I guess you achieve that by a correct use of car's and cdr's. Because as nuntilus (aka daniel) suggest, doing

No references/pointers, although, often you should not be using them, i think lisp should have them. I have a project where i am working on a lisp with (among others) a better typing system, and i will put references/pointers in there.

@gugamilare: i associate using the first element of a list as a reference with pain. That might be because programming non-functionally can cause trouble, or just because i was not as good a programmer back then, though.