Erlang article #1 on programming.reddit.com

Rick Pettit <>
Thu Aug 17 20:50:26 CEST 2006


On Thu, Aug 17, 2006 at 11:30:19AM -0700, Ryan Rawson wrote:
> Surely you jest?
> 
> You'd have to break Erlang to insert loops.  First off you'd have
> variables that need to be changed.  That substantiably breaks Erlang
> imho.

Not sure I understand you here. I have recently been using Joe Armstrong's
robust TCP server, for example, and in that there is the notion of a
"controller" loop for synchronizing operations among multiple socket handlers.

For "simple servers" (i.e. those not requiring a behaviour like gen_server)
I see tail-recursive server loop constructs all the time.

Single assignment isn't a problem considering each new iteration through the
loop allows for new local variable bindings, etc.

> If you want to loop, you probably want to map or fold.  If you need to
> loop you might want to use gen_server instead, or at the last resort
> use a tail recursive call.

What do you think goes on behind the scenes in a map, fold, or even gen_server?

You might be surprised to find that there is a server loop in a gen_server
(it is what passes the state to gen_server callbacks, and it is what the
gen_server callbacks return the state to).

Perhaps I misunderstand you.

-Rick

> On 8/17/06, Joel Reymont <> wrote:
> >
> >On Aug 17, 2006, at 5:53 PM, Ryan Rawson wrote:
> >
> >> I beg of all of you - no for loops.  No looping of any kind!
> >
> >What's wrong with looping?
> >
> >--
> >http://wagerlabs.com/
> >
> >
> >
> >
> >
> >



More information about the erlang-questions mailing list