[eeps] Request for comments on EEP-25 "Unnesting cases"
Abhay Kumar
abhay@REDACTED
Fri Dec 19 19:15:36 CET 2008
If the goal is to provide a fall-through behavior that's also easy to
read, then it would make sense to look at some of the other languages
besides Algol 86: C, C++, Java, PHP, ... (default), Ruby (else). I
like the idea of a different reserved word (not 'or') being used to
signify another branching path.
consider:
'case' Expression 'of'
Pattern ['when' Guard] '->' Expression
{';' Pattern ['when' Guard] '->' Expression}...
{';' 'else' 'case' Expression 'of'
Pattern ['when' Guard] '->' Expression
{';' Pattern ['when' Guard] '->' Expression}...}...
'end'
or:
'case' Expression 'of'
Pattern ['when' Guard] '->' Expression
{';' Pattern ['when' Guard] '->' Expression}...
{';' 'default' 'case' Expression 'of'
Pattern ['when' Guard] '->' Expression
{';' Pattern ['when' Guard] '->' Expression}...}...
'end'
I personally like 'else' but that might be my Ruby bias. 'default'
never makes semantic sense to me when using C based languages but I
just accepted it as it was. The best word is really 'otherwise' but
that's too long. 'els' is nice for spacing concerns.
I wonder if the parser should support two 'end' statements as i
expect that it will be one of the most common mistakes that someone
will make. Also, will the 'or' 'else' also support a fall-through
return for the block?
Cheers,
Abhay
On Dec 19, 2008, at 6:37 AM, Camille Troillard wrote:
> Hey everyone,
>
> On Fri, Dec 19, 2008 at 3:28 PM, Vlad Dumitrescu
> <vladdu55@REDACTED> wrote:
> > I for one find it acceptable. The "; or case" construct is ok -
> > perhaps not extremely elegant, but conveys the meaning
> > very well.
>
> This was the only aspect I was about to comment on too. Maybe "; else
> case" sounds better?
>
> I find this new construct very useful and helps keeping things neat
> instead of deeply nested.
> However I am also concerned by the "or" keyword.
> This may sound stupid but, on many keyboard the 'R' and the 'F' are
> very close, making OR and OF even more similar.
>
> I like "; else case", but before reading Vlad's post, I was about
> to suggest "; other case".
>
>
> Best,
> Cam
> _______________________________________________
> eeps mailing list
> eeps@REDACTED
> http://www.erlang.org/mailman/listinfo/eeps
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/eeps/attachments/20081219/618c4b29/attachment.htm>
More information about the eeps
mailing list