[slime-devel] Additional source location information for SBCL

Nikodemus Siivola nikodemus at random-state.net
Tue May 31 11:44:28 UTC 2005


Development environments such as Slime benefit from being able attach 
additional source location information (eg. buffer associations) to 
functions. Currently Slime does this by patching SBCL in order to be able 
to attach its own plists to SB-C::DEBUG-SOURCE structures.

I propose we add :SOURCE-PLIST option to WITH-COMPILATION-UNIT, with
the following tentative spec:

  :SOURCE-PLIST Plist-Form

   Attaches the value returned by the Plist-Form to internal source
   location information of functions and definitions compiled in within the
   dynamic contour. Primarily for use by development environments, in order
   to eg. associate function definitions with editor-buffers. Can be accessed
   as SB-INTROSPECT:DEFINITION-SOURCE-PLIST. If multiple, nested
   WITH-COMPILATION-UNITs provide :SOURCE-PLISTs, they are appended
   togather, innermost left, unless :OVERRIDE is true, in which case
   previous :SOURCE-PLISTs are ignored.

The space-costs of this are nominal: size of DEBUG-SOURCE structures is 
increased by one slot/word, but there is only one of those per compiled 
file -- though one per function loaded from source or entered at the 
toplevel.

I think calling it a :SOURCE-PLIST is a reasonable compromise between
more abstract names such as :INFO, the documentary nature of the -PLIST
vrt. the appending behaviour, by YMMW.

To illustrate the usage, the significant part of SWANK-COMPILE-STRING[*] 
could eg. become

    (with-compilation-unit (:source-plist
                             (list 'emacs-buffer buffer
                                   'emacs-string string
                                   'emacs-position position))
           (with-input-from-string (s string)
             (load s))))))

I've the SBCL parts of this implemented in my local tree, and most
of swank-sbcl adapted for this.

The questions to SBCL and Slime folks respectively:

  1. Does the interface seem sane and something we would be happy to
     support? Are the non-slime use cases this doesn't reasonably cover?

  2. Does this fit the needs of Slime? If this existed on other platforms
     as well, would you be tempted to use this instead of whatever you
     currently use?

[*] To nitpick, I venture the opinion that SWANK-COMPILE-STRING is
a misnomer, as as far as I can tell the intention is something like
"evaluate the forms contained in this string as if they had been
entered at the toplevel, but making sure all functions are compiled".

Cheers,

  -- Nikodemus              Schemer: "Buddha is small, clean, and serious."
                   Lispnik: "Buddha is big, has hairy armpits, and laughs."



More information about the slime-devel mailing list