From: Yukihiro Matsumoto Date: 2010-09-09T10:07:22+09:00 Subject: [ruby-core:32186] Re: Making custom_lambda() work Hi, In message "Re: [ruby-core:32154] Making custom_lambda() work" on Thu, 9 Sep 2010 01:21:57 +0900, Magnus Holm writes: |A tiny suggestion for how we could make it possible to call lambdas |with parenthesis. | |Two changes in the parser: | |1) If the parser sees "foo()" and "foo" is a local variable (in the |local variable table), it's the same as foo.call(). |2) Allow parenthesis after an expression. So "foo[:bar]()" and |"(foo.bar)()" is the same as "foo[:bar].call()" and |"(foo.bar).call()". Of course, the parenthesis after a method call |should take precedence over these parenthesis (so "foo()" doesn't get |rewritten to "foo.call()") I once have made a patch to the parser to allow (1), but I gave up, because it introduced several syntax errors in the bundled libraries. In general depending on context is a bad idea in Ruby. In fact, the current Ruby works differently depending on whether an identifier is a local variable or not (for parenthesis resolution), but I strongly regret and want to remove it in the future. I have tried (2) also. It was too long ago to remember the detail, but according to my vague memory, it caused parser conflicts. But still, these problems are due to my patch implementation, besides mu opinion. Some may come up with better patches in the future. I will happily reconsider my last decision. matz.