From 3a8c92457829ac036ef91856185f58b69c221d54 Mon Sep 17 00:00:00 2001 From: David Vazquez Date: Fri, 28 Dec 2012 01:55:28 +0000 Subject: [PATCH] Print functions with the name --- lispstrack.lisp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lispstrack.lisp b/lispstrack.lisp index 12fc7c9..ba63ffa 100644 --- a/lispstrack.lisp +++ b/lispstrack.lisp @@ -38,11 +38,18 @@ (defmacro defvar (name &optional value) `(%defvar ,name ,value)) - (defmacro %defun (name args &rest body) - `(progn - (eval-when-compile - (%compile-defun ',name)) - (fsetq ,name (lambda ,args ,@body)))) + (defmacro named-lambda (name args &rest body) + (let ((x (make-symbol "FN"))) + `(let ((,x (lambda ,args ,@body))) + (set ,x "fname" ,name) + ,x))) + + (defmacro %defun (name args &rest body) + `(progn + (eval-when-compile + (%compile-defun ',name)) + (fsetq ,name (named-lambda ,(symbol-name name) ,args + ,@body)))) (defmacro defun (name args &rest body) `(%defun ,name ,args ,@body)) @@ -428,12 +435,17 @@ (join (mapcar (lambda (d) (string (char "0123456789" d))) digits)))))) +#+lispstrack (defun print-to-string (form) (cond ((symbolp form) (symbol-name form)) ((integerp form) (integer-to-string form)) ((stringp form) (concat "\"" (escape-string form) "\"")) - ((functionp form) (concat "#")) + ((functionp form) + (let ((name (get form "fname"))) + (if name + (concat "#") + (concat "#")))) ((listp form) (concat "(" (join-trailing (mapcar #'print-to-string (butlast form)) " ") -- 1.7.10.4