Fork me on GitHub
#rewrite-clj
<
2020-09-07
>
lread17:09:21

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?

borkdude17:09:58

@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

lread17:09:50

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

borkdude18:09:52

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.

borkdude18:09:40

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

lread18:09:08

Thanks for you responses, much appreciated.

lread18:09:33

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

borkdude18:09:41

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

borkdude18:09:54

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

borkdude18:09:04

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

borkdude18:09:02

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

borkdude18:09:38

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

lread18:09:12

cool, thanks!

borkdude18:09:08

@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