Question

At 15:30 in this talk (p13 of this presentation here) Rich Hickey mentions the formalisms available for reasoning about Communicating Sequential Processes. He then goes on to mention that these haven't yet been applied to Clojure's core.async.

The only reference I know of for CSP is Hoare's book. I can see some examples of formalisms to describe CSP here.

Suppose I wanted to do the most basic of CSP as per Rob Pike's presentation in Go (slide 43 of this).

var (
    Web = fakeSearch("web")
    Image = fakeSearch("image")
    Video = fakeSearch("video")
)

type Search func(query string) Result

func fakeSearch(kind string) Search {
        return func(query string) Result {
              //time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
              return Result(fmt.Sprintf("%s result for %q\n", kind, query))
        }
}

How would I express this as an Algebraic statement? What benefit would it give me?

Taking a stab at it - I get

(Web → P) Π (Search → Q) Π (Video → R)

Which tells me that the Search process can choose to interact with Web or Video depending on which environment the Search Process chooses to communicate with.

Assumptions

I'm told that you can't do this in pure CSP because of the timer. For an answer I'm happy to assume we'll ignore the timer part of this.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange
scroll top