Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

result! and retry! do not work as qualified imports #2

Open
yuhan0 opened this issue Jul 9, 2024 · 1 comment
Open

result! and retry! do not work as qualified imports #2

yuhan0 opened this issue Jul 9, 2024 · 1 comment

Comments

@yuhan0
Copy link

yuhan0 commented Jul 9, 2024

I've always been interested to explore CL-style condition systems, thanks for bringing some form of it over to Clojure :)

Here's a repro (adapted from the readme)

(require '[pure-conditioning :as pc])

(defn do-something [x] x)

(manage [:x (pc/result! "nevermind")]
  (do-something 3))
;; => Execution error (ExceptionInfo) at pure-conditioning.core/result! (core.clj:277).
;;    result! must be used within manage, retryable or retryable-fn* blocks.

It appears that the library macros (manage, retryable) are only able to work when given unqualified symbols:

(if (and (list? f) (#{'result! 'retry!} (first f)))

Figuring this out was pretty confusing, as there are actual result! and retry! vars defined in the pure-conditioning.core namespace (I assume for dev tooling affordances?) But it turns out that the library doesn't care whether they exist or were imported in the current namespace, essentially treating the bare symbols as anaphors.

Not that unhygenic DSLs are a bad thing, but perhaps this fact should be made more explicit in the docstrings / Readme? From a syntax perspective I guess there would be less of a surprise if they were given more DSL-y names like !retry or $retry.. Going the pseudo-hygenic route might be possible too by somehow resolving the vars using &env at macroexpansion time.

@yuhan0
Copy link
Author

yuhan0 commented Jul 9, 2024

Side note: the Clojars link in the readme points to an outdated version of the library with the conditions namespace, also used by the Nextjournal tutorial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant