Skip to content

Commit 52d3cf7

Browse files
committed
Document Thread.each_caller_location parameters
These parameters were added in https://bugs.ruby-lang.org/issues/20335, but the call-seq was never updated to mention them.
1 parent 33744d2 commit 52d3cf7

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

vm_backtrace.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1424,10 +1424,27 @@ rb_f_caller_locations(int argc, VALUE *argv, VALUE _)
14241424

14251425
/*
14261426
* call-seq:
1427-
* Thread.each_caller_location(...) { |loc| ... } -> nil
1427+
* Thread.each_caller_location(start=1, length=nil) {|loc| ... } -> nil
1428+
* Thread.each_caller_location(range) {|loc| ... } -> nil
14281429
*
14291430
* Yields each frame of the current execution stack as a
14301431
* backtrace location object.
1432+
*
1433+
* Similar to +Kernel#caller_locations+, but without allocating an array.
1434+
* The parameters work the same way:
1435+
*
1436+
* The optional _start_ parameter determines the number of initial stack
1437+
* entries to omit from the top of the stack.
1438+
*
1439+
* A second optional +length+ parameter can be used to limit how many entries
1440+
* are yielded from the stack.
1441+
*
1442+
* Optionally you can pass a range, which will yield the entries within the
1443+
* specified range.
1444+
*
1445+
* Unlike +Kernel#caller_locations+, this method does not allocate an array,
1446+
* and is therefore more efficient when only some of the entries are needed.
1447+
* The block can +break+ early to stop iterating through the stack.
14311448
*/
14321449
static VALUE
14331450
each_caller_location(int argc, VALUE *argv, VALUE _)

0 commit comments

Comments
 (0)