[erlang-questions] Process scope variable

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


On 20/02/2015, at 2:16 am, Imants Cekusins <imantc@REDACTED> wrote:

>> "ok, a method called 'fred'.  Wonder what it does?"
> 
> well let's just say if I understand program flow, this is not a
> problem.

If it is unfamiliar code, then by definition I don't understand
the control flow.

Last week, a test case failed in my Smalltalk system.
I had refactored A -> C to A -> B -> C.  This was in most
respects a nice win -- half of C had disappeared -- and I'd
been using the new C for a while.  But the new test case
used a different constructor, and suddenly it blew up in
a strange way.  It took me an hour to disentangle the
control flow, and I had written every line of it all.

There were actually two bugs.
(1) a method was being called during construction when it expected
to be called after.  The control flow had changed.
(2) a method override that wasn't needed now that B was there
still existed and was being called.  A control flow should have
changed but hadn't.

As Dijkstra pointed out back in the 60s, when we have to play
computer in order to figure things out, we're in trouble.

> If I do not understand it, long explicit signatures are not
> of much help.

That's not my experience.

In particular, a function

   foo(State0, Input) -> {State1, Output}

is a function I can understand in isolation, and I can use
type checking to constrain its uses.  A function

   foo(Pid, Input) -> Output

is something I can't understand without understanding a
great deal about the process Pid refers to, without any
type/state system telling me about that.







More information about the erlang-questions mailing list