Re: Help - how to pass a "keyed parameter list" to a macro or function - beginner is at wits end

Gary King <[email protected]> Fri, 2 Jul 2004 08:02:25 -0400
Newsgroups gmane.lisp.allegro
Message-ID <[email protected]>
Hi David,

In short, use #'apply. For example:

(apply #'make-instance 'foo '(:a 1 :b 2 :c 3))

Apply is like funcall except that it splices the _last_ argument into 
the rest -- i.e., it does what you want.




On Jul 2, 2004, at 2:38 AM, David Koch wrote:

> How can I pass a keyed argument list to a function  ? to a macro?
>
> For example:
>
> (setf  aspec '(:a 1 :b 2 :c 3))
>
> (defclass obj () (a b c))
>
> (make-instance 'obj aspec)    <<<<<
>
> >>>   Malformed plist in doplist, odd number of elements.
>
> Clearly aspec is being evaluated before the call to make-instance
>
> so I have been trying something like:
>
> (defmacro create-obj (arg)
>    `(make-instance 'obj ,@arg))
>
> This does not expance correctly, and I have tried everything under the 
> sun that I could think of , except the correct method?
>
> Any suggestions?
>
> Thanks,
>
> David Koch
> [email protected]
>
>
-- 
Gary Warren King, Lab Manager
EKSL East, University of Massachusetts * 413 577 0176

Callused men in business suits speak computerese
Play pinball with the third world, trying to keep it on its knees
Their single crop starvation plans put sugar in your teas
and the local third world is kept on reservations you can't see

It'll all go back to normal if we put our nation first.
But the trouble with normal is it always gets worse.

   -- Bruce Cockburn, Trouble with Normal