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)
  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)
  second
  arc> x
  (new second c)
  arc> (= (car (cdr (cdr x))) 'third)
  third
  arc> x
  (new second third)
These last two examples would expand to

  (scar (cdr x) 'second)
and

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