[erlang-questions] Re: Breaking out of a foldl

Robert Virding <>
Tue Jun 2 10:40:21 CEST 2009


2009/6/2 mats cronqvist <>

>
> > Yeah, but it's syntax is somewhat misleading. People with
> > Java/C++/Eiffel/etc. background would expect that exceptions should be
> > used in exceptional situation, not instead of a return statement
> > (which Erlang lacks).
>
>   Erlang might lack the keyword 'return', but it does have a non-local
>  return construct; 'throw'. Whether or not C++ have problems with
>  that seems quite off-topic here.


True, true. I just want to confirm here that it is exactly as Richard said
in an earlier post that catch/throw came directly from the lisp world. We
had no problems with it. :-) The only complaint I have with catch is that it
also catches errors, but it *was* a predecessor to try so it had to catch
everything.


> Perhaps we can agree that keeping the core libraries small, consistent
>  and intuitive is a very good thing (*).
>
>  ...
>
> (*) Unfortunately, the current libs fails on all of these; there's way
>  too much cruft (like lists:foldr), they're inconsistent (like string
>  sub_string/substr) and counter-intuitive ( try e.g. lists:seq(2,1)).


Foldr is pretty natural, I think anyway. String is a mess of course, but
there were at one time 2 string libraries and this was the easy way out (but
the wrong way in the long run). There *is*, however, as you say a lot of
cruft in the libraries, but knowing the difficulties with getting rid of
something it is most likely to stay that way.

Robert


More information about the erlang-questions mailing list