Erlang article #1 on programming.reddit.com

Logan, Martin Martin.Logan@REDACTED
Thu Aug 17 21:43:34 CEST 2006


Rick, you are correct but technically the process loops in Erlang are
implemented via tail recursion.  I think this is where the
misunderstanding came about.  Procedural looping structures such as
"for", "while", "do while", and "foreach" are the sorts of looping
constructs that would severely damage Erlang as a language, IMHO.

Cheers,
Martin

-----Original Message-----
From: owner-erlang-questions@REDACTED
[mailto:owner-erlang-questions@REDACTED] On Behalf Of Rick Pettit
Sent: Thursday, August 17, 2006 1:50 PM
To: Ryan Rawson
Cc: Joel Reymont; Yariv Sadan; erlangquestions
Subject: Re: Erlang article #1 on programming.reddit.com

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 <joelr1@REDACTED> 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