"alt!" 在 Clojure 中的含义
Meaning of "alt!" in Clojure
在 clojure.core.async 中有一个名为 alts!
的函数可以在多个频道上等待消息。在 Go 中这被称为 select
(就像 select 来自多个渠道的消息),但是在 Clojure 中 "alt" 是什么意思?
我知道这个函数是干什么的,但是不知道"alts"是什么意思,我很难记住函数名?它是 "alternative(s)" 的快捷方式吗?
来自 alt!
的文档字符串(强调已添加):
Makes a single choice between one of several channel operations,
as if by alts!
和 alts!
(添加了重点):
Completes at most one of several channel operations.
这将支持 "alt" 是 "alternative" 或 "alternatives" 的缩写的观点。换句话说,从几个备选方案中选择一个。
在 clojure.core.async 中有一个名为 alts!
的函数可以在多个频道上等待消息。在 Go 中这被称为 select
(就像 select 来自多个渠道的消息),但是在 Clojure 中 "alt" 是什么意思?
我知道这个函数是干什么的,但是不知道"alts"是什么意思,我很难记住函数名?它是 "alternative(s)" 的快捷方式吗?
来自 alt!
的文档字符串(强调已添加):
Makes a single choice between one of several channel operations, as if by alts!
和 alts!
(添加了重点):
Completes at most one of several channel operations.
这将支持 "alt" 是 "alternative" 或 "alternatives" 的缩写的观点。换句话说,从几个备选方案中选择一个。