Log in

No account? Create an account

xref support in SBCL

Juho Snellman has committed an xref system to SBCL, and made a corresponding update to SLIME to support the new functionality.

xref is a cross referencing system for the code you have compiled and loaded. It tracks where constants and specials are referenced, where macros are macroexpanded, and where functions are called. With that information, you can ask your running system questions like "What functions call FOO:BAR?" and "Where is WITH-FROB macroexpanded?"

There's a portable xref facility, and for a time it was used for SBCL in slime, but it was disabled and I don't recall why.

Juho's xref is fast and small enough that it has been enabled by default. It can be turned off by setting the SPACE optimization to 3.

I've never actually used a Lisp with xref support in SLIME before. I can understand the conceptual usage, but can anyone tell me the sorts of things they find themselves using xref for in their daily workflow?




Experience that kind of functionality for C/C++

I have never used xref, but for a large C/C++ code base I use cscope (through Emacs) which finds definitions, declarations, symbols, all the functions calling a function, etc. It really helps to get a grip on the code.

Re: Experience that kind of functionality for C/C++

There's a Lisp Machine program called masterscope that sounds like it did the same things as cscope. I'm really curious if one inspired the other; it seems like just too great a coincidence that they're independent efforts.


An extremely useful feature

I am using it a lot when refactoring my code. Especially one that I have not touched in a while. Renaming a function, changing the arg list becomes a lot easier with xref, it's like having TAGS on steroids.