clojure

dpsutton 2025-11-12T22:38:51.737009Z

(when (or config/is-dev? config/is-test?)
  (defn load-stuff [] ,,,))

,,,
(defn init!
  []
  ,,,
  (when (or config/is-dev? config/is-test?)
    (load-stuff)))
just random, this works. Does it intentionally work and this is fine, or does this abuse the compiler a bit? When not dev load-stuff will be an unbound var. So it is unconditionally made but conditionally bound. I can’t tell if this is proper™ or not

1
p-himik 2025-11-12T23:06:18.684609Z

Does it matter whether it's an unbound var in prod or a non-existent var? (when false (something-that-doesn't-exist-at-all)) works just fine. The only scenario that I can see where things could go wrong is if you AOT that code with direct linking when somehow is-dev? or is-test? is true and run it in an environment where it's false.

dpsutton 2025-11-12T23:07:21.834339Z

it doesn’t matter that its unbound in the jar. this is so we load drivers from source tree during dev time but we load them a different way during the jar’s run time. It feels funny but i can’t figure out if it actually is funny

p-himik 2025-11-12T23:08:06.392499Z

I don't think it is. :) But FWIW I would move that check inside load-stuff and call load-stuff unconditionally. Then there no ambiguity anywhere.

dpsutton 2025-11-12T23:08:31.149099Z

that’s a simple way to make this all go away

Ludger Solbach 2025-11-12T23:13:10.238889Z

why is-dev? instead of just dev?? The question mark is indicating a predicate, so is-test? providing that information twice.

dpsutton 2025-11-12T23:13:54.286989Z

fair point. i think it’s been around for a while and no one has bothered to change it. maybe other reasons i’m not sure

Ludger Solbach 2025-11-12T23:16:20.769689Z

When coming from Java I tended to name predicates starting with is. But now I consider that noise.

dpsutton 2025-11-12T23:17:25.935379Z

yeah agree. these might have a bit of special circumstances around them

Ludger Solbach 2025-11-12T23:26:26.849389Z

Is there a 'standard' library providing camelCase/kebab-case/snake_case tests and conversions and not much other bloat? I have my own code for this, but I'm happy to replace it with a lib.

2025-11-12T23:36:01.080169Z

Like this? Or something else? https://github.com/clj-commons/camel-snake-kebab

➕ 8
Ludger Solbach 2025-11-13T01:10:24.016659Z

thx