TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Poor man's dependency injection in Clojure

39 点作者 pyritschard超过 11 年前

4 条评论

eigenrick超过 11 年前
This is just my opinion, but if one is writing dependecy-injected frameworks in Clojure, then they're missing the point of Clojure.
评论 #7120997 未加载
评论 #7120891 未加载
评论 #7120935 未加载
评论 #7121471 未加载
Qerub超过 11 年前
The one-function protocols strike me as unidiomatic; why not use functions directly? `(fn […] …)` would work just as well as `(reify P (f [this …] …))` (`this` is never used).<p>Update: I looked at the code again and noticed that `stdin-transport` implements <i>two</i> protocols. Guess I need to think a little bit more about this.
moomin超过 11 年前
Check out Stuart Sierra&#x27;s &quot;component&quot; for another take. Of course, another take is that you&#x27;re better off just constructing objects by calling their constructors directly.
评论 #7120920 未加载
gengstrand超过 11 年前
A chapter from the O&#x27;Reilly book covers this subject pretty well. With Clojure&#x27;s java interop, you can still use Spring. Thanks to the homoiconicity of the language, support for higher order functions, and with some clever use of Clojure&#x27;s load-file function in core, you kind of get DI baked into the language for free.