[erlang-questions] Process scope variable

Richard A. O'Keefe ok@REDACTED
Fri Feb 20 01:16:36 CET 2015


On 20/02/2015, at 2:12 am, Imants Cekusins <imantc@REDACTED> wrote:
> a fun can return just what it did, without
> {Return, State}
> 
> so no more
> S1 = a(State),
> S2 = b(S1)
> 
> simply
> a(Pid)
> b(Pid)
> 
OK, this is where Haskell shines.  Haskell exploits the type system
to let you hide the plumbing, while the plumbing remains _there_.

However, you still have that Pid to pass around all the time, so
instead of simply threading state values through function calls,
you are passing around an armed grenade instead; you're still not
*hiding* the plumbing the way you can in Haskell.

Now I begin to see where you are coming from, but if renumbering
state variables was a big part of the time you spent refactoring,
you were probably doing it wrong, like maybe having big function
bodies with lots of stateful steps instead of little function
bodies with at most say three stateful steps.

Seeing REAL CODE would be a huge help in discussions like this.
I can't emphasise that strongly enough.  REAL CODE.

As in, not little ad hoc snippets, but actual chunks of the
code you are actually trying to work on.

What we really need is state monad combinators for Erlang.




More information about the erlang-questions mailing list