本文介绍了在Clojure(core.async)中alts和alt之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我无法弄清楚之间的区别:I can't figure out the difference between:alts!和alt! core.async 。推荐答案 alts!一个函数,接受要从中取出的频道向量和/或带有值的频道(以双向向量的形式: [cv] )。可以动态地构造向量;调用 alts!的代码可能不知道它将选择多少个频道(并且实际上该调用不需要在调用中保持不变)。alts! is a function that accepts a vector of channels to take from and/or channels with values to be put on them (in the form of doubleton vectors: [c v]). The vector may be dynamically constructed; the code calling alts! may not know how many channels it'll be choosing among (and indeed that number need not be constant across invocations). alt!是一个方便的宏,基本上作为 cond 和 alts!。这里,端口(通道或通道+值对)的数量必须静态地知道,但是在实践中这是经常的情况,并且 cond 清除alt! is a convenience macro which basically acts as a cross between cond and alts!. Here the number of "ports" (channels or channel+value pairs) must be known statically, but in practice this is quite often the case and the cond-like syntax is very clear. alt!使用 alts! c $ c>;除了语法方便之外,它不提供额外的功能。alt! expands to a somewhat elaborate expression using alts!; apart from the syntactic convenience, it offers no extra functionality. 这篇关于在Clojure(core.async)中alts和alt之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-12 07:22