Shortest path between two words and other goodness
Tuesday, July 25, 2006
I got frustrated with an obscure stack effect inference bug today, so I decided to work on something completely different, the beginnings of a system like InterLisp’s MasterScope. In MasterScope, you can perform queries like the following:
- Which functions call my function?
- Which functions does my function call?
- What’s the shortest call path between two functions?
- What dynamic variables does my function read or write?
Factor can already tell you the first two, and has been able to for quite some time. Now I implemented a program that computes the shortest path between two words. Its a little inefficient since I’m missing a fast priority queue, and the code is a bit rough so I’m not putting it in the core yet. It will go in soon, though. Here are some examples:
\ nth \ parse shortest-path .
{ parse parse-lines set namespace peek nth }
\ set-nth \ each shortest-path .
{ }
In the first example a call path was found. In the second example, the
set-nth
word is never called by any word called from each
.
I also implemented uses/usages at the vocab level. You can ask what
vocabularies does a given vocabulary depend on (when one considers the
totality of words defined therein):
"opengl" vocab-uses .
{
"sequences" "kernel-internals" "generic" "alien" "math"
"io" "kernel" "opengl"
}
Also, you can ask what vocabularies call words from this one:
"gadgets-text" vocab-usage .
{
"gadgets" "gadgets-listener" "gadgets-search"
"gadgets-text" "gadgets-theme" "io" "models"
}
Right now there is a lot of circular dependency between vocabularies,
but over time I hope to reduce this and tools such as the above will
help.
What will be really neat is wrapping these cross-referencing tools in an
UI frontend.