From: Phrogz Date: 2007-11-05T22:45:19+09:00 Subject: Re: def blah do |x| -- alternate method definition syntax On Nov 5, 4:59 am, joe07...@gmail.com wrote: > Thanks matz and all. The define_method() trick hadn't occurred to me > -- almost the same, indeed. Why couldn't block parameter syntax be > extended to accept optional args: do |x, y=0| ? I Realize that this is > only meaningful for the hypothetical def usage, but come to think of > it I see no reason blocks couldn't accept optional args in cases where > they're .called(). Because the | operator exists, and there are some edge cases where it would be hard to determine when the block had ended. Something like: foo{ |x, y=0| 1+6|7 } could be either: foo{ |x, y=0| (1+6|7) } or foo{ |x, y=((0|1)+6)| 7 } IIRC, it's not just that such edge cases exist (where a sane human could possibly make a choice to disallow certain otherwise-legal syntax), but that it's very hard or impossible to adjust the syntax lexer to allow them.