What's happening in your code?
First, let's define the macro, look at the macroexpansion, and look at the result of evaluating a form using this macro. Then we figure out why each form produces what it does. The definition is easy; you've already provided that:
CL-USER> (defmacro my-eval (x)
(car (cdr x)))
MY-EVAL
Now let's take a look at what the macroexpansion of (my-eval '(car '(1 2 3))) is:
CL-USER> (macroexpand-1 '(my-eval '(car '(1 2 3))))
(CAR '(1 2 3))
T
This is what we should expect. The form '(car '(1 2 3)) is short for
(quote (car (quote (1 2 3))))
The cdr of that is
((car (quote (1 2 3))))
The car of that is
(car (quote (1 2 3)))
That's the code that that (my-eval '(car '(1 2 3))) will be replaced by. That means that when we evaluate (my-eval '(car '(1 2 3))), we should expect to see the same results as if we had evaluated that directly. Of course, (car '(1 2 3)) evaluates to 1. Let's check:
CL-USER> (my-eval '(car '(1 2 3)))
1
What did you want to happen?
quote is a special operator in Common Lisp. It has the special behavior that (quote object) returns object. object doesn't get evaluated. If it's a list, then you get a list back; if it's a number you get a number back, etc. But where does the object come from? In most cases, you're reading Lisp code form a file, or from a stream, and it's the reader's responsibility for creating the object from the textual representation. E.g., when you write '53, or (quote 53), you get a number because the reader already produces the number 53 from you and returns the form that could be produced by (list 'quote 53) (or (list 'quote '53)). When the evaluator receives that form, it recognizes that it's a list and that the car of that list is the symbol quote, and so invokes the special operator named by quote with the argument that is the second object of the list. That's a special behavior coded into the system.
Macros, on the other hand, allow you transform some forms, after they've been read by the reader, into new forms that can be passed to the evaluator. If you're trying to implement your own quote-like form as macro, what would it need to do? It would need to turn
(kwote object)
into a form that would be guaranteed to evaluate to object. You can't simply expand to object, because you don't want to pass the object to the evaluator. If it's something that can be treated as another form, the evaluator will try to do more evaluation on it. The only thing that you can pass to the evaluator to be guaranteed to get object back is a list of the
(quote object)
This means that if you want to implement your own quote, you'll have to do it terms of te built-in quote. E.g.,
CL-USER> (defmacro kwote (object)
(list 'quote object))
KWOTE
CL-USER> (kwote (1 2 3))
(1 2 3)
CL-USER> (kwote (car '(1 2 3)))
(CAR '(1 2 3))
CL-USER> (kwote '(car '(1 2 3)))
'(CAR '(1 2 3))
quote(without using the built inquote). I've added an answer that covers the first, and takes a stab at the second. In short, the special behavior ofquotesomething built into the evaluator, and can't be factored out into macros alone. - Joshua Taylor