Erlang article #1 on programming.reddit.com
Joe Armstrong (TN/EAB)
joe.armstrong@REDACTED
Mon Aug 21 10:28:43 CEST 2006
You can't write many programs without loops, I use 'em all the time:
Most programs look like this:
loop(State) ->
receive
{From, Q} ->
{Reply, State1} = F(Q, State),
From ! {self(), Reply},
loop(State1)
end.
In often define:
for(Max, Max, F) -> [F(Max)];
for(I, Max, F) -> [F(I)|F(I+1,Max,F].
The word "loop" in the context of a function programming language is
usually taken to mean - "a tail recursive function" - basically
I call any function that can recurse forever without consuming stack a
loop.
/Joe
> -----Original Message-----
> From: owner-erlang-questions@REDACTED
> [mailto:owner-erlang-questions@REDACTED] On Behalf Of Logan, Martin
> Sent: den 17 augusti 2006 21:37
> To: Ryan Rawson; Joel Reymont
> Cc: Yariv Sadan; erlangquestions
> Subject: RE: Erlang article #1 on programming.reddit.com
>
> You are scaring me, who is talking of adding loops. I will
> stop using Erlang if I see a for loop :-) No more single
> assignment? That would make Erlang rather messy. Plus
> function clauses and recursion + loops inside function
> clauses themselves will greatly increase the cognative load
> imposed upon anyone trying to understand Erlang code. One of
> the greatest things about Erlang is that after a few months
> of coding it you can dive into the kernel, read code, and
> understand what you are reading
> - try doing that with Java, damn, try doing that with any
> OO/procedural language.
>
> Martin
>
> -----Original Message-----
> From: owner-erlang-questions@REDACTED
> [mailto:owner-erlang-questions@REDACTED] On Behalf Of Ryan Rawson
> Sent: Thursday, August 17, 2006 1:30 PM
> To: Joel Reymont
> Cc: Yariv Sadan; erlangquestions
> Subject: Re: Erlang article #1 on programming.reddit.com
>
> 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.
>
> 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.
>
>
>
> 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