Re: [翻譯] ES6 的 destructuring 與 forEach()

作者: dryman (dryman)   2013-03-13 14:15:25
destructuring 這個字,我最早是在 clojure 中看到這名詞
http://clojure.org/special_forms 在文件最下面的 binding forms (destructuring)
Clojure supports abstract structural binding, often called
destructuring, in let binding lists, fn parameter lists, and any
macro that expands into a let or fn. The basic idea is that a
binding-form can be a data structure literal containing symbols
that get bound to the respective parts of the init-expr. The
binding is abstract in that a vector literal can bind to anything
that is sequential, while a map literal can bind to anything that
is associative.
ex:
(let [[a b c & d :as e] [1 2 3 4 5 6 7]]
[a b c d e])
->[1 2 3 (4 5 6 7) [1 2 3 4 5 6 7]]
中文解釋我會這麼寫:
destructuring 可以解釋為「智慧批配」
它會以等號左邊的表達式作依據,並將等號右邊的值批配給此表達式中的變數。
變數可以是一個以上,這個數值分配的過程稱之為「智慧批配」
雖然我用了名詞「表達式」(epression),但其實精準的翻譯應該要用「形式」(form)
在Lisp/Clojure中這兩者是不太一樣的
不過對其他程式語言來說這可能沒有差那麼多,使用「表達式」也比較能望文生義
然後就能說明表達式有哪些常見的模式
包括object/hash, array, etc.
名詞的翻譯我以意譯而非直譯,還有盡量讓中文讀起來不會困難
或許有更好的選擇,還要請強者多多指教
作者: AmosYang (泛用人型編碼器)   2013-03-17 04:08:00
批配、解配、解構覺得都不錯,但“智慧”感覺有點牽強了

Links booklink

Contact Us: admin [ a t ] ucptt.com