user-defined operators

Shawn Pearce spearce@REDACTED
Fri Mar 26 06:35:18 CET 2004

Eric Newhuis <enewhuis@REDACTED> wrote:
> Erlang:
> lists:foldl (fun (X, A) -> X + A end, 0, [1, 2, 3, 4]).
> Would be nice to just say this in Erlang:
> 0 + over [1, 2, 3, 4].


Though I'm not really sure why.  :-)

I'm a perl hacker at heart, and one of my favorite operators has to be
=~ and !~.  In a language where you are doing text processing so much,
its very handy to have regular expressions "at your finger tips".

In Erlang, like LISP and Scheme, we do list processing all of the time:


Though fortunately there's a few ways to write these operations, with
LCs being a huge improvement for the first three (but is frowned upon
as a shorthand for foreach).  Still, it would be very nice if they were
even easier to express.

I'm very against operator overloading, as someone already metioned
the pain they went through trying to decide what the result of "2 + 2"
would be in some weird case...  I've had the same experience in C++ and
have never looked at the language again.  That one very bad feature of
the language has left a bad taste in my mouth.

But so has Python, Tcl, Java and Erlang when it comes to regular
expression processing - Perl just can't be beat (thanks to =~ and !~).

But Erlang can't be beat when it comes to concurrent/parallel processing.
Nothing is easier than receive ... end and !.  !! would be such a nice

Whatever happens here, folks are right to be worried about operator
pollution.  We don't want Erlang to start to look like Perl or someone's file (does anyone even remember those anymore?).  Erlang
code should be poetic, concise, and clearly understandable.  I find it
such a huge improvement over everything else I've written in to date,
so I would hate to see it change for the worse.


More information about the erlang-questions mailing list