From: feilong

Subject: Length again and definition of macro

Date: 2003-1-15 17:02

Hello,freinds:
Just now i have tried to get the length of (length (quote quote)),but i get the error message. 

CG-USER(8): (length (quote quote))
Error: attempt to take the length of a non-sequence: QUOTE
[condition type: SIMPLE-ERROR]
 
I have not very understood, (length (quote '(1 2 3))) is 2, (length (quote quote)) should be also 2, while this list consist 2 parts(quote + quote), and quote is macro, semantic is also correct. And if (length (quote '(1 2 3))) is 2, then (length (list '(1 2 3))) should be also 2, while this list has 2 parts: symbol list and list (1 2 3). But the result is 3. Why? Whether quote operator does not evaluats the expression, aber list operator must evaluate the expression.

CG-USER(2): (length (list 1 2 3))
3

Why is the begin of definition of makro almost list operator. For example own definition my-if
(defmacro my-if (test then else)
          (list '(cond (list test then) (list 't else))) ;;part1

Can I so define the body of macro: (cond (test then) (t else));;part2 
while i thinkd part1 is equivalent to part2, can man replace part1 with part2? What is the difference?

Another example: own nil macro
(defmacro nil! (x)
          (list 'setf x nil));;part1 is equal to setf x nil
Can man replace part1 with (setf x nil)?

Best Greetings  
Xu