Issue #5007 has been updated by phluid61 (Matthew Kerwin).


judofyr (Magnus Holm) wrote:
> Still not sure about the name. Maybe #call_with is better?

I suggest #call_as or #call_bound: "as" because it suggests that "self" in the proc will refer to the first parameter, or possibly "bound" because we're binding the proc to the object (as well as to its existing binding scope).  However I don't have strong feelings about any name, except that I like #call_with less than any others.

A side discussion: how does this tie in with currying?  For example, do you foresee a Proc#curry_under (or curry_self, or curry_with, or whatever) method, that would cause the proc to be passed to instance_exec when all its parameters are satisfied?
----------------------------------------
Feature #5007: Proc#call_under: Unifying instance_eval and instance_exec
https://bugs.ruby-lang.org/issues/5007#change-40193

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/