[parenscript-devel] &optional bugfix push request and tracing macro.
tc at travislists.com
Sun Nov 16 15:20:43 UTC 2008
William Halliburton wrote:
> Hi guys. Parenscript rocks. I feel like I'm really rollerskating now..
> There was a bug reported on /Tue Sep 30 21:28:05 UTC 2008 by/ Daniel
> Gackle about the failure of &optional arguements. I just got bit by the
> bug, can we please get that one-liner pushed into the repository. Muchos
That problem was a bit nuanced, as you can see on that thread. It is
> On a happier note here is a macro I wrote to enable tracing-ala-cl.
> Works with firebug. You'll need to (defvar *trace-level*). I don't do
> indentation but that would be an easy addition.
> (defpsmacro console (&rest rest)
> `(console.log , at rest))
> (defpsmacro defun-trace (name args &rest body)
> (let* ((sname (ps::symbol-to-js name))
> (tname (ps-gensym name))
> (arg-names (loop for arg in args
> unless (eq arg '&optional)
> collect (if (consp arg) (car arg) arg)))
> (loop for arg in arg-names
> nconc (list (ps::symbol-to-js arg) arg))))
> (defun ,name ,arg-names
> (console *trace-level* ,sname ":" , at argpairs)
> (incf *trace-level*)
> (let* ((rtn (,tname , at arg-names)))
> (decf *trace-level*)
> (console *trace-level* ,sname "returned" rtn)
> (return rtn)))
> (defun ,tname ,args
> , at body))))
Neat. Thanks for sharing.
More information about the parenscript-devel