From: Q
Subject: Using &rest...simple
Date: 
Message-ID: <1194618603.447517.112920@q5g2000prf.googlegroups.com>
Hi,

I'm trying to figure out how to use &rest for the following function:

(defun show-output (format-string &rest parameters)
  (when *show-output*
    (funcall #'format t format-string parameters)))

This is obviously wrong, since the parameters are sitting in a list,
and will be treated as one big parameter.  How do I get them out and
pass them as atomic units to format?

From: ······@corporate-world.lisp.de
Subject: Re: Using &rest...simple
Date: 
Message-ID: <1194618959.391724.293230@y27g2000pre.googlegroups.com>
On Nov 9, 3:30 pm, Q <······@gmail.com> wrote:
> Hi,
>
> I'm trying to figure out how to use &rest for the following function:
>
> (defun show-output (format-string &rest parameters)
>   (when *show-output*
>     (funcall #'format t format-string parameters)))
>
> This is obviously wrong, since the parameters are sitting in a list,
> and will be treated as one big parameter.  How do I get them out and
> pass them as atomic units to format?

Use APPLY.
From: Edi Weitz
Subject: Re: Using &rest...simple
Date: 
Message-ID: <u7ikrscyo.fsf@agharta.de>
On Fri, 09 Nov 2007 06:30:03 -0800, Q <······@gmail.com> wrote:

> I'm trying to figure out how to use &rest for the following function:
>
> (defun show-output (format-string &rest parameters)
>   (when *show-output*
>     (funcall #'format t format-string parameters)))
>
> This is obviously wrong, since the parameters are sitting in a list,
> and will be treated as one big parameter.  How do I get them out and
> pass them as atomic units to format?

Use APPLY instead of FUNCALL.

  http://www.lispworks.com/documentation/HyperSpec/Body/f_apply.htm

Edi.


-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: Frode Vatvedt Fjeld
Subject: Re: Using &rest...simple
Date: 
Message-ID: <2hode3bi3q.fsf@vserver.cs.uit.no>
Q <······@gmail.com> writes:

> I'm trying to figure out how to use &rest for the following function:
> 
> (defun show-output (format-string &rest parameters)
>   (when *show-output*
>     (funcall #'format t format-string parameters)))

Just substitute apply for funcall.

-- 
Frode Vatvedt Fjeld