英文:
Why do CSP implementations only cover channels?
问题
在关于通信顺序进程的书中,花了很多时间来定义事件,这些事件没有方向,可以涉及多个独立的进程。
只有在第4章中引入了通道,这些通道是有方向的,涉及两个进程。
然而,包括occam、Go、LuaCSP和clojure.core.async在内的所有CSP实现都只实现了通道。
尽管大多数实际问题可以通过(广播)通道来解决,但我想知道为什么这本书在事件上花了这么多时间,而没有人使用它们。
英文:
In the book about Communicating Sequential Processes a lot of time is spent defining events, which have no direction and can involve multiple independent processes.
Only in chapter 4 are channels introduced, which are directed and involve 2 processes.
Yet all implementations of CSP including occam, Go, LuaCSP and clojure.core.async only implement channels.
Even though most practical problems can be solved with (broadcast) channels, I wonder why the book spends so much time on them while nobody uses them.
答案1
得分: 9
首先,这本书是在实现之前发生的。因此,你的问题最好这样表述:
> 为什么CSP的实现没有将事件作为重点,尽管这本书非常强调它们。
基本上,将事件作为语言的一等公民会给它带来一定的使用特定性,这可能对于通用编程语言来说太狭窄了。
此外,你可以在通道(和其他结构)上轻松实现事件,如果你对事件驱动编程感兴趣。
英文:
Well first of all the book happened before the implementations. Therefore your question is better formulated as:
> Why does no implementation of CSP put a major focus on events even though the book emphazises them greatly.
Basically, making events a first-class citizen of a language gives it a certain usage specificity that would probably be too narrow for a general purpose programming language.
Additionally, you can easily implement events on channels (and other constructs), in case you are into event driven programming.
答案2
得分: 2
在Occam-pi中,屏障是通道的重要补充。通过屏障,每个已注册的进程都会等待屏障,直到它们都这样做为止。在此时,它们都会被释放。这是CSP事件的一种非通道形式的示例。
Occam-pi还使用通道实现了扩展的会合。这是一种与Ada中的会合非常相似的通道使用模式。
英文:
In Occam-pi, barriers are an important adjunct to channels. With a barrier, each enrolled process waits on the barrier until they have all done so. At this point they are all released. This is an example of a non-channel form of CSP event.
Occam-pi also has an extended rendezvous using channels. This is a quite different pattern of usage of channels, very similar to the rendezvous in Ada.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论