[ruby-core:94774] [Ruby master Feature#16001] Provide an alias to Kernel#caller_locations(1, 1) and Kernel#caller(1, 1)
From:
daniel@...42.com
Date:
2019-09-04 13:33:13 UTC
List:
ruby-core #94774
Issue #16001 has been updated by Dan0042 (Daniel DeLorme). piotrmurach (Piotr Murach) wrote: > This is quite a common thing to do and it's not only about performance, though the performance aspect is equally important. I often see code `caller[0]` used to refer to the immediate frame which means that the whole backtrace is retrieved and then discarded. Maybe `caller` without any arguments should be deprecated? Force people to use e.g. `caller(1..)` if they really want the full expensive backtrace. ---------------------------------------- Feature #16001: Provide an alias to Kernel#caller_locations(1,1) and Kernel#caller(1,1) https://bugs.ruby-lang.org/issues/16001#change-81392 * 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 - a common mistake. 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: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>