Wither Self

Luke Gorrie luke@REDACTED
Wed Sep 10 19:56:14 CEST 2003


"Vlad Dumitrescu" <vlad_dumitrescu@REDACTED> writes:

> > In short, there are cases where locally defined recursive functions
> > are harder to read than the alternatives, and, based on Haskell and
> > ML experience, there are cases where they are much easier to read than
> > the alternatives.
> 
> I guess I am biased by some real-life examples I met, where the
> inlined function was a real monster and should have been split in 2
> or maybe 3 different simpler functions, the result still being
> easier to read than the original. Think just of 20 lines with an
> indentation of 50+ chars... *brrr*

IMO it's the indentation that is the biggest problem! I often avoid
using funs because they would push me over 80 columns.

We were discussing this over beer after the Erlang Workshop. Who's in
favour of hacking the Erlang indentation rules (i.e. Emacs mode) to
reduce indentation in funs?

Example:

  OLD:
  fun(X) ->
          foo(X)
  end.

  NEW:
  fun(X) ->
      foo(X)
  end.



  OLD:
  fun(X)
     when integer(X);
          list(X) ->
          foo(X);
     (Y) ->
          bar(X)
  end.

  NEW:
  fun(X)
   when integer(X);
        list(X) ->
      foo(X);
     (Y) ->
      bar(X)
  end.

Anything obvious I've missed? Any objections?

Cheers,
Luke




More information about the erlang-questions mailing list