[cffi-devel] plural forms for WITH-FOREIGN-POINTER and in general

Tamas K Papp tkpapp at gmail.com
Wed Dec 9 14:10:04 UTC 2009


Hi,

Two suggestions:

1. Could we have a plural form of WITH-FOREIGN-POINTER (similarly to
WITH-FOREIGN-OBJECTS, WITH-FOREIGN-STRINGS).

2. In my own code, I usually use something like this:

(defmacro with-multiple-bindings (macro)
  "Define a version of `macro' with multiple arguments, given as a
list.  Application of `macro' will be nested.  The new name is the 
plural of the old one (generated using format)."
  (let ((plural (intern (format nil "~aS" macro))))
    `(defmacro ,plural (bindings &body body)
       ,(format nil "Multiple binding version of ~(~a~)." macro)
       (if bindings
	   `(,',macro ,(car bindings)
		     (,',plural ,(cdr bindings)
			       , at body))
	   `(progn , at body)))))

(with-multiple-bindings with-foreign-pointer)

Incorporating something similar would replace the repetitions in the
CFFI code, and make it easier to define plural forms.

Cheers,

Tamas





More information about the cffi-devel mailing list