From: Scott D. Anderson
Subject: Re: A Bug?
Date: 
Message-ID: <ANDERSON.95Feb28124408@earhart.cs.umass.edu>
In article <··········@mogan.cc.metu.edu.tr> ·····@rorqual.cc.metu.edu.tr (levent erkok) writes:

>  A number of people responded to my question, I want to thank them all. 
> But I didn't understand why they didn't follow up my question but rather
> replied me directly.     
>  
>  After those replies I got the following code:
> 
>   ;;; count number of item's in s
>   (defun mycount (item s)
>    (cond ((equal s item) 1)
>           ((atom s) 0)
>           (t (apply #'+ (mapcar #'(lambda (e) 
>                                         (mycount item e))
>                                s)))))
> 
>  That is just a # prepended before '+ and '(lambda.
> 
>  This works fine, and does the required job. But nobody explained me the
> semantics of #'. Unfortunately my book doesn't cover it, and I'm stuck.
> I would be happy if somebody explains what this means.
> 
>  Thanks in advance.
>   
>  /*
>   * Levent ERKOK.
>   * Research Assistant,
>   * Middle East Technical University, Department of Computer Engineering.
>   * 06531, Ankara, Turkiye.
>   * E-Mail: ·····@ceng.metu.edu.tr
>   *
>   */

You should probably get a copy of CLtL2 (Common Lisp the Language, by Guy
L. Steele Jr) as a reference guide.  It's not a tutorial, but it will answer
questions like this.

Briefly, #'<form> is a read macro equivalent to typing (function <form>), as
opposed to '<form> which is equivalent to typing (quote <form>).  The FUNCTION
special form keeps its argument from being evaluated, just as QUOTE does, but in
addition it tells the compiler that the form is a function, thereby giving the
compiler the opportunity to treat it specially.  In particular, in the case
where <form> is a lambda, it will compile that lambda.  In your case, the
compilation is necessary so that the lexical closure is handled correctly.

Some implementations permit QUOTE (') in places where FUNCTION (#') is
technically required, which is probably why the #' wasn't used in your book.

I hope this helps.

Scott D. Anderson
········@cs.umass.edu