[parenscript-devel] &optional bugfix push request and tracing macro.

William Halliburton whalliburton at gmail.com
Wed Oct 29 20:34:35 UTC 2008


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 gracais.

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)))
         (argpairs
          (loop for arg in arg-names
            nconc (list (ps::symbol-to-js arg) arg))))
    `(progn
       (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))))

Thanks much,
Will
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/parenscript-devel/attachments/20081029/c39152dd/attachment.html>


More information about the parenscript-devel mailing list