Subject: Re: Hack: dynamically discovering how to generate unquote and unquote-splicing.
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 15 Mar 2003 02:51:54 -0600
Newsgroups: comp.lang.lisp
Message-ID: <V0ednadRkco3dO-jXTWc-w@speakeasy.net>
Joerg Hoehle  <hoehle-sorry@dont.t-systems.UCE.spam.no.com> wrote:
+---------------
| Now, there's a repeating backquote pattern which goes like this:
| (defun foo (seq)
|   (with-foreign-object (buf `(c-array uint8 ,(length seq)) seq)
|     ...body...))
| 
| I wish to optimize this case as well. This (c-array X ,Y) pattern is
| supposed to occur often in FFI interaction. I don't want to take
| advantage of the fact that it's CLISP's FFI and write unportable code
| for CLISP's backquote mechanism only.
+---------------

That one looks simple. The 2nd arg of the macro is evaluated, right?
[Otherwise backquote wouldn't work in the first place.] So just
hand-expand it:

  (defun foo (seq)
    (with-foreign-object (buf (list 'c-array 'uint8 (length seq)) seq)
      ...body...))

Now it's portable.


-Rob

-----
Rob Warnock, PP-ASEL-IA		<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607