From ... From: Erik Naggum Subject: Re: basic question on lambda Date: 2000/10/24 Message-ID: <3181390601712381@naggum.net>#1/1 X-Deja-AN: 685281055 References: mail-copies-to: never Content-Type: text/plain; charset=us-ascii X-Complaints-To: newsmaster@eunet.no X-Trace: oslo-nntp.eunet.no 972403059 4981 195.0.192.66 (24 Oct 2000 15:57:39 GMT) Organization: Naggum Software; vox: +47 800 35477; gsm: +47 93 256 360; fax: +47 93 270 868; http://naggum.no; http://naggum.net User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7 Mime-Version: 1.0 NNTP-Posting-Date: 24 Oct 2000 15:57:39 GMT Newsgroups: comp.lang.lisp * Nils Goesche | 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