[erlang-questions] Funargs: Ruby-like blocks for Erlang
Fri Jul 22 06:28:02 CEST 2011
On 22/07/2011, at 3:49 PM, Tony Arcieri wrote:
> On Thu, Jul 21, 2011 at 7:43 PM, Richard O'Keefe <ok@REDACTED> wrote:
> Wrong. In funs, "end" is paired with "fun" and "fun" ONLY.
> Okay, conceded (and Jachym made the same point)
> I'll revert to my other point, which is that the '->' token in Erlang is only found in forms outside of funs, which are expressions. No other expression in Erlang uses the '->' token.
I am totally confused here.
Erlang constructs "->" if and only if they have patterns-and-guards
(well, patterns-and-or-guards, to be picky) to separate from bodies.
That's it. No exceptions.
I have just revised the Expressions chapter of the reference manual,
and I cannot find one single example of a kind of expression that
_should_ use "->" but doesn't.
So what kind of expression do _you_ think ought to use "->" but doesn't?
> I'd also ask what you feel about the people who responded to this thread
> who find the Erlang fun syntax awkward. I certainly find it awkward.
Oh dear, this is going to sound insulting, but it's not meant that way.
I am more impressed by people who demonstrate that they understand how
the current syntax actually *works* before they complain about it.
I myself have said that I find Erlang syntax "clunky but tasteful".
It uses more tokens than Haskell does.
But then, Haskell syntax is surprisingly tricky, and I'm not sure
how many Haskell parsers actually get it 100% right.
For reference, it took a huge amount of fighting in the ISO Prolog
committee to agree on an unambiguous syntax, and in the revision mailing
list there are continuing, um, strong disagreements. I think the
restrictions compared with classic Prolog were and are too severe. But
a correspondent who has done a heck of a lot more work on standards issues
in recent years than I have points out with a great deal of justice that
the various Prolog implementations out there STILL don't agree on syntax,
not as much as their authors fondly imagine. He'd like to see them get
what's in the standard right before adding anything else.
Do not despise a simple syntax that implementors can actually get RIGHT.
It is *HARD* to come up with a clean coherent syntax for the whole of a
programming language. And it is triply hard to patch your way there,
and outright impossible to do it by adding inconsistencies.
Yes, "fun ... end" is not as pretty as it could be, but for something
that was added years after Erlang was shipping, it's nearly as close
to the rest of the language as anyone could wish for. (The thing I
don't like is the scope rules for variables shared between "fun" heads
and their contexts, which has nothing to do with keywords or
More information about the erlang-questions