Clojure <> ClojureScript; e.g: the “format” function
Clojure中有一个非常方便的函数,称为
以轻松模板字符串的能力而闻名。 该功能通常在大多数编程语言中都可用。
我很生气地发现ClojureScript没有实现此功能。 据我研究,它是在旧版本中实现的,但最新版本不包含该功能。
有人知道这是否有原因吗?
1 2 3 4 5 6 | (ns rostering.components.services (:require [goog.string :as gstring] [goog.string.format])) (str"$" (gstring/format"%.2f" 2.5)) |
在此简短文档的底部,几乎有相同的示例。
我不能说ClojureScript的一部分是GCL。 这是另一个参考。 这意味着
以下是该参考的引文:
The Google Closure Library is a javascript library developed by Google, based on a modular architecture and provides cross-browser functions for DOM manipulations and events, ajax and JSON, among other features.
It’s written specifically to take advantage of the Closure Compiler (that is used internally by the ClojureScript compiler).
And ClojureScript is built on Closure Compiler and Closure Library. In fact, ClojureScript namespaces are Closure modules.
对相关吉拉票的评论可能会有所帮助:
Backing this one out, goog.string.format defies advanced optimization and it provides few of the capabilities of Clojure's format - which does a lot because of java.util.Formatter. Apologies for the churn, but this is a simple thing for people to stub in themselves for the little bit of functionality it actually delivers.