From: eregontp@... Date: 2019-07-15T09:29:47+00:00 Subject: [ruby-core:93784] [Ruby master Feature#16001] Provide an alias to Kernel#caller_locations(1, 1) and Kernel#caller(1, 1) Issue #16001 has been updated by Eregon (Benoit Daloze). chrisseaton (Chris Seaton) wrote: > This new method allows the user to explicitly say that they only need some of the callers. `caller` and `caller_locations` already allow that with the `length` argument, which is more flexible. I don't think there would be a significant performance difference between `caller_locations(1,1)` and `immediate_caller`, is it? piotrmurach (Piotr Murach) wrote: > That's a very important point. Limiting the full backtrace to the immediate caller will reduce unnecessary allocations. Which allocations? Isn't `caller_locations(1,1)` exactly the same as `immediate_caller`? Maybe the only difference is the first one returns an Array and the second just a `Thread::Backtrace::Location`? That's probably not significant for performance. ---------------------------------------- Feature #16001: Provide an alias to Kernel#caller_locations(1,1) and Kernel#caller(1,1) https://bugs.ruby-lang.org/issues/16001#change-79439 * Author: piotrmurach (Piotr Murach) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- As it is common to use `caller_locations(1,1)` and `caller(1,1)`, this proposes aliases to help get the previous backtrace frame and improve performance by avoiding getting full backtrace information. The currently suggestions are: * `immediate_caller` * `first_caller` * `caller_only` This feature request is based on a conversation with Charles Nutter who says: > This is such a common thing... maybe we need to add something like #caller_only or #caller1 that basically do caller(1,1). -- https://bugs.ruby-lang.org/ Unsubscribe: