它应该更常见,但我怀疑并不是因为它使解析语言变得更加复杂。
优点:
缺点:
至于为什么不这样做,我的猜测是:
It should be more common, but I suspect it is not because it makes parsing languages more complex.
Benefits:
Drawbacks:
As to why not, my guesses are:
好处太小,不足以证明使语言复杂化是合理的。
您并不经常需要它,而且只需多几个字符就可以轻松干净地获得相同的效果。
The benefit is too small to justify complicating the language.
You don't need it that often, and it is easy to get the same effect cleanly with a few characters more.
Scheme(可能还有大多数其他 Lisp 家族语言)在其语法内有效地支持多重比较:
(< x y z)
这可以被视为具有三个参数的 < 函数的普通函数应用。请参阅6.2.5 数值运算 在规范中。
<
Clojure 也支持链式比较。
Scheme (and probably most other Lisp family languages) supports multiple comparison efficiently within its grammar:
This can be considered an ordinary function application of the < function with three arguments. See 6.2.5 Numerical Operations in the specification.
Clojure supports chained comparison too.
自 20 世纪 60 年代末以来,链式比较一直是 BCPL 的一个特征。
Chained comparison is a feature of BCPL, since the late 1960s.
我认为 ICON 是具有此功能的原始语言,并且在 ICON 中,它脱离了将布尔值作为特殊“失败”标签处理而将所有其他值视为 true 的方式。
I think ICON is the original language to have this, and in ICON it falls out of the way that booleans are handled as special 'fail' tags with all other values being treated as true.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(5)
它应该更常见,但我怀疑并不是因为它使解析语言变得更加复杂。
优点:
缺点:
至于为什么不这样做,我的猜测是:
It should be more common, but I suspect it is not because it makes parsing languages more complex.
Benefits:
Drawbacks:
As to why not, my guesses are:
好处太小,不足以证明使语言复杂化是合理的。
您并不经常需要它,而且只需多几个字符就可以轻松干净地获得相同的效果。
The benefit is too small to justify complicating the language.
You don't need it that often, and it is easy to get the same effect cleanly with a few characters more.
Scheme(可能还有大多数其他 Lisp 家族语言)在其语法内有效地支持多重比较:
这可以被视为具有三个参数的
<
函数的普通函数应用。请参阅6.2.5 数值运算 在规范中。Clojure 也支持链式比较。
Scheme (and probably most other Lisp family languages) supports multiple comparison efficiently within its grammar:
This can be considered an ordinary function application of the
<
function with three arguments. See 6.2.5 Numerical Operations in the specification.Clojure supports chained comparison too.
自 20 世纪 60 年代末以来,链式比较一直是 BCPL 的一个特征。
Chained comparison is a feature of BCPL, since the late 1960s.
我认为 ICON 是具有此功能的原始语言,并且在 ICON 中,它脱离了将布尔值作为特殊“失败”标签处理而将所有其他值视为 true 的方式。
I think ICON is the original language to have this, and in ICON it falls out of the way that booleans are handled as special 'fail' tags with all other values being treated as true.