Subject: Re: basic question on lambda From: Erik Naggum <erik@naggum.net> Date: 2000/10/24 Newsgroups: comp.lang.lisp Message-ID: <3181390601712381@naggum.net> * Nils Goesche <nils.goesche@anylinx.de> | What is this all about? Why do all Lisp books put #' in front of a | lambda expression? And why does it work with #' and a lambda | expression but not with #' and a ``curry'' expression? #'x is actually short for (function x), which quotes x in a functional context, like 'x is short for (quote x), which quotes x in data/variable context. Look up the special operator function and quote in your friendly standard reference material for the whole story. Specifically, (function (lambda ...)) causes interpretation of the (lambda ...) as a function (which means it may be funcalled, and will be compiled), which (quote (lambda ...)) does not. Why would you want to quote (curry ...) in a functional context? | BTW, if it has to do with `read macros', note that I don't know what | a read macro actually is :-( It has nothing to do with reader macros. A reader macro is a function called by the reader to return a Lisp object from parsing or otherwise processing the input stream. There's a reader macro for the character ( which causes the elements up to the matching ) to be returned as a list, for instance. The reader macro for ' returns a list with quote as the first element and the next element taken directly from the input stream. #' does the same, only with function instead of quote. Lack of understanding of reader macros should not impact your appreciation of the full form they return. If you are not comfortable with reader macros, write things out in full, instead, thus encouraging your appreciation of the shorthand when you understand exactly what it does. In other words: Write (function x) where your textbooks write #'x. Note that you don't need to write (function (lambda ...)) because (lambda ...) is a macro that expands to (function (lambda ...)). I think it helps understanding Common Lisp's evaluation to think of lambda as returning an anonymous function, and to disregard the sometimes confusing #' or function special form. Consequently, I never quote lambda forms and consider it redundant to do so. #:Erik -- I agree with everything you say, but I would attack to death your right to say it. -- Tom Stoppard