Suggested Example/ emacs questions

Luke Gorrie <>
Tue Oct 10 11:14:00 CEST 2000


 writes:

> For example, if you use a gen_server to write your first server,
> you'll get working code which is well-behaved. But nobody does
> that. Everyone writes a 'classic' receive-loop server first and thinks
> "hey! that's really neat and simple"*. And then you can go away and use
> gen_server because it makes a lot of fiddly details go away. But
> you never forget that the 'classic' server is the beautiful one.

Yup. Lately I've been noticing that I don't write the receive loops of
many servers, because I just use gen_server. That seems like a shame
because what I really miss is the lovely "I communicate, therefore I
synchronise" style you get if you use guarded receive clauses to
decide in which order you'll receive messages, e.g.:

  receive {push, Item} when Full == false ->

to implicitly block push requests for a bounded stack while it's full,
and that sort of thing. The stuff I got excited about when reading
_communicating sequential processes_.

Anyone empathise? :-) I'm not sure whether it's just that most of my
programs don't need guarded receives and fancy synchronisation, or
whether I'm just too far into the habbit of using gen_server to write
beautiful receive loops. I'm suspicious that it's the latter :)

-Luke




More information about the erlang-questions mailing list