From: richard.schneeman@... Date: 2014-04-28T17:55:51+00:00 Subject: [ruby-core:62201] [ruby-trunk - Feature #9777] Feature Proposal: Proc#to_lambda Issue #9777 has been updated by Richard Schneeman. Sorry for the delayed response. I was not "watching" this issue by default. > Why can't you use break and next? I wanted this to make a public api based on anonymous functions: https://github.com/opro/opro#password-token-exchange (note the return used in this section towards the bottom). New developers know the semantics of `return` very well but the differences between `lambda` and `Proc` are confusing to them, they are not familiar with the `break` keyword. If i tell new developers to use this API, create a block, and use `break` many would not do so and still use `return` by accident. This is my use-case, but others may have different or better ones. As mentioned 16 people were interested in this enough to google it, find the stack overflow post and up-vote the answer. ---------------------------------------- Feature #9777: Feature Proposal: Proc#to_lambda https://bugs.ruby-lang.org/issues/9777#change-46353 * Author: Richard Schneeman * Status: Feedback * Priority: Normal * Assignee: * Category: core * Target version: current: 2.2.0 ---------------------------------------- Currently different block objects such as a lambda can be converted into to a proc: http://www.ruby-doc.org/core-1.9.3/Proc.html#method-i-to_proc However you cannot turn a Proc instance into a lambda. Since a Proc and lambda behave differently sometimes you may want to convert between the two functionalities. One example is a `return` inside of the block. In a lambda the `return` keyword exits the closure, in a Proc the `return` keyword raises an exception. There is currently no implementation standard way to convert a Proc to a lambda. I made a gem that makes this easier: https://github.com/schneems/proc_to_lambda but it seems overkill. If MRI introduces a `to_lambda` method on Proc then we can standardize on an interface for this behavior. This question on stack overflow has been upvoted many times: http://stackoverflow.com/questions/2946603/ruby-convert-proc-to-lambda. I think other Ruby developers would like this behavior supported by Ruby core. -- https://bugs.ruby-lang.org/