开发者

How would one create a Clojure Lint?

One example of a common Clojure programming error is expecting a lazy expression to be evaluated for side-effects. On the surface it appears checking for unused lazy expressions would be helpful. What would be the best approach to identifying this and other common mistakes? Should the core compiler che开发者_StackOverflow中文版ck for these situations, or should it be the domain of a lint program to detect? What would be a good way to start the implementation?


How about:

  • Multimethods with no :default method
  • Missing documentation strings
  • In cases where the argument to a function is always the same type, suggesting type hints on arguments
  • Pointing out multiple copies of identical anonymous functions
  • Pointing out tail recursion and suggesting restructuring
  • Using a macro where a function would suffice
  • Unused arguments, especially & rest type arguments
  • Where a function will use BigNums instead of just ints or floating point

Not sure how these checks would be implemented, but they would sure save me from myself a lot of the time.


A couple of ideas just to get things started; it could detect lazy code that can never be realized, or point out areas where reflection will be used. Though in general is clojure a little young as a language to express a common set of provable mistakes?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜