[ruby-core:93933] [Ruby master Feature#15955] UnboundMethod#apply
From:
jean.boussier@...
Date:
2019-07-26 13:48:38 UTC
List:
ruby-core #93933
Issue #15955 has been updated by byroot (Jean Boussier). Zeitwerk had the exact same use case recently: https://github.com/fxn/zeitwerk/blob/ba7ff65d40a4309701981f9443249ac7e0e8c65f/lib/zeitwerk/real_mod_name.rb i.e. get the true Module name even if the method was redefined. ---------------------------------------- Feature #15955: UnboundMethod#apply https://bugs.ruby-lang.org/issues/15955#change-80062 * 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` -- 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>