News for hackers. Stuff that matters.
Re:Clojure Interactive Development 101 by dmichulke on Monday September 02, 2024 @04:09AM (#41423527)
I'd love to use all this but the fact that you have to substitute in variables just makes this very not-useful.

Ideally in functional programming everything is a (pure) function (and this is how I program), so you never have your variables defined.

Instead, my standard setup is to debug a function by saving its arguments in a vector, e.g.

  (defn buggy-function [a b c]
   (def test-bf [a b c]) ;; <- add this
   ... function body ...
  )
Then I can call buggy-function with

  (apply buggy-function test-bf)
and modify the code until it behaves as expected.

This is also where immutability has its grand appearance.

Re:Clojure Interactive Development 101 by bundtlake on Monday September 02, 2024 @09:18AM (#41425168)
I like the simplicity of your implementation but I would fear overfitting to your example development data.

In clojure if youre writing tests, even a quick mock-up, I’d recommend you do so directly using “clojure.test”.

Clojure has my favorite test suite, especially when paired with “clojure.test.check”.

It’s super powerful, and fun to use with its toolbox of generators that can test over a broad variety of inputs.

When using the generators it’s less about the variables being defined so much as their properties.

https://clojure.org/guides/test_check_beginner

Re:Clojure Interactive Development 101 by dmichulke on Monday September 02, 2024 @09:23AM (#41425203)
My original comment was only meant for real-time debugging, not for testing.
Re:Clojure Interactive Development 101 by bundtlake on Monday September 02, 2024 @09:28AM (#41425230)
For sure, but you’re using test driven development just without writing the tests. (which I do think is a clever)

Might as well write the tests, or, as I recommended, generators for your expected input.