From: "garysweaver (Gary Weaver)" Date: 2013-04-12T03:47:45+09:00 Subject: [ruby-core:54190] [ruby-trunk - Feature #8168] Feature request: support for (single) statement lambda syntax/definition Issue #8168 has been updated by garysweaver (Gary Weaver). @matz, You know best. :) !! I know that this request varies a bit when you consider that stab is a function call, but the goal is to de-uglify code that we are starting to have like: some_method :some, :args, :here, -> {the block makes a single expression look ugly} some_method :some, :args, :here, ->(x,y) {the block makes a single expression look ugly} instead of the more beautiful expression lambda proposed as ->>. But, I think you are alluding to the issue that: some_method :some, :args, :here, ->>(x,y) some expression is bad, because with those parentheses, it looks like a function call to ->> which should take a block. So, how about some other operator that could turn a single expression into a block? Perhaps this could be ultracool, and look like: some_class_method :some, :arg, ->(x,y)> some expression The obvious problem with that is that, though, may be that ">" would be taking on a special meaning in certain contexts, which would be difficult to read (and even more context sensitive to interpret?). So, I guess that the best solution is possibly a syntactical symbol that indicates that the expression that follows it should be converted into a block during parsing. I'm probably way off though. I wish that ->> would work, but perhaps it should be ->| or something. Thanks for taking time to consider this. It is just a nice to have, but Ruby is a beautiful language, and lambdas get so ugly, even with stabs. ---------------------------------------- Feature #8168: Feature request: support for (single) statement lambda syntax/definition https://bugs.ruby-lang.org/issues/8168#change-38466 Author: garysweaver (Gary Weaver) Status: Feedback Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: Abstract: Proposal for single statement lambda support, either via a new type of stab '->>', such that '->> some value;' would be equivalent to '-> {some value;}', or by just supplying a stab operator '->' with a value instead of a block (which would be more intuitive). Background: Often proc and lambda blocks are one statement long. Braces or do/end in this case are mostly unnecessary and result in less beautiful code Pros: may reduce amount of syntax required, especially if can re-use same operator. Cons: different stab operator may be confusing because of similarity to existing lambda operator. With either proposal, may cause additional overhead for interpreters. -- http://bugs.ruby-lang.org/