Clojure 1.4發(fā)布 并發(fā)編程語(yǔ)言
Clojure是一種LISP風(fēng)格的語(yǔ)言,運(yùn)行在JVM上。Clojure的一大特色就是其并發(fā)機(jī)制,它支持不可變的數(shù)據(jù)結(jié)構(gòu)(Clojure是來(lái)自于可持久化的數(shù)據(jù)結(jié)構(gòu))。Clojure還有一個(gè)特色是軟件事務(wù)存儲(chǔ)(Software Transactional Memory,STM),其支持用事務(wù)代替鎖和互斥器來(lái)更新共享內(nèi)存。STM還是一個(gè)有爭(zhēng)議的技術(shù),還需要更好的證明自己,一個(gè)簡(jiǎn)單的辦法就是訪問(wèn)一個(gè)JVM上的實(shí)現(xiàn)。
Clojure是一個(gè)在JVM平臺(tái)運(yùn)行的動(dòng)態(tài)函數(shù)式編程語(yǔ)言,其語(yǔ)法解決于LISP語(yǔ)言,在JVM平臺(tái)運(yùn)行的時(shí)候,會(huì)被編譯為JVM的字節(jié)碼進(jìn)行運(yùn)算。而且Clojure保持了函數(shù)式語(yǔ)言的主要特點(diǎn),例如immutable state,F(xiàn)ull Lisp-style macro support,persistent data structures等等,并且還能夠非常方便的調(diào)用Java類(lèi)庫(kù)的API,和Java類(lèi)庫(kù)進(jìn)行良好的整合。
Clojure 1.4 發(fā)布了,該版本主要改進(jìn)內(nèi)容有:
1 已過(guò)時(shí)和刪除的特性:
1.1 Fields that Start With a Dash Can No Longer Be Accessed Using Dot Syntax
2 新增和改進(jìn)的特性:
2.1 Reader Literals
2.2 clojure.core/mapv
2.3 clojure.core/filterv
2.4 clojure.core/ex-info and clojure.core/ex-data
2.5 clojure.core/reduce-kv
2.6 clojure.core/contains? Improved
2.7 clojure.core/min and clojure.core/max prefer NaN
2.8 clojure.java.io/as-file and clojure.java.io/as-url Handle URL-Escaping Better
2.9 New Dot Syntax for Record and Type Field Access
2.10 Record Factory Methods Available Inside defrecord
2.11 assert-args Displays Namespace and Line Number on Errors
2.12 File and Line Number Added to Earmuff Dynamic Warning
2.13 require Can Take a :refer Option
2.14 *compiler-options* Var
2.15 Improved Reporting of Invalid Characters in Unicode String Literals
2.16 clojure.core/hash No Longer Relies on .hashCode
2.17 Java 7 Documentation
2.18 loadLibrary Loads Library Using System ClassLoader
2.19 Java int is boxed as java.lang.Integer
3 性能提升
4 Bug 修復(fù)
例如:
記錄和類(lèi)型字段,以破折號(hào)開(kāi)始不再使用點(diǎn)語(yǔ)法訪問(wèn)
Clojure的1.4引入了一個(gè)字段的存取點(diǎn)的特殊形式,贊同ClojureScript的Clojure的領(lǐng)域查找語(yǔ)法語(yǔ)法。
- (defrecord Bar [-a]) ;=> user.Bar
- (.-a (Bar. 10)) ;=> 10
下載地址:http://repo1.maven.org/maven2/org/clojure/clojure/1.4.0/clojure-1.4.0.zip
【編輯推薦】