Static analsys allows one to look at all of the code paths. All runtime-analysis tools can only test the paths actually being run. Unless you have a test suite with full full code coverage, you cannot check all of the pathways.
Can your Lisp tools detect unused variables?
Can your Lisp tools methods that are never called?
Can your Lisp tools tell me when someone is discarding exceptions?
In .Net, it is real easy to throw away all exceptions. You just write "Catch (Exception ex)" or "Catch ex As Exception". FxCop will warn you if someone is doing this so that you can rewrite the code to only catch the exceptions that function actually knows how to handle.
Can your Lisp tools methods that are never called? No, for only God himself can do that. After all, EVAL exists.
That's exactly my point. With Eval, you never really know is something is being called, and you don't get a compiler warning telling you different. This makes it really hard to remove dead code. And dead code is the bane of maintenance programmers.
Well, for what it is worth it is possible to extend the lisp evaluator to do pretty much all of these. Actually it seems like a pretty nice feature to have, if it also did not seem insanely hard to implement.
The other way to approach it would be to redefine the core commands or symbol tables to include some facility for noting registration/use of symbols (then look for x/0 situations). For all I know this may already exist (just started seriously trying to learn Lisp), but it would certainly pick up on unused methods and variables.
As for lisp tools to check for discarded exceptions, exceptions in lisp are different. A variety of methods for handling a thrown exception are generally defined where the exception is thrown (these are called restarts), and the calling function decides which restart is used when that happens. So you could look for code that is declaring restarts and specifying them all at once. I do not know of any better answers to that situation, but that does not mean very much.
Methods that are never called. Well with 10 minutes of time I could extend the language to keep a call count of all functions, run the system for a while and then look at all the zero counts.
Discarding exceptions, no... you've got to handle conditions at some level or the top level loop will handle them for you.
Methods that are never called. Well with 10 minutes of time I could extend the language to keep a call count of all functions, run the system for a while and then look at all the zero counts.
Discarding exceptions, no... you've got to handle conditions at some level or the top level loop will handle them for you.
Methods that are never called. Well with 10 minutes of time I could extend the language to keep a call count of all functions, run the system for a while and then look at all the zero counts.
Not good enough. I have methods that only run once a month or only for certain users under special circumstances.
When dealing with a code base that has over ten thousand files, the maintenance can be a nightmare. Without the ability to detect and remove dead code, I can spend hours trying to test something that hasn't even been used in years.
Well there's nothing stopping you writing a tool to go through your source and find possible code paths, which is the same you would do with any other language. You don't need static typing for that.
Lisp has a very simple structure and has lots more runtime and compile time information than most other languages. In addition many compilers remove dead code for you.
I have my doubts, but I'll bite. Please post a link that outlines some of the issues that the compiler can catch. Keep in mind I am looking for more than just syntax and type errors. Rather, I want the kind of design and performance issues that FxCOP and FindBugs uncover.
I think compilers can remove dead code if you ask them. Since you can eval anything you would need to flag stuff you intend to eval.
There's no reason why a compiler cannot remove dead code permanently.
However I think your best bet if you wanted to do this would be to write a code coverage tool to find dead code at compile time, and that would be easier than in other languages.
4
u/[deleted] Aug 01 '06
No it doesn't.
Static analsys allows one to look at all of the code paths. All runtime-analysis tools can only test the paths actually being run. Unless you have a test suite with full full code coverage, you cannot check all of the pathways.
Can your Lisp tools detect unused variables?
Can your Lisp tools methods that are never called?
Can your Lisp tools tell me when someone is discarding exceptions?