rewrite-clj

https://github.com/clj-commons/rewrite-clj
lread 2020-09-07T17:39:21.133900Z

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?

borkdude 2020-09-07T17:53:58.134900Z

@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

lread 2020-09-07T17:57:50.135900Z

Thanks @borkdude, much appreciated! That helped me to summarize https://github.com/lread/rewrite-cljc-playground/issues/59

borkdude 2020-09-07T18:05:52.137Z

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.

borkdude 2020-09-07T18:06:40.137400Z

So I would really do nothing at this point, since people are relying on being able to turn asserts off

lread 2020-09-07T18:14:08.137700Z

Thanks for you responses, much appreciated.

lread 2020-09-07T18:19:33.142200Z

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).

borkdude 2020-09-07T18:23:41.142700Z

I think the asserts are mostly there for people constructing nodes themselves.

borkdude 2020-09-07T18:23:54.143100Z

So in clj-kondo hook code that may be something people are missing out on

borkdude 2020-09-07T18:24:04.143400Z

but we can fix that manually for that exposed API which is not that big

borkdude 2020-09-07T18:25:02.143900Z

At the moment we only expose creating lists, vectors and tokens

borkdude 2020-09-07T18:25:38.144200Z

I just checked and saw that they don't have any asserts

lread 2020-09-07T18:32:12.144700Z

cool, thanks!

borkdude 2020-09-07T18:43:08.145400Z

@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