[erlang-questions] What is the purpose of the fun vs function distinction?
Christian S
chsu79@REDACTED
Sun Jan 13 21:55:12 CET 2008
2008/1/13 David Cabana <drcabana@REDACTED>:
> is not valid Erlang, not even inside foo. Instead one has to write
> lists:map(fun foo:double/1, [1,2,3]
If you are inside foo, then "fun double/1" suffices, no need to export
it that way.
> Finding this tedious, I try another seemingly natural idea: I'll define my
> functions as funs.
> doub = fun(X) -> 2*X end.
That is a bad match, did you mean "Doub = fun(X) -> 2*X end" ?
> Well, things are what they are. Erlang simply does not have the clean syntax
> of scheme or Haskell with respect to passing functions as arguments. But
> why? Is this merely cruft, or does it serve some purpose?
Funs were added later on to erlang, that can explain why they do not have more
convenient syntax. So "cruft" by your taxonomy I guess.
More information about the erlang-questions
mailing list