From: NF Stevens
Subject: Problem with macro expansion
Date: 
Message-ID: <3594419e.13518195@news.u-net.com>
I am a total novice at lisp. I recently downloaded a some
lisp source code and have been struggling to get it working.
Unfortunately the code is quite old and was written for a
different lisp system. I'm using CLISP on win32.

At the moment I'm completely stumped by a problem with
macros which include a recursive definition. The relevant
macro definitions are as follows.

% Redefinition of DE and DM to make it call PUTD as it should in Standard
% Lisp. The purpouse is to make it look for the LOSE flag. JEA
(DM DE (U)
 (LIST 'PUTD (LIST 'QUOTE (CADR U)) '(QUOTE EXPR)
  (LIST 'QUOTE (CONS 'LAMBDA (CONS (CADDR U) (CDDDR U)))) ) )

(DM DM (U)
 (LIST 'PUTD (LIST 'QUOTE (CADR U)) '(QUOTE MACRO)
  (LIST 'QUOTE (CONS 'LAMBDA (CONS (CADDR U) (CDDDR U)))) ) )

(DE COPY (X)
 (COND
  ((PAIRP X) (CONS (COPY (CAR X)) (COPY (CDR X))))
  (T X) ) )

When I try to use this I get the following error message,
which seems to indicate that the COPY within the definition
of COPY is being expanded.

*** - LISP:FUNCTION: 
#'(LAMBDA (X) (COND ((PAIRP X) (CONS (COPY (CAR X))
       (COPY (CDR X)))) (T X)))
is not a function name

Is there any way that I can get it to work in the way that
was originally intended.

Apologies if this is a trivial question or one that has come
up before. I looked at the FAQ and couldn't find anything
on macros other than the possible need for recompilation,
which doesn't apply in this case.

Thanks in advance
Norman
-- 
Any sufficiently stupid Usenet post is indistinguishable from a troll.
(with apologies to A Clarke)

From: Barry Margolin
Subject: Re: Problem with macro expansion
Date: 
Message-ID: <23kl1.9$TV.14@cam-news-reader1.bbnplanet.com>
In article <·················@news.u-net.com>,
NF Stevens <······@arcady.u-net.com> wrote:
>I am a total novice at lisp. I recently downloaded a some
>lisp source code and have been struggling to get it working.
>Unfortunately the code is quite old and was written for a
>different lisp system. I'm using CLISP on win32.
>
>At the moment I'm completely stumped by a problem with
>macros which include a recursive definition. The relevant
>macro definitions are as follows.
>
>% Redefinition of DE and DM to make it call PUTD as it should in Standard
>% Lisp. The purpouse is to make it look for the LOSE flag. JEA
>(DM DE (U)
> (LIST 'PUTD (LIST 'QUOTE (CADR U)) '(QUOTE EXPR)
>  (LIST 'QUOTE (CONS 'LAMBDA (CONS (CADDR U) (CDDDR U)))) ) )

I suspect this is just defining DE as an abbreviation for DEFUN.  In Common
Lisp, that would be:

(defmacro de (name arglist &body x)
  `(defun ,name ,arglist ,@body))

>(DM DM (U)
> (LIST 'PUTD (LIST 'QUOTE (CADR U)) '(QUOTE MACRO)
>  (LIST 'QUOTE (CONS 'LAMBDA (CONS (CADDR U) (CDDDR U)))) ) )

And this is making DM a short-cut for MACRO, the predecessor to DEFMACRO,
and the CL equivalent would probably be:

(defmacro dm (name arglist &body body)
  `(defmacro ,name (&whole arglist) ,@body))

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
From: NF Stevens
Subject: Re: Problem with macro expansion
Date: 
Message-ID: <359bc3e3.2889174@news.u-net.com>
Barry Margolin <······@bbnplanet.com> wrote:

>In article <·················@news.u-net.com>,
>NF Stevens <······@arcady.u-net.com> wrote:
>>I am a total novice at lisp. I recently downloaded a some
>>lisp source code and have been struggling to get it working.
>>Unfortunately the code is quite old and was written for a
>>different lisp system. I'm using CLISP on win32.
>>
>>At the moment I'm completely stumped by a problem with
>>macros which include a recursive definition. The relevant
>>macro definitions are as follows.
>>
>>% Redefinition of DE and DM to make it call PUTD as it should in Standard
>>% Lisp. The purpouse is to make it look for the LOSE flag. JEA
>>(DM DE (U)
>> (LIST 'PUTD (LIST 'QUOTE (CADR U)) '(QUOTE EXPR)
>>  (LIST 'QUOTE (CONS 'LAMBDA (CONS (CADDR U) (CDDDR U)))) ) )
>
>I suspect this is just defining DE as an abbreviation for DEFUN.  In Common
>Lisp, that would be:
>
[snip]

Thanks for responding. Unfortunately this didn't help at all. It seems
that part of the point of the definitions is so that the macro arguments
aren't evaluated, so you can, for example, pass file names without
quotes! I got the code to work with a different interpreter so the
problem has been solved.

Norman
-- 
Any sufficiently stupid Usenet post is indistinguishable from a troll.
(with apologies to A Clarke)