From: Yehuda Katz Date: 2009-08-23T09:04:14+09:00 Subject: [ruby-core:25041] Proposal: Simpler block format --00c09f8a4fbd1668760471c3d62d Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I'd like to propose that we add the following syntax for procs in Ruby: x = { contents } x = { |y| contents } { contents }.should raise_error(Exception) call_method({ proc_1 }, { proc_2 }, { proc_3 }) Essentially, any use of {} that was not a Hash would become a proc. Effectively, this includes all use of {} that produces a SyntaxError at the moment ({} remains the equivalent of Hash.new). I suggested this to ujihisa, who is an expert at parse.y, and he created a patch that implements this behavior: http://gist.github.com/173052. This test does not cause any regressions in the Rails test suite or RubySpec. Among other things, this syntax makes using multiple blocks in a method call easier on the eyes. I was not initially sure that this would be easy to do, but ujihisa has done it! -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 --00c09f8a4fbd1668760471c3d62d Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
I'd like to propose that we add the following syntax for procs in = Ruby:

=A0=A0x =3D { contents }
=A0=A0x = =3D { |y| contents }
=A0=A0
=A0=A0{ contents }.should r= aise_error(Exception)
=A0=A0
=A0=A0call_method({ proc_1 }, { proc_2 }, { proc_3 })=
=A0=A0
Essentially, any use of {} that was not a Hash = would become a proc. Effectively, this includes all use of {} that produces= a SyntaxError at the moment ({} remains the equivalent of Hash.new). I sug= gested this to ujihisa, who is an expert at parse.y, and he created a patch= that implements this behavior: h= ttp://gist.github.com/173052. This test does not cause any regressions = in the Rails test suite or RubySpec.

Among other things, this syntax makes using multiple bl= ocks in a method call easier on the eyes. I was not initially sure that thi= s would be easy to do, but ujihisa has done it!

--
Yehuda Katz=
Developer | Engine Yard
(ph) 718.877.1325
--00c09f8a4fbd1668760471c3d62d--