Project

General

Profile

Feature #5016

Kernel#caller with negative limit should limit result to N initial frames

Added by Nikolai Weibull about 5 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
[ruby-core:37988]

Description

Calling Kernel#caller with a negative limit should limit result to N initial frames. When using Kernel#caller you often only want the first element of the result to get the information of the immediate caller. Generating the whole backtrace in this case is wasteful and time-consuming. Allowing Kernel#caller to take a negative limit to only return the first -N initial stack frames would allow for this.


Related issues

Related to Ruby trunk - Feature #1906: Kernel#backtrace: Objectifying Kernel#caller Closed 08/07/2009
Related to Ruby trunk - Feature #3917: [proposal] called_from() which is much faster than caller() Closed 10/08/2010

History

#2 [ruby-core:38019] Updated by Nikolai Weibull about 5 years ago

I wouldn’t say “dup”, but it’s certainly related. This interface can be used instead of adding Kernel#called_from, if we want to keep the number of methods down. Also, even if we objectify the backtrace as per #1906 that still doesn’t mean that we shouldn’t have the limit as per this feature request.

#3 [ruby-core:43651] Updated by Yusuke Endoh over 4 years ago

  • Status changed from Open to Assigned
  • Assignee set to Koichi Sasada

#4 [ruby-core:43652] Updated by Koichi Sasada over 4 years ago

Calling Kernel#caller with a negative limit should limit result to N initial frames. When using Kernel#caller you often only want the first element of the result to get the information of the immediate caller. Generating the whole backtrace in this case is wasteful and time-consuming. Allowing Kernel#caller to take a negative limit to only return the first -N initial stack frames would allow for this.

There are similar proposals.
https://bugs.ruby-lang.org/issues/3917

Maybe there are other proposals. I want to summarize and implement 2.0.
At first, I want to know other alternative proposals. Please let me know.

--
// SASADA Koichi at atdot dot net

#5 [ruby-core:45853] Updated by Koichi Sasada about 4 years ago

  • Status changed from Assigned to Closed

Also available in: Atom PDF