Thank you to @richhickey @alexmiller @fogus et al for the new :keys! and & features in Clojure 1.13.0 Alpha 2! It's already cleaned up quite a bit of our code, and it'll change the way future code is written at work. And, yes, we already have some apps in production running on Alpha 2 🙂
Thank you for testing it out!
The first function I looked at after learning about :keys! was a good candidate for its use simple_smile
It's funny how you could always just assert or s/assert but programmers being so lazy obviously I rarely would go that extra mile. Having to just put a ! mark and having be in the signature so it works as quick documentation too 👌
Assert throws an Error, not an Exception, which isn't really appropriate for an Illegal Argument check. Also, assert can be turned off in production, which is also not appropriate for an Illegal Argument check.
well, I think that's a matter of debate :)
I have strong opinions about assert and Error:grin:
not really debating that, debating what you should be checking at runtime
Ya fair, assert/pre/post are more for invariants that if broken indicate an application bug, and not a user provided input mistake. But I mean there'd be a million ways you could have validated the required input prior but I was always too lazy. I think one thing I like about Clojure is that it takes a Bayesian mindset to software correctness, and keys! feels like that. It increases the likelihood programmers validate required keys in places where they should by steering them towards the safer choice and making it the default low friction mode.