[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Issue: FUNCTION-TYPE (Version 5)



   Date: 23 Jun 1987 01:34-EDT
   Sender: navajo!NGALL@G.BBN.COM
   From: navajo!NGALL@G.BBN.COM


   My main concern about losing symbols as valid function objects (i.e.,
   things that can be given to apply and funcall) is that it will make
   the "functional style" of Lisp more difficult to debug.

   For example, I use the following reader macro to allow function names
   (symbols) to be used as arguments when my code is in the debugging
   phase and "true" fucntions to be used when my code is "finished".

   (defun |#!-reader| (stream subchar arg)
     (declare (ignore subchar arg))
     (let ((fname (read stream t nil t)))
       (if *debugging-p*
	 `',fname
	 `#',fname)))

   (set-dispatch-macro-character
     #\#
     #\!
     (if *debugging-p* '|#!-reader| #'|#!-reader|))

Here's a version of your debugging environment that adheres to the
strict definition of functions:

(defun |#!-reader| (stream subchar arg)
  (declare (ignore subchar arg))
  (let ((fname (read stream t nil t)))
    (if (consp fname)
	`#',fname
	(if *debugging-p*
	    `#'(lambda (&rest x) (apply #',fname x))
	    `#',fname))))

(set-dispatch-macro-character
  #\#
  #\!
  (if *debugging-p* 
      #'(lambda (&rest x) (apply #'|#!-reader| x))
      #'|#!-reader|))