[slime-devel] Random notes, *read-suppress*

Luke Gorrie luke at bluetail.com
Mon May 10 15:14:43 UTC 2004


Ahoy,

On the weekend I tried actually /using/ SLIME. It's not bad but, gee
wiz, it isn't hard to run into trouble :-). A couple of notes.

If you have your own reader-macros then make sure they respect
*READ-SUPPRESS*. We set this while searching for source locations, and
it took me a while to realise that some of my reader-macros were
broken: they couldn't handle their recursive READs returning NIL. This
is confusing to debug if you didn't know that *READ-SUPPRESS* exists,
so read the Hyperspec if in doubt.

I generally had some trouble working with majorly broken packages that
want to bring up the debugger lots of times while failing to
compile. It helped to add a new ABORT restart that aborts compilation
but still presents the compiler messages that have been gathered so
far.

I also hit a bug in the May snapshot of CMUCL that is triggered by my
"cache source files as strings for location-finding" change:
reader-errors coming from non-file streams hit a type error before the
real error is reported. Raymond Toy says it should be fixed in 19A,
and meanwhile here is a "hotfix" (might only apply to May snapshot):

;;; Avoid calling FILE-LENGTH on STREAM. It might not be a file stream.
(in-package :c)
(defun careful-read (stream eof pos)
  (handler-case (let ((*features* (backend-features *target-backend*)))
		  (read stream nil eof))
    (error (condition)
      (if (null (peek-char nil stream nil))
          (unexpected-eof-error stream pos condition)
          (progn (normal-read-error stream pos condition)
                 (ignore-error-form stream pos)))
      '(cerror "Skip this form."
	       "Attempt to load a file having a compile-time read error."))))

(defun unexpected-eof-error (stream pos condition)
  (declare (type stream stream) (type unsigned-byte pos))
  (let ((eof-pos (file-position stream))
        (res nil))
    (file-position stream pos)
    (loop
      (let ((line (read-line stream nil nil))) 
	(unless line (return))
	(when (or (find #\" line) (find #\( line))
	  (setq res line)
	  (return))
	(unless (or res (zerop (length line)))
	  (setq res line))))

    (compiler-error-message
     "Read error in form starting at ~D:~%~@[ \"~A\"~%~]~A"
     pos res condition)

    (file-position stream eof-pos)
    (undefined-value)))





More information about the slime-devel mailing list