Subject: Re: #'(lambda ... (lambda
From: Erik Naggum <erik@naggum.net>
Date: Tue, 16 Apr 2002 18:37:28 GMT
Newsgroups: comp.lang.lisp
Message-ID: <3227971048368989@naggum.net>

* "Luke Crook"
| I was wondering why this:
| 
| (setf (symbol-function 'double) #'(lambda (x) (* x 2)))
| 
| is the same as:
| 
| (setf (symbol-function 'double) (lambda (x) (* x 2)))

  They are not the same.  They have the same effect.  Lots of things have
  the same effect.  Just because two things have the same effect, does not
  mean you can use the difference as basis for any inference about other
  things that are similarly different without understanding the cause.
  Quite elementary logic, this.  If you do not command a reasonable level
  of reasoning, you will go wrong in so many wasteful ways that you should
  go back to study reasoning and logic, and not attempt to stumble along
  with random guesswork and clueless trial and error.

| Why doesn't the setf in the latter return an error when it tries to
| evaluate the lambda expression?

  Look it up in your favorite Common Lisp reference.  Things like this are
  very well explained in every serious introduction to Common Lisp, and
  then you have the specification.

  But how did you manage to write this code in the first place?  It is so
  odd to mess with the symbol-function slot of a symbol without knowing
  what #' means or how the macro lambda works.

///
-- 
  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.

  Post with compassion: http://home.chello.no/~xyzzy/kitten.jpg