So I want to do some CFFI interfacing ... and have written the following
macro:
(defmacro define-gm-fun! (name (varlist) &body body)
`(defun! ,name (,varlist)
(ensure-cello-graphicsmagick-initialized)
(prog1
,@body
(cello-graphicsmagick-check-error))))
This works as long as I am defining functions that have arguments like
(define-gm-fun! gm-destroy-magick-wand (wand)
(DestroyMagickWand wand))
However, I do get the following error for functions without arguments:
missing value for argument VARLIST
[Condition of type SIMPLE-ERROR]
when trying to compile or macroexpand for e.g. this function:
(define-gm-fun! gm-magick-get-copyright ()
(foreign-string-to-lisp (MagickGetCopyright)))
I can't get the varlist to produce () as a result within the macro ...
Help ! SOS ! ---...--- ;-)
TIA!
Frank
On 30 abr, 15:35, Frank GOENNINGER <······@googlemail.com> wrote:
> So I want to do some CFFI interfacing ... and have written the following
> macro:
>
> (defmacro define-gm-fun! (name (varlist) &body body)
> `(defun! ,name (,varlist)
> (ensure-cello-graphicsmagick-initialized)
> (prog1
> ,@body
> (cello-graphicsmagick-check-error))))
This form
(prog1
,@body
...)
won't work as expected (if body has two or more forms, then the
result of the first form is returned instead of the result of the
last). Consider this solution:
(prog1
(progn ,@body)
...)
>
> This works as long as I am defining functions that have arguments like
>
> (define-gm-fun! gm-destroy-magick-wand (wand)
> (DestroyMagickWand wand))
>
> However, I do get the following error for functions without arguments:
>
> missing value for argument VARLIST
> [Condition of type SIMPLE-ERROR]
>
> when trying to compile or macroexpand for e.g. this function:
>
> (define-gm-fun! gm-magick-get-copyright ()
> (foreign-string-to-lisp (MagickGetCopyright)))
>
> I can't get the varlist to produce () as a result within the macro ...
> Help ! SOS ! ---...--- ;-)
>
> TIA!
>
> Frank
gugamilare <··········@gmail.com> writes:
> On 30 abr, 15:35, Frank GOENNINGER <······@googlemail.com> wrote:
>> So I want to do some CFFI interfacing ... and have written the following
>> macro:
>>
>> (defmacro define-gm-fun! (name (varlist) &body body)
>> � `(defun! ,name (,varlist)
>> � � �(ensure-cello-graphicsmagick-initialized)
>> � � �(prog1
>> � � � �,@body
>> � � � �(cello-graphicsmagick-check-error))))
>
> This form
>
> (prog1
> ,@body
> ...)
>
> won't work as expected (if body has two or more forms, then the
> result of the first form is returned instead of the result of the
> last). Consider this solution:
>
> (prog1
> (progn ,@body)
> ...)
Yes, thanks! (Figured as much already ;-)
Frank
thus spoke Frank GOENNINGER <······@googlemail.com>:
> So I want to do some CFFI interfacing ... and have written the following
> macro:
> (defmacro define-gm-fun! (name (varlist) &body body)
Oops!
Try:
> (defmacro define-gm-fun! (name (&rest varlist) &body body)
or:
> (defmacro define-gm-fun! (name varlist &body body)
Stanis�aw Halik <·······@test123.ltd.pl> writes:
> thus spoke Frank GOENNINGER <······@googlemail.com>:
>
> > So I want to do some CFFI interfacing ... and have written the following
> > macro:
>
> > (defmacro define-gm-fun! (name (varlist) &body body)
>
> Oops!
>
> Try:
>
> > (defmacro define-gm-fun! (name (&rest varlist) &body body)
>
> or:
>
> > (defmacro define-gm-fun! (name varlist &body body)
This latter one will also mean that the expansion function will need to
use
(defun ,name ,varlist ...)
instead of
(defun ,name (,varlist) ...)
I like the second form a little better.
--
Thomas A. Russ, USC/Information Sciences Institute
In article <···············@blackcat.isi.edu>,
···@sevak.isi.edu (Thomas A. Russ) wrote:
> Stanis,aw Halik <·······@test123.ltd.pl> writes:
>
> > thus spoke Frank GOENNINGER <······@googlemail.com>:
> >
> > > So I want to do some CFFI interfacing ... and have written the following
> > > macro:
> >
> > > (defmacro define-gm-fun! (name (varlist) &body body)
> >
> > Oops!
> >
> > Try:
> >
> > > (defmacro define-gm-fun! (name (&rest varlist) &body body)
> >
> > or:
> >
> > > (defmacro define-gm-fun! (name varlist &body body)
>
> This latter one will also mean that the expansion function will need to
> use
>
> (defun ,name ,varlist ...)
>
> instead of
>
> (defun ,name (,varlist) ...)
>
> I like the second form a little better.
I like:
(defun ,name (,@varlist) ...)
It maintains the parallelism between the structure of the macro argument
list and the function argument list.
--
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Barry Margolin <······@alum.mit.edu> writes:
> I like:
>
> (defun ,name (,@varlist) ...)
>
> It maintains the parallelism between the structure of the macro argument
> list and the function argument list.
Nice one. Thanks.
Cheers
Frank
Stanisław Halik <·······@test123.ltd.pl> writes:
> thus spoke Frank GOENNINGER <······@googlemail.com>:
>
>> So I want to do some CFFI interfacing ... and have written the following
>> macro:
>
>> (defmacro define-gm-fun! (name (varlist) &body body)
>
> Oops!
Yes, oooops!
>
> Try:
>
>> (defmacro define-gm-fun! (name (&rest varlist) &body body)
>
> or:
>
>> (defmacro define-gm-fun! (name varlist &body body)
Thanks. Works, of course ...
Frank