[erlang-questions] Ideas for a new Erlang

Ulf Wiger <>
Wed Jun 25 23:57:37 CEST 2008


2008/6/25 Vlad Dumitrescu <>:
>
> I'm not sure I get the reason why channels would be useful. I see two
> possibilities:
> a) for performance, when each channel has a different mailbox
> b) to simplify the code/architecture

I don't think channels would simplify the code, but they might make
it easier to reason about it. The thing that selective receive brings to
the table is scoped message reception. The Erlang approach of
pattern-matching on a single message queue is extremely flexible,
but it's difficult to "prove" the code correct. For example, it is quite
possible for a piece of code to consume someone else's 'DOWN'
message, by ignoring the Ref part. If channels followed the same
scoping rules as variables (and channels aren't just syntactic sugar
on top of a single message queue), a function could not steal someone
else's messages.

Not that these kinds of bugs are commonplace in Erlang. It's quite
easy to avoid them using simple conventions. But there is, after all,
a difference between "easy to avoid" and "impossible", which can
sometimes be significant.

Haskell has channels, and so does .NET (mailbox objects). There is
therefore an opportunity to compare programs and try to determine
whether programming with channels makes for more or less
readable code than erlang's selective receive.

BR,
Ulf W



More information about the erlang-questions mailing list