On the relationship of (LAMBDA (...) ...) and #'(LAMBDA (...) ...).

People frequently ask about the difference between (LAMBDA (...) ...) and #'(LAMBDA (...) ...). Saying there is no difference is, however, an oversimplifcation that leaves out some details from the Common Lisp standard.

In an evaluated context, the relationship between the two forms can be described accurately by saying that LAMBDA is actually a macro that expands the first form into the second one.
(defmacro lambda (&whole whole args &body body)
  (declare (ignore args body))
It follows that in an evaluated context, the two forms are thus completely synonymous. Note that the form involving FUNCTION is strictly more primitive, and is what causes the creation of a lexical closure eventually.

Howsoever, there are some unevaluated contexts in which you're only allowed to use the former, but not the latter form:

  • The CAR of a form must usually be a symbol, naming the function, macro, or special operator that is supposed to be invoked.

    As a special exception to that rule (historically for ISLISP compatibility), the CAR of a form can also be (LAMBDA (...) ...).

    ((lambda (x) (* x x)) 2) ==> 4
    See CLHS section
  • The :interactive, :report, and :test arguments of a clause in RESTART-CASE take (LAMBDA (...) ...), but not #'(LAMBDA (...) ...) forms.
  • Likewise for the :print-function, and :print-object options of DEFSTRUCT.


About this blog

The purpose of my blog is to share the knowledge I have acquired over the last 4 years I've been learning Common Lisp. Even after (almost) 4 years, I wouldn't dare to assert to know the language in its entirety; there are still major areas I'm only superficially familiar with.

My rationale behind this endeavor is two-fold.
  • On one hand, I want to offer a ressource for people that already have experience with Common Lisp to gain even more thorough understanding of the language---so they can ascent to the next level so to speak.
  • On the other hand, I want to preserve information for myself. The human mind is generally not capable of keeping too many details for a long period of time around. Hence, I'd like to use this blog as a swapping device for stuff I once spent time on.

I'll start with a series about writing macros correctly---correctly as in consistently to how the macros in the Common Lisp standard behave. There are lot more issues involved in writing correct macros than the widely known problems of unwanted variable capture, and multiple evaluation.

I'm looking forward to comments about the upcomming postings, and to suggestions for things to write about. You can always reach me via e-mail (trittweiler, common-lisp, net.)



Slime Talk 2008

Last Wednesday, I gave a talk to the Munich Lisp Group about SLIME, the Superior Lisp Interaction Mode for Emacs. An perfect opportunity for opening my blog!

The presentation can be found at

It was an honor to see that so many people (about 25), partly from very far abroad!, showed up to see myself talk about the stuff I hacked over the past two years. The age distribution was also very diverse, from early twenties to mid forties, I guess. I was especially pleased to notice that the average age drifted more towards the younger end than to the older one.

The background of all the people was also very diverse, and very fascinating. As the resonance of the talk has been very positive (thanks all!), it was decided to regularly uphold such meetings in the future. If you're close to Munich, go, and subscribe to the mailinglist!