Issue #14904 has been updated by shyouhei (Shyouhei Urabe). -1. Seems you are already aware of the fact that lambdas are different from procs in handling of the arguments. Lambdas are strict, procs are loose. You are requesting to confuse this distinction. This is not a wise idea. At the beginning there was no lambdas in ruby. The strictness was found useful later, to introduce lambdas. Do not push things back. If you want this feature only because lambdas are "more readable" in your sense, you would better propose a better syntax of procs. ---------------------------------------- Feature #14904: Make it possible to run instance_eval with zero-arguments lambda https://bugs.ruby-lang.org/issues/14904#change-72905 * Author: prijutme4ty (Ilya Vorontsov) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- At a moment #instance_eval always yields an object to a given block. Though if we passed lambda as a block for instance_eval, its work depend on number of arguments. But I see no reason for such strictness when lambda gets zero arguments. In that case instance_eval can just skip yielding receiver to its block. It will reduce surprise for a newcomers who don't know the difference between proc and lambda. I got to this problem with code similar to this: ``` module ConfigParams def add_config_parameter(param_name, **kwargs, &block) # ... define_method(param_name){ kwargs[:default].call(self) } end end class KeyBindings extend ConfigParams add_config_parameter :undo add_config_parameter :redo, default: ->{ "shift+#{undo}" } end kb = KeyBindings.new kb.undo = 'ctrl+z' puts kb.redo # => shift+ctrl+z kb.redo = 'ctrl+y' ``` I want to allow user to express defaults with lambda which will be later evaluated in the context of an instance. It's a bit more readable than: ``` add_config_parameter :redo, default: proc{ "shift+#{undo}" } ``` And anyway, it'd be good if a user preferred to change proc into lambda didn't get strange exceptions. I've already found different solution - to use instance_exec instead of instance_eval. But I'm still sure that life could be easier it instance_eval handled zero-argument lambdas properly. Related: #10513 -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>