问题描述
目前(Clojure v1.6)你可以用两种方式给出类型提示:
bCurrently (Clojure v1.6) you can give a type hint two ways:
^floats xs#^floats xsAccording to Clojure ^floats vs. #^floats?, the latter is legacy syntax, and the former is the current preferred form.
When did that change happen?
解决方案A brief history of the ^ macro character
In Clojure v1.0, the ^ character is the "meta reader macro". In other words, ^x was shorthand for (meta x). #^ was used to associate metadata with an object. (See the Macro Characters documentation from November 2009.)
At some point, someone probably realized that having special cases for both #^ and ^, both related to metadata, was confusing. They decided to deprecate ^, with the plan to eventually replace #^ with ^. In Clojure v1.1, the ^ reader macro was officially deprecated. (See the Macro Characters documentation from January 2010.)
There's a commit on April 26, 2010 on Github that replaces the old ^ behavior with the #^ behavior. (This is when #^ and ^ became synonymous.)
In the Clojure v1.2 release, #^ was deprecated in favor of ^. (See the Macro Characters documentation from August 2010.)
They removed the last few instances of #^ from clojure.core back in 2013, sometime before the Clojure v1.6 release.
这篇关于元数据读取器语法何时从#^更改为^?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!