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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Keyword arguments done right (in Clojure)

26 点作者 cemerick超过 15 年前

2 条评论

gcv超过 15 年前
The article describes a reasonable approach, but requires passing keyword arguments into a function as a separate map. I wrote a macro, let-kw, which allows a more natural calling convention: (my-fun req1 req2 :kw1 kw1-val :kw2 kw2-val)<p>I opened a ticket so let-kw would be considered for clojure-contrib inclusion (<a href="http://www.assembla.com/spaces/clojure-contrib/tickets/51-Add-let-kw-to-c-c-macros" rel="nofollow">http://www.assembla.com/spaces/clojure-contrib/tickets/51-Ad...</a>). The actual (final) macro source is posted on the Clojure mailing list (<a href="http://groups.google.com/group/clojure/msg/3ee695696c5ea1ec" rel="nofollow">http://groups.google.com/group/clojure/msg/3ee695696c5ea1ec</a>).
评论 #1055836 未加载
评论 #1055851 未加载
akkartik超过 15 年前
I wonder how they combine rest args with keyword args. Here's how I do this in my arc macros:<p><pre><code> (paginate '/search' 10 ;; optional keyword args nextcopy "Next &#38;rarr;" prevcopy "&#38;larr; Prev" :do ;; body (preprocess docs) (each doc (cut docs start-index end-index) (render-doc doc))) </code></pre> More details: <a href="http://arclanguage.org/item?id=10692" rel="nofollow">http://arclanguage.org/item?id=10692</a>