[erlang-questions] DRY principle and the syntax inconsistency in fun vs. vanilla functions
Thu May 19 13:41:50 CEST 2011
I would rather have one clear but slightly verbose way of doing things rather than two potential ways to do the same thing in slightly different manners prompting religious wars to get the same result I already have.
The idea to revisit the syntax isn't bad in itself, but looking at the examples Steve Davis provided, I can only see your concept being useful for very short functions.
When it comes to learning Erlang, I can tell you that in my experience, new users struggle a lot more with clause separators (;), expression separators (,), form terminators (.), records, 'if' or funs (in concept) than they do with function syntax. They do not seem to see the current way to write function heads as problematic. Then, all Erlang users are also used to it.
Adding more ways to do things that currently have a single way to be done is a net loss in my opinion. People already complain that Erlang's syntax is too ugly or complex; I do not think that adding more syntax is the way to solve that. It would not benefit new users and it would not benefit the majority of all users, only increase the ways they can read code and get confused.
In the other thread, someone called it 'syntactic salt', and I think this is a good way to describe how things are right now. It's not a bad thing in my opinion.
On 2011-05-19, at 06:47 AM, Michael Turner wrote:
> "But how interesting is whether existing code would break or not?"
> Not very. I mean, who uses Erlang for anything important? Hardly anybody, right?
> "It would, as others have pointed out, also be much harder to jump into a module and _know_ what the clause does since the function's name can be pages away."
> It would only be harder ("much"??) if you *chose*, in such cases, to use the syntax I propose to bring over from multi-clause funs. In the case you bring up, it might be wiser not to. And what I propose clearly allows everyone to continue with the present syntax. So your argument for readability in this case comes down to "somebody might not use this language feature wisely." (*facepalm*).
> -michael turner
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions