Arc Forumnew | comments | leaders | submitlogin
1 point by cje 5103 days ago | link | parent

Not exactly, no. The first argument isn't evaluated, but "=" looks at it to let you do convenient things like that.

In fact, "=" is actually a fancy macro, which transforms (= (car x) 'z) into (scar x 'z), where "scar" is the set-car function.

For example:

  arc> (= x '(a b c))
  (a b c)
  arc> (= (car x) 'new)
  arc> x
  (new b c)
The fancy bit here is that only the "outermost" form of the first argument is specially processed:

  arc> (= (car (cdr x)) 'second)
  arc> x
  (new second c)
  arc> (= (car (cdr (cdr x))) 'third)
  arc> x
  (new second third)
These last two examples would expand to

  (scar (cdr x) 'second)

  (scar (cdr (cdr x)) 'third))
Common Lisp does essentially the same thing with "setf".