[erlang-questions] DRY principle and the syntax inconsistency in fun vs. vanilla functions

Michael Turner <>
Thu May 19 08:48:35 CEST 2011


"... multi-clause funs just don't happen all that often ...."

The issue isn't multi-clause funs -- to maintain backward compatibility, if
nothing else, they'd have to retain their current syntax anyway. (Besides:
if multi-clause funs were more clearly documented, they might be
better-known and you might have seen them sooner in other people's code.)

In any case, multi-clause named functions are very common -- I'd say about
one third of the functions I write are multi-clause, and something close to
that ratio seems typical of most Erlang code. All I'm proposing is that we
should have the option of using the syntax of multi-clause funs in named
functions as well -- so that you only have to write the name once, among
other benefits.

-michael turner

On Thu, May 19, 2011 at 1:17 AM, Daniel Goertzen <
> wrote:

>
>
> On Wed, May 18, 2011 at 11:08 AM, Michael Turner <
> > wrote
>
> "I didn't ask that question until I *stumbled* on the extended syntax for
> funs; I didn't know about it before. The current documentation makes it hard
> to find."
>
>
>
>
> I think this is a key issue here: multi-clause funs just don't happen all
> that often.  It was very late in my Erlang learning experience that I found
> the need for multi-clause funs, and I easily found the documentation at the
> time.  I did notice the syntax inconsistency, but didn't care.   Anyway, it
> is often a good idea to break funs out into full functions to reduce nesting
> and facilitate tracing.  Lots of funs make programs hard to debug.
>
> Dan.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110519/f6ca17d7/attachment.html>


More information about the erlang-questions mailing list