
On Thu, 24 Jan 2008 10:29:23 -0600
Derek Elkins
Doing it in the IDE would a) require much more from most IDEs and b) be almost entirely useless. Most IDEs don't even get as far as parsing the code, even the the best rarely know much about the actual semantics of the language. This would require a rather deep analysis and ultimately it is undecidable. Practically speaking, having such a feature in the IDE would be useless unless the programming style of most "imperative" programmers changed dramatically. The only functions such an analysis would say were pure are those that were rather trivial. Either way, having such a feature in the IDE doesn't really help. A purity checker in the IDE isn't going to help when the function/method is unknown, e.g. when I write a function/method that takes a function or an object. A "purity annotation" would have to be at the language level, short of doing a whole-program analysis which would be infeasible.
Indeed - JML (Java Modelling Language) takes exactly this approach. -- Robin