Issue #15955 has been updated by mame (Yusuke Endoh).


Matz approved the feature.  The name "apply" was arguable in some terms:

* We may want to use the name "apply" for other purpose in future.
* This API will be used not so frequently.  Only some fundamental libraries (like pp, sorbet-runtime, zeitwerk, etc.) will use it.

I proposed `UnboundMethod#bind_call` at the developers' meeting, and matz liked it.  I'll commit it soon.

----------------------------------------
Feature #15955: UnboundMethod#apply
https://bugs.ruby-lang.org/issues/15955#change-81278

* Author: nelhage (Nelson Elhage)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
I'd love a way to apply an UnboundMethod to a receiver and list of args without having to first `bind` it. I've ended up using `UnboundMethod`s in some hot paths in my application due to our metaprogramming idioms, and the allocation from `.bind` is comparatively expensive.

I'd love `unbound_method.apply(obj, args…)` to be equivalent to `unbound_method.bind(obj).call(args…)` but without allocating the intermediate `Method`



---Files--------------------------------
umethod_apply.patch (5.01 KB)


-- 
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>