From ... Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed1.bredband.com!bredband!uio.no!Norway.EU.net!not-for-mail From: Erik Naggum Newsgroups: comp.lang.lisp Subject: Re: Basics of #'(lambda ... Date: 19 Aug 2002 16:54:32 +0000 Organization: Naggum Software, Oslo, Norway Lines: 37 Message-ID: <3238764872794264@naggum.no> References: <3D6107AD.82AFE53B@in.the.newsgroup> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: oslo-nntp.eunet.no 1029776073 18785 193.71.199.50 (19 Aug 2002 16:54:33 GMT) X-Complaints-To: abuse@KPNQwest.no NNTP-Posting-Date: 19 Aug 2002 16:54:33 GMT Mail-Copies-To: never User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.lisp:38319 * Eli Bendersky | However, if I try to omit the #' (which seems logical to me as mapcar really | accepts a function, so to complicate it by dereferencing a symbol doesn't | make much sense) #' is a reader macro just like '. #'x means (function x) just as 'x means (quote x). It is not as optional as you might think. If you come from a Scheme background (which I believe you might do because you think that "logical" /alone/ is useful and has anything to do with language design, i.e., "alone" as apart from the /premises/ of the logic employed), you should realize that Common Lisp is not a dialect of Scheme and that you should endeavor to understand it in its own right. `lambda´ is a macro that returns the whole form wrapped in a `function´, so if you observe that it "works", the important thing is to understand /why/. So when you evaluate (lambda (x) (+ x 10)), the macro is first expanded so you get (function (lambda (x) (+ x 10))) which can then be evaluated to a function object and returned. | Could you Lisp gurus please elaborate? What is the right way to do it? The right way is to understand what the `function´ special operator does and then to use it consistently. If you feel uncomfortable with the heavy use of punctuation marks in the #' reader macro, the easiest solution is to write "function" out in full. As you get more experienced with Common Lisp, you will see that `function´ is also used to name functions that consist of more than a symbol name, so your initial assumption that it is the same as `symbol-function´ should be discarded as soon as possible. -- Erik Naggum, Oslo, Norway Act from reason, and failure makes you rethink and study harder. Act from faith, and failure makes you blame someone and push harder.