On 13/01/2008, <b class="gmail_sendername">Christian S</b> <<a href="mailto:firstname.lastname@example.org">email@example.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
2008/1/13 David Cabana <<a href="mailto:firstname.lastname@example.org">email@example.com</a>>:<br>> Well, things are what they are. Erlang simply does not have the clean syntax<br>> of scheme or Haskell with respect to passing functions as arguments. But
<br>> why? Is this merely cruft, or does it serve some purpose?<br><br>Funs were added later on to erlang, that can explain why they do not have more<br>convenient syntax. So "cruft" by your taxonomy I guess.
</blockquote><div><br>There is one feature of Erlang which seriously screws up the handling of functions compared to Scheme and Haskell, and that is having functions with the same name but with different arities. This means that there is no clear binding function <-> name which you need to be able to write as you can in the other languages. To refer to a function you need both the name and the arity. Period. The same with exported functions, to refer to a function in another module you need the module name, the function name and its arity.
<br><br>That is why you have a construction fun to create a function reference, it contains the arity within it. The "fun name/arity" syntax is really just a short form for:<br><br>fun (A1, ..., An) -> name/A1, ..., An) end.