Andrey Antukh b6a108c456 📚 Restrict new ! suffix to app.db and transients
Default is now no `!` for new functions. Existing `!`
stays as legacy until its gradual refactor.

Allowed cases live in clojure/idioms: mutating public
app.db API and functions working over transients. Any
further case must be registered there first.

AI-assisted-by: muse-spark-1.3-contributor
2026-10-05 09:54:46 +00:00

1.5 KiB

Clojure Idioms (verified)

Behaviors confirmed against the language/stdlib — do not re-derive from assumption; a wrong assumption here already cost a review round.

  • int? is NOT 32-bit-only: true for Long, Integer, Short, Byte (fixed-precision integers). Clojure integer literals are Long, so (int? 5000) is true.
  • integer? is the general integer predicate; prefer it when any integer kind must match, int? only when fixed precision is meant.
  • await is a cljs.core macro asserting (:async &env): it fails at compile time outside an ^:async context, never silently.
  • The analyzer reads :async only from the fn name meta and the fn operator meta; list-level meta is ignored (would make a MetaFn). (fn ^:async [] …) puts the meta on argv (pre/post only, NOT async).
  • Valid: (defn ^:async f), (defn- ^:async f), (^:async fn [] …) (the latter is what stock t/async generates itself).
  • ^:async fns never throw synchronously (rejected promises instead); try/catch/finally supported; continuations are microtasks, timers and RxJS schedulers are macrotasks (FIFO).
  • ! suffix allowed cases (only exceptions to the no-new-! rule in mem:clojure/design-rules): mutating public app.db API (insert!, update!, delete!, run!, tx-run!, exec!, ...) and fns whose contract is to work over transients (stdlib conj!, assoc!, dissoc!, disj!, persistent! and custom helpers over them); any further case must be registered here with justification before use.