[cffi-devel] Mutable Pointers

Martin Simmons martin at lispworks.com
Fri Jul 14 16:49:10 UTC 2006


>>>>> On Fri, 14 Jul 2006 11:01:27 -0500, Stephen Compall said:
> 
> On Fri, 2006-07-14 at 13:30 +0100, Luís Oliveira wrote:
> > See inc-pointer.
> > <http://common-lisp.net/project/cffi/manual/html_node/
> > inc_002dpointer.html>
> >
> > (setf *stack-pointer* (inc-pointer *stack-pointer* 1)) should work.
> > You can abstract that with a simple macro:
> >
> >    (defmacro incf-pointer (place &optional (offset 1))
> >      `(setf ,place (inc-pointer ,place ,offset)))
> >
> > Any objections to adding this macro to CFFI?
> 
> This evaluates the PLACE forms twice.  If I follow correctly, this can
> be more generally solved with a cross-platform setf-expander for
> POINTER-ADDRESS that requires its PTR arg to be a place, whereupon
> things like (incf (pointer-address *ptr*)) and any other place-modifier
> should work.

Looks like a job for DEFINE-MODIFY-MACRO to me.

-- 
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/



More information about the cffi-devel mailing list