From: Yehuda Katz Date: 2009-08-24T06:27:43+09:00 Subject: [ruby-core:25054] Re: Proposal: Simpler block format --00c09f8e5c386e01600471d5c5a1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On Sun, Aug 23, 2009 at 2:00 PM, Caleb Clausen wrote: > Yehuda Katz wrote: > >> On Sat, Aug 22, 2009 at 7:38 PM, Caleb Clausen > How do you disambiguate this case: >> >> { foo bar => baz } >> >> which could be parsed 2 ways: >> { foo(bar) => baz } #a hash >> or >> { foo(bar=>baz) } #a block >> >> >> Things that currently don't parse are fine to become blocks. I'd be >> worried about a case that currently parsed fine as a Hash but might be >> expected to be parsed as a block if this feature existed. Can you think of >> any? >> > > There's these 2, which parse as hashes currently: > > { p () => () } > { p {} => {} } > > Which confuse me, and presumably other humans. Maybe not confusing to > parsers... Both of those cases continue to parse as a Hash with this patch. Effectively, the patch simply fills in SyntaxError cases of { ... }, which should mean that anything that parsed as a Hash before will continue to do so, but anything that couldn't parse before will become a proc. > If you want to just define my first example to be a proc, that's fine. (I > think it will be easy enough to implement that way....) > > But I'd like to see a more explicit description of how this would work, if > I am to implement it. Making reference to an existing parser implementation > is unhelpful for me, especially as I am not familiar with the internals of > that implementation. Things that cause parse errors for MRI may not for > redparse; redparse is generally looser and more tolerant than MRI parse.y. > In other words, what would the appropriate section of a ruby standard read > when describing this feature? Understood -- but you do have the implementation to refer to. I agree that in order for this to be accepted, we would need to provide new RubySpecs to specify the behavior. I believe ujihisa is working on that. -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 --00c09f8e5c386e01600471d5c5a1 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Sun, Aug 23, 2009 at 2:00 PM, Caleb C= lausen <caleb= @inforadical.net> wrote:
Yehuda Katz wrote:
On Sat, Aug 22, 2009 at 7:38 PM, Caleb Clausen <caleb@inforadical.net =A0 =A0How do= you disambiguate this case:


=A0 =A0 { foo bar =3D> baz }

=A0 =A0which could be parsed 2 ways:
=A0 =A0 { foo(bar) =3D> baz } #a hash
=A0 =A0or
=A0 =A0 { foo(bar=3D>baz) } =A0 #a block


Things that currently don't parse are fine to become blocks. I'd be= worried about a case that currently parsed fine as a Hash but might be exp= ected to be parsed as a block if this feature existed. Can you think of any= ?

There's these 2, which parse as hashes currently:

=A0{ p () =3D> () }
=A0{ p {} =3D> {} }

Which confuse me, and presumably other humans. Maybe not confusing to parse= rs...

Both of those cases continue to parse= as a Hash with this patch. Effectively, the patch simply fills in SyntaxEr= ror cases of { ... }, which should mean that anything that parsed as a Hash= before will continue to do so, but anything that couldn't parse before= will become a proc.
=A0
If you want to just define my= first example to be a proc, that's fine. (I think it will be easy enou= gh to implement that way....)

But I'd like to see a more explicit description of how this would work,= if I am to implement it. Making reference to an existing parser implementa= tion is unhelpful for me, especially as I am not familiar with the internal= s of that implementation. Things that cause parse errors for MRI may not fo= r redparse; redparse is generally looser and more tolerant than MRI parse.y= . In other words, what would the appropriate section of a ruby standard rea= d when describing this feature?

Understood -- but you do have the implementation to ref= er to. I agree that in order for this to be accepted, we would need to prov= ide new RubySpecs to specify the behavior. I believe ujihisa is working on = that.

--
Yehuda Katz
Developer | Engine Yard
(ph) 718.877.132= 5
--00c09f8e5c386e01600471d5c5a1--