Issue #5007 has been updated by judofyr (Magnus Holm).


I concur with trans: I don't think this issue will solve #6298. However, please keep that discussion out of this issue.

Would it be possible to get a OK/NG for inclusion of this in 2.1?

Still not sure about the name. Maybe #call_with is better?
----------------------------------------
Feature #5007: Proc#call_under: Unifying instance_eval and instance_exec
https://bugs.ruby-lang.org/issues/5007#change-40191

Author: judofyr (Magnus Holm)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: 
Target version: next minor


I'm proposing a method called Proc#call_under (the name could be
discussed) which both unifies instance_eval and instance_exec, and makes
it possible to call a Proc with a block and a scope:

  Proc#call_under(self, *args, &blk):

    proc { self }.call_under(1) # => 1

    proc { |a| self + a }.call_under(1, 2) # => 3

    proc { |&b| self + b.call }.call_under(2) { 2 } # => 4


-- 
http://bugs.ruby-lang.org/