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