This is my first app made in Clojure. I’d love to get some review.
Looks good to me Are you looking for feedback on anything in particular? Are there aspects of the code that left you wondering if there’s a “better way”?
I use an environment variable to get the Telegram token. Since I could not find a Java function to set an environment variable, I could not figure out how to set this variable from the REPL itself in order to test the app, so I closed the REPL, set the environment variable in Emacs itself and then restarted it. Is there a better way? Is there any better framework to handle configuration variables in Clojure?
Is there any macro similar to Rust’s “unwrap” method? I looking for some way to tell “I don’t want this variable to be null. If it is, throw an exception”. Currently i just do
(or x (throw Exception "..."))for every such value.
You can use environ https://github.com/weavejester/environ
There isn’t an existing function for that. But you don’t need a macro for something so simple. Just define a function as:
(defn unwrap [a] (if (some? a) a (throw...)))
But, depending what you’re trying to achieve, you can also instead choose to use either Clojure pre/post and assert machinery or Clojure spec.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.