On 19 Dec 2013, at 5:17 am, Kevin Ballard <[email protected]> wrote: > 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
I think one of the points was that you could update the behaviour of the server as it was running. I changed my gist to show that: https://gist.github.com/bjz/e4d536c63900960c9e15#file-universal_server-rs-L63-L67 This is where I find that the static types come in handy, despite their verbosity. It’s much easier to understand what’s going on from the types alone. ~Brendan _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
