Scheme 中“=>”关键字的名称是什么?
What is the name of the "=>" keyword in Scheme?
Excercise 4.5 of Structure and Interpetation of Computer Programs (SICP) 引入了另一种形式为 (<test> => <recipient>)
的条件子句语法,例如:
(cond ((assoc 'b '((a 1) (b 2))) => cadr)
(else false))
是否有此关键字或 cond 子句的此替代形式的名称?
测试此关键字是否存在的过程可以采用 (=>? <exp>)
形式,但我可能更喜欢更具表现力的名称。即使使用名称 =>?
是否有公认的发音方式,例如,“是双箭头”、“是 altnernative cond 子句”、“正在调用 cond”?
我已经扫描了几个 r*rs 规范,但我看不到名称引用的关键字。
Scheme supports an alternative clause syntax:
(predicate => recipient)
where recipient is an expression. If predicate evaluates to a true
value, then recipient is evaluated. Its value must be a procedure of
one argument; this procedure is then invoked on the value of the
predicate.
所以你读它就像逻辑“如果predicate then recipient”。约束条件是 recipient 是 1 个参数的函数。
更新:
我查看了mailing lists of scheme,我从未见过这种语法糖,也就是说,它是最近添加到语法中的。
Excercise 4.5 of Structure and Interpetation of Computer Programs (SICP) 引入了另一种形式为 (<test> => <recipient>)
的条件子句语法,例如:
(cond ((assoc 'b '((a 1) (b 2))) => cadr)
(else false))
是否有此关键字或 cond 子句的此替代形式的名称?
测试此关键字是否存在的过程可以采用 (=>? <exp>)
形式,但我可能更喜欢更具表现力的名称。即使使用名称 =>?
是否有公认的发音方式,例如,“是双箭头”、“是 altnernative cond 子句”、“正在调用 cond”?
我已经扫描了几个 r*rs 规范,但我看不到名称引用的关键字。
Scheme supports an alternative clause syntax:
(predicate => recipient)
where recipient is an expression. If predicate evaluates to a true value, then recipient is evaluated. Its value must be a procedure of one argument; this procedure is then invoked on the value of the predicate.
所以你读它就像逻辑“如果predicate then recipient”。约束条件是 recipient 是 1 个参数的函数。
更新:
我查看了mailing lists of scheme,我从未见过这种语法糖,也就是说,它是最近添加到语法中的。