I don't mean to discourage innovative thinking here, but for reference, consider that the editor and/or separate source indexer can locate defXXX forms, and record the location of (define-widget cool-widget ...) as (:definition (:name cool-widget :type define-widget) :location (:file "file.lisp" :line 28)), and make it available to meta-dot.
While I can see advantages to having a form record where it came from, as you guys are describing, there's also a huge disadvantage -- the need to actually expand (and possibly evaluate) that macro, before being able to use meta-dot.
You'd *like* to be able to edit code which is only conditionally loaded, or intended for some other platform or environment, or not yet working. Let's say, you just modified (and broke) the define-widget macro,and now you want to look at its usage -- but you can't, because you can't load it, because the file define-widget itself is in is broken and won't load.
You'd even like to be able to index forms which are read by neither the compiler nor the interpreter. You may have definitional data which you want to constrain to certain definitional types, and NOT allow arbitrary evaluation (for example, it may be from an untrusted source).
That said, it's typical for compilers and interpreters, in many languages, to record source locations. This has advantages when no source is available -- for example, reporting stack traces. Sometimes you can even detect version-mismatches between source and binary as a result. But I don't think it's ever the optimal solution for a development environment.
Eclipse sort of does both for Java -- if you have a jar file with binaries, you can associate it with a directory or jar with sources; otherwise, it indexes the sources as it parses them, collects cross-reference data, etc. (It also constructs cross-reference data for the .jar files, so you can find usages within methods within classes in compiled jar files).
So I'd say, what you really want here is, not a run-time or read-time action, but rather a declarative hint to both compiler and editor, that a particular form is definitional.
The simplest, and traditional way to do that, is to simply declare that forms beginning with 'def' are definitional. It's arbitrary -- but it's simple.
On Mar 29, 2011, at 6:08 PM, Bob Kerns wrote:
While I can see advantages to having a form record where it came from, as you guys are describing, there's also a huge disadvantage -- the need to actually expand (and possibly evaluate) that macro, before being able to use meta-dot.
I use tag files. Tag files are good.
Even better, a lot better, is id-utils mkid' m-x gid; I recommend it - even if it has some rough edges.
Of course, no amount of lexical indexing can discover the definition of cool-widget that arose from a define-toy-box form.
On Mar 28, 2011, at 5:59 PM, Alessio Stalla wrote:
I think it would be best done by implementers (a CDR?) rather than being a library, since it interferes quite deeply with the reader.
I suspect that most implementations have this functionality. In ccl:record-source-file for example; and in LispWorks the subsystem is almost entirely documented: http://www.lispworks.com/documentation/lw50/LWUG/html/lwuser-54.htm http://www.lispworks.com/documentation/lwm43/LWRM/html/lwref-91.htm
On Mar 28, 2011, at 1:17 PM, dherring@tentpost.com wrote:
Stelian Ionescu wrote:
... That's part of Slime
Please look at Conium. http://gitorious.org/conium#more
Conium is sweet. That helps some queries to the data stored about definitional homes, but it doesn't help with making entries into that data store.
----
I seem to recall that the Lisp Machine or the Symbolics also had something analogous to LispWork's dspecs; but i couldn't fine it with a minute or two of looking.
I was sad to see that some of the implementations lack affordances for extending the kinds of things defined, e.g. adding widgets would be a pain.
The LispWorks documentation is full of interest. They take a run at providing both containment (things defined inside of other things) as well as single things defined by the union of many forms (e.g. generic methods and their individual methods).
---
In addition to the index-my-sources and the collect-assertions-about- definition approaches there is another possible tack. If your compiler writer is staying up late he may have provided very fastidious mappings back to the source file for all the code he's generating. People do that for debugging, code coverage, and even implementing unwind cleanups ... i guess that data might also be leveraged for this. It's not obviously how though.
- ben
- ben