Heya @borkdude, @sogaiu has tweaked my interest in rewrite-clj’s usage of assert
. He educated me on the negative implications of a library’s usage of assert
, notably that a caller would need to know to catch a Throwable rather than Exception.
He noticed that you disable assert
in some of your projects (example: https://github.com/borkdude/clj-kondo/blob/a2aede1a78fe83fd78c18e7295f96592b47510df/project.clj#L28). Did you disable due to rewrite-clj’s usage of assert? If so, for perf reasons? Or because you did not want the checks, or other?
@lee I disable them because of perf. The asserts in rewrite-clj are, I think, mostly interesting from a developer's perspective, not for the end program
Thanks @borkdude, much appreciated! That helped me to summarize https://github.com/lread/rewrite-cljc-playground/issues/59
I gave a response there. It's nice to get some extra checking during development, but you should be able to turn that off when compiling a final artifact. E.g. linters and formatters should get the ultimate performance possible, since they run on every keystroke.
So I would really do nothing at this point, since people are relying on being able to turn asserts off
Thanks for you responses, much appreciated.
Most of the asserts are to validate that Clojure code that is being parsed is valid, I think. I’ll play around a bit to make sure I’m right about that and add to the issue. I guess my question to myself is, if the asserts are disabled, is rewrite-clj able to parse invalid Clojure code? (which isn’t necessarily a bad thing).
I think the asserts are mostly there for people constructing nodes themselves.
So in clj-kondo hook code that may be something people are missing out on
but we can fix that manually for that exposed API which is not that big
At the moment we only expose creating lists, vectors and tokens
I just checked and saw that they don't have any asserts
cool, thanks!
@lee Comparable situation: spec uses asserts when people write specs: https://github.com/clojure/spec.alpha/blob/eb49d429e85b6878a61443e853be26092ff6e249/src/main/clojure/clojure/spec/alpha.clj#L657 This is useful during development, but you may want to turn it off later