Best way to include dev-only functions?

167 views
Skip to first unread message

Jonathon McKitrick

unread,
Jan 15, 2018, 11:31:05 AM1/15/18
to Clojure
I’d like to have a namespace loaded with dev-only versions of some functions.

Is there a better way than using environ with ‘require’ and ’ns-resolve’ to do this?

Patrik Sundberg

unread,
Jan 17, 2018, 8:23:14 AM1/17/18
to Clojure
I tend to add a path to my :resource-paths in boot for dev-only things. You can do the same with lein (and hopefully any other build tool you use).

I'm not sure I got your question fully. My interpretation is that you want to have a different version of the "same" fn, so that other parts of the code that use the fn ends up using a diff version without needing to be changed. I think that's what you asked? :)

If so then adding a dev-only path like mentioned above, with the dev versions of the fns, and then e.g. add a wrapper macro that uses with-redefs to point the fns you want to the dev versions from the dev NS. You can then use this macro to to execute code with the dev versions, like (dev-mode (form1) (form2) ... ). 

jmcki...@gmail.com

unread,
Jan 22, 2018, 5:37:04 PM1/22/18
to clo...@googlegroups.com
Ah, ok. I’ve not used with-redefs. I’ll give it a shot.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/LPi164ENGzc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Jonathon McKitrick
Reply all
Reply to author
Forward
0 new messages