作者dryman (dryman)
看板Translate-CS
标题Re: [翻译] ES6 的 destructuring 与 forEach()
时间Wed Mar 13 14:15:25 2013
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.
名词的翻译我以意译而非直译,还有尽量让中文读起来不会困难
或许有更好的选择,还要请强者多多指教
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 207.151.229.119
1F:→ AmosYang:批配、解配、解构觉得都不错,但“智慧”感觉有点牵强了 03/17 04:08