Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!europa.eng.gtefsd.com!howland.reston.ans.net!EU.net!uunet!sytex!smcl
From: smcl@sytex.com (Scott McLoughlin)
Subject: Re: Q: How do I construct a list and call it?
Message-ID: <oZs6uc3w165w@sytex.com>
Sender: bbs@sytex.com
Organization: Sytex Access Ltd.
References: <cj.waters-0211940636570001@130.216.64.235>
Date: Wed, 2 Nov 1994 10:43:47 GMT
Lines: 40

cj.waters@auckland.ac.nz (Chris Waters) writes:

> 
> Here is a simple example:
> 
> (defun test (a b c)
>    (print c))
> (setq myfun '(test 4 5))
> (setq temp '((foo) (bar)))
> (eval (append myfun 'temp))
> 
> I would expect this to call the function test and print out ((foo) (bar))
> which is the behaviour I want. The problem is that the list returned by
> the append function is: (test 4 5 . temp) and the interpreter (MCL) says
> can't take the car of temp. How do get the new parameter (temp) without
> the dot?

(eval (append myfun (list (list 'quote temp))))

A good debugging method is to do the (append...) part 
first and look at what is being passed off to the call
to EVAL.

APPEND '((foo) (bar)) 'TEMP
APPEND (quote ((foo) (bar)) (quote temp)
APPEND <evaluated: ((foo) (bar))> <evaluated: temp>
APPEND --> ((FOO) (BAR) . TEMP)

Go back in your manual and look at what QUOTE does. While
Lisp "evaluation" looks like magic at first, it isn't. It's
just like function call in other languages. 

Also, rule of thumb: don't use EVAL unless you absolutely
have to. No "magic" in eval either. Think of it, heuristically,
as "compile and go".  GOOD LUCK!

=============================================
Scott McLoughlin
Conscious Computing
=============================================
