From: Neil Schemenauer
Subject: Questions about code in "Art of the MOP"
Date: 
Message-ID: <kIzL8.143144$Gs.13511078@bin5.nnrp.aus1.giganews.com>
Some quick questions.  First, in the function
canonicalize-direct-slot, there is this form:

  (setq initfunction
      `(function (lambda () ,(cdr olist))))

Is this not exactly the same thing as:

  (setq initfunction
      `(lambda () ,(cdr olist)))

If so, is there _any_ reason to use the first form?  Secondly,
there is the function definition:

  (defun canonicalize-direct-superclasses (direct-superclasses)
    `(list ,@(mapcar #'canonicalize-direct-superclasses direct-superclasses)))    
Would the following be equivalent?

  (defun canonicalize-direct-superclasses (direct-superclasses)
    `(quote ,(mapcar #'canonicalize-direct-superclasses direct-superclasses)))

My understanding is that if you use ,@ or , with ` then a fresh
list will be created.  Thanks for any help.

  Neil

From: Jochen Schmidt
Subject: Re: Questions about code in "Art of the MOP"
Date: 
Message-ID: <admj7u$2t5$1@rznews2.rrze.uni-erlangen.de>
Neil Schemenauer wrote:

> Some quick questions.  First, in the function
> canonicalize-direct-slot, there is this form:
> 
>   (setq initfunction
>       `(function (lambda () ,(cdr olist))))
> 
> Is this not exactly the same thing as:
> 
>   (setq initfunction
>       `(lambda () ,(cdr olist)))

Well - take a look to what

  (macroexpand '(lambda () x))

evaluates.

ciao,
Jochen

--
http://www.dataheaven.de
From: Tim Moore
Subject: Re: Questions about code in "Art of the MOP"
Date: 
Message-ID: <admrsu$s7p$0@216.39.145.192>
On Thu, 06 Jun 2002 02:23:12 GMT, Neil Schemenauer <··········@arctrix.com> 
wrote:
>Some quick questions.  First, in the function
>canonicalize-direct-slot, there is this form:
>
>  (setq initfunction
>      `(function (lambda () ,(cdr olist))))
>
>Is this not exactly the same thing as:
>
>  (setq initfunction
>      `(lambda () ,(cdr olist)))

Yes, but AMOP was written before the ANSI standard was finalized.  I
don't recall when the lambda macro was introduced.

>If so, is there _any_ reason to use the first form?  Secondly,
>there is the function definition:
>
>  (defun canonicalize-direct-superclasses (direct-superclasses)
>    `(list ,@(mapcar #'canonicalize-direct-superclasses direct-superclasses)))    
>Would the following be equivalent?
No.

>
>  (defun canonicalize-direct-superclasses (direct-superclasses)
>    `(quote ,(mapcar #'canonicalize-direct-superclasses direct-superclasses)))
>
>My understanding is that if you use ,@ or , with ` then a fresh
>list will be created.  Thanks for any help.

canonicalize-direct-superclasses generates code that is run sometime
later.  So while your point about ,@ consing a fresh list inside
backquote is true, it's not relevant to what happens when the form returned
by canonicalize-direct-superclasses is executed.  At that time, I think
you can see,the difference between the definition in the book and
yours is pretty dramatic.  Hint: the fact that the quoted list is
constant is not the most important difference.

Tim
From: Thomas F. Burdick
Subject: Re: Questions about code in "Art of the MOP"
Date: 
Message-ID: <xcvofeokz68.fsf@apocalypse.OCF.Berkeley.EDU>
Neil Schemenauer <··········@arctrix.com> writes:

> Some quick questions.  First, in the function
> canonicalize-direct-slot, there is this form:
> 
>   (setq initfunction
>       `(function (lambda () ,(cdr olist))))
> 
> Is this not exactly the same thing as:
> 
>   (setq initfunction
>       `(lambda () ,(cdr olist)))
> 
> If so, is there _any_ reason to use the first form?

The introduction to the book says that it's supposed to load cleanly
into any CLtL1 Lisp, which didn't have the LAMBDA macro defined.

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                               
   |     ) |                               
  (`-.  '--.)                              
   `. )----'