That's cute, but I don't really understand the point. The sample program he
gave:
test() ->
Pid = spawn(fun universal_server/0),
Pid ! {become, fun factorial_server/0},
Pid ! {self(), 50},
receive
X -> X
end.
will behave identically if you remove universal_server from the equation:
test() ->
Pid = spawn(fun factorial_server/0),
Pid ! {self(), 50},
receive
X -> X
end.
The whole point of universal_server, AFAICT, is to just demonstrate something
clever about Erlang's task communication primitives. The equivalent in Rust
would require passing channels back and forth, because factorial_server needs
to receive different data than universal_server. The only alternative that I
can think of would be to have a channel of ~Any+Send objects, which isn't very
nice.
To that end, I don't see the benefit of trying to reproduce the same
functionality in Rust, because it's just not a good fit for Rust's task
communication primitives.
-Kevin
On Dec 18, 2013, at 6:26 AM, Benjamin Striegel <[email protected]> wrote:
> Hello rusties, I was reading a blog post by Joe Armstrong recently in which
> he shows off his favorite tiny Erlang program, called the Universal Server:
>
> http://joearms.github.io/2013/11/21/My-favorite-erlang-program.html
>
> I know that Rust doesn't have quite the same task communication primitives as
> Erlang, but I'd be interested to see what the Rust equivalent of this program
> would look like if anyone's up to the task of translating it.
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev