Re: Newbie: Quick Question regarding Disassembling a list
From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 04/30/04
- Next message: Dave Roberts: "Trouble with compiled file using UFFI"
- Previous message: Matthew Danish: "Re: Newbie: Quick Question regarding Disassembling a list"
- In reply to: Matthew Danish: "Re: Newbie: Quick Question regarding Disassembling a list"
- Next in thread: pkhuong: "Re: Newbie: Quick Question regarding Disassembling a list"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 30 Apr 2004 00:43:57 -0400
In article <20040430042115.GX25328@mapcar.org>,
Matthew Danish <mdanish@andrew.cmu.edu> wrote:
> On Thu, Apr 29, 2004 at 09:10:50PM -0700, Ari Johnson wrote:
> > >AND is a macro. You cannot FUNCALL or APPLY it, that wouldn't make
> > >sense. There is a function named EVERY which does what he wants.
> > >Alternatively, (loop for l in list1 always l).
> >
> > Could you macroexpand it? (eval (macroexpand (cons 'and list1))) seems
> > to work for me.
>
> I strongly discourage this sort of solution. MACROEXPAND and especially
> EVAL are very heavy machinery to invoke, and there is no need for it.
> Essentially, you are creating an entire separate Lisp interpreter or
> even compiler process. Also, EVAL does not operate in the current
> lexical environment (since it is basically running a fresh new program).
Furthermore, unless you know for sure that list1 only contains
self-evaluating objects, the above code has a bug. It should be:
(eval (cons 'and (mapcar '(lambda (x) `',x))))
to prevent the elements of list1 from being evaluated.
The MACROEXPAND is unnecessary -- EVAL will expand macros when necessary.
-- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***
- Next message: Dave Roberts: "Trouble with compiled file using UFFI"
- Previous message: Matthew Danish: "Re: Newbie: Quick Question regarding Disassembling a list"
- In reply to: Matthew Danish: "Re: Newbie: Quick Question regarding Disassembling a list"
- Next in thread: pkhuong: "Re: Newbie: Quick Question regarding Disassembling a list"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]