--0016365ee0e0f331c30496390220
Content-Type: text/plain; charset=ISO-8859-1

Good Afternoon,

On Mon, Nov 29, 2010 at 2:45 PM, Michael Kaelbling <
michael.kaelbling / siemens.com> wrote:

> REQUEST FOR COMMENTS: Change to future Ruby hash literal syntax
>
> In 1.9, if you prefer to omit parentheses and you write this:
>
>  h   a: Array.new 5, 'A', b: 0, c: 1 }   # Syntax error
>
> you will get a syntax error.  The following works:
>
>  h   a: Array.new(5, 'A'), b: 0, c: 1 }
>
> because the parser is not confused by the argument-separating comma
> and the element-separating comma.
>
> I propose that the owners consider changing the syntax.
>
> ALTERNATIVE 1: Same input, different interpretation
>
> If the scanner does lookahead and returns tASSOC_SEP for a comma
> that is followed by a label, then there is no ambiguity.
>
> ALTERNATIVE 2:  Use ';' to separate elements, use ',' for arguments
>
>  h   a: Array.new 5, 'A'; b: 0; c: 1 }   # Proposal 2
>
> This avoids shift-reduce conflicts by a simple change to the assocs
> production in parse.y, perhaps.  Unfortunately the semicolon looks
> strange, especially in array literals, when we address those, too.
>
> ALTERNATIVE 3: Allow ';' as an element separator, but keep ','
>
>  h   a: Array.new 5, 'A'; b: 0, c: 1 }    # Proposal 3
>
> This does not break working code.  It is like 'or' versus '||',
> and 'do' vs. '{', i.e., same role, different precedence.
>
>
I'd vote none of the above. That has got to be some of the ugliest looking
ruby code I've ever seen. None of those concepts looks to be legible at all.
Forget about what the parser handles....the human brain can't make heads nor
tails out of that stuff.

Is there honestly a use case that requires the code to be compacted into
that ugly a grouping of different concepts? I mean I can get the concept
that folks hate parentheses but you really couldn't do this?

x  rray.new 5, 'A'
h   a: x, b: 0, c: 1 }

John

--0016365ee0e0f331c30496390220--