(defmacro access-slot (object &rest slot-names)
`(ff:fslot-value-typed (ff:foreign-pointer-type ,object)
:c (ff:foreign-pointer-address ,object)
,@slot-names))
(defmacro define-struct-getter (struct package &rest slots)
(loop for s in slots
do (let ((acc (intern (concatenate 'string (symbol-name
struct) "-" (symbol-name s))))
(sp (intern s package)))
(eval `(defmacro ,acc (object)
`(access-slot ,object ',',sp))))))
because it is a macro which writes macros which uses macro. My
first real world macro.
On Sun, Sep 5, 2010 at 4:24 PM, Kazimir
Majorinc
<kazimir@chem.pmf.hr>
wrote:
As
first, good luck with this list!
I'm in search for best examples of "code is data" paradigm in Common
Lisp. For most CL-ers, it probably means "macros", but eval, backquote,
anything that processes the code as data is of interest. As "best" I
think on the most surprising, powerful, sophisticated examples, not
necessarily of a pedagogical value.
Imagine that someone invited you to write the presentation "Five best CL
macros ... I seen" or "Five best CL macros ... I wrote." What would you
chose and why?
Kazimir Majorinc
_______________________________________________
pro mailing list
pro@common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/pro