[armedbear-devel] [j-devel] slime swank-abcl.lisp

Mark Evenson evenson at panix.com
Wed Sep 16 09:22:35 UTC 2009


On 9/16/09 12:23 AM, Tobias C. Rittweiler wrote:
[…]
> I think there's an off-by-one in SOURCE-LOCATION. In Emacs, a buffer
> starts at 1, but in Common Lisp a file-position starts at 0.
>
> (Caveat: `(goto-char 0)' in DWIM fashion will also bring you to the
> beginning of a buffer.)
>
> I think that's the reason why you put the (PLUSP POS) there to guard
> against this issue, but merely passing (IF POS (1+ POS) 1) should also
> suffice. Perhaps you want to put this into an extra function so the
> casual hacker will be aware of it more easily.

There certainly is an "off-by-one" here if Emacs buffers start at 1 
(this surprised me!), but I don't quite understand what Tobias is 
proposing here.

The intention of the first operand in the (AND POS (PLUSP POS) was to 
guard against getting a nil from EXT:SOURCE-FILE-POSITION, right?  So 
don't we want this implementation:

(defun source-location (symbol)
   (when (pathnamep (ext:source-pathname symbol))
     (let ((pos (ext:source-file-position symbol)))
       `(((,symbol)
          (:location
            (:file ,(namestring (ext:source-pathname symbol)))
            ,(if pos
                 (list :position (1+ pos))
                 (list :function-name (string symbol)))
            (:align t)))))))


-- 
"A screaming comes across the sky.  It has happened before, but there
is nothing to compare to it now."




More information about the armedbear-devel mailing list