Issue #16001 has been updated by piotrmurach (Piotr Murach).


Eregon (Benoit Daloze) wrote:
> Maybe `direct_caller`?
> 
> Would it call `caller_locations(1,1)` or `caller(1,1)`? It can only be one of them.

That's a very good point. I'd probably lean towards modern API of `caller_locations(1,1)` if we only used a single alias. However, we could follow a pattern and name `caller_locations(1,1)` as `direct_caller_location` and `caller(1,1)` as `direct_caller`?

----------------------------------------
Feature #16001: Provide an alias to Kernel#caller_locations(1,1) and Kernel#caller(1,1)
https://bugs.ruby-lang.org/issues/16001#change-79394

* 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 an alias to help get the previous backtrace frame and avoid common beginner mistakes getting full backtrace information.

The currently suggestions are:
* `immediate_caller`
* `caller_first`
* `caller_only`

This feature request is based on 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>