[slime-devel] source path finding breaks in the presence of #.

Hi all, I encountered a construct like the following in cl-irc. It makes the source path finder in M-. break: ------------- C-c C-k, then M-. A RET ------------ (cl:defpackage :swank-bork (:use :cl)) (cl:in-package :swank-bork) (eval-when (:compile-toplevel :load-toplevel :execute) (defvar *foo* '(a b c))) (defmacro define-foos (args) `(progn ,@(mapcar (lambda (arg) `(defun ,arg (,arg) ,arg)) args))) (define-foos #.*foo*) ------------- snip ------------ trying to M-. A or B or C will fail with "Error: The variable *FOO* is unbound." With Juho Snellman's help, I tracked this down to swank::read-source-form. My current suspicion on why this is happening is that it READs the form and doesn't bind *package* to the package that the stream uses. This causes evaluation of the #. form to yield bad results. Unfortunately, I have no idea how to fix this, or if this is fix-worthy at all. I guess read-source-form would have to try and find a top-level in-package form somewhere, possibly expanding macros along the way and digging into top-levelness preserving forms like eval-when and progn. That would be a lot of work for this one error, in my eyes. Thanks for any advice (or fixes (-8), -- Andreas Fuchs, <asf@boinkor.net>, asf@jabber.at, antifuchs

* Andreas Fuchs [2005-11-06 21:16+0100] writes:
Unfortunately, I have no idea how to fix this, or if this is fix-worthy at all. I guess read-source-form would have to try and find a top-level in-package form somewhere, possibly expanding macros along the way and digging into top-levelness preserving forms like eval-when and progn. That would be a lot of work for this one error, in my eyes.
I think we don't actually need to eval the expression. I changed the readtable so that the #. macro is simply suppressed. Helmut.

Helmut Eller <heller@common-lisp.net> writes:
* Andreas Fuchs [2005-11-06 21:16+0100] writes:
Unfortunately, I have no idea how to fix this, or if this is fix-worthy at all. I guess read-source-form would have to try and find a top-level in-package form somewhere, possibly expanding macros along the way and digging into top-levelness preserving forms like eval-when and progn. That would be a lot of work for this one error, in my eyes.
I think we don't actually need to eval the expression. I changed the readtable so that the #. macro is simply suppressed.
Do you remember why we have *READ-SUPPRESS* bound to NIL when we call READ-AND-RECORD-SOURCE-MAP? I don't and it seems comment-worthy.

* Luke Gorrie [2005-11-07 09:40+0100] writes:
Do you remember why we have *READ-SUPPRESS* bound to NIL when we call READ-AND-RECORD-SOURCE-MAP? I don't and it seems comment-worthy.
READ returns always nil if *READ-SUPPRESS* is t, but we need the form for the lookup in the source-map. (It doesn't matter if we read it in the wrong package.) We set *READ-SUPPRESS* to t while skipping over the uninteresting top-level forms just to avoid unnecessary interning. This seems to be a bigger annoyance because many readmacro writers forget to test their code with *READ-SUPPRESS* = t. Helmut.
participants (3)
-
Andreas Fuchs
-
Helmut Eller
-
Luke Gorrie