From: SASADA Koichi Date: 2012-11-27T18:55:59+09:00 Subject: [ruby-core:50216] Re: [ruby-trunk - Feature #7434] Allow caller_locations and backtrace_locations to receive negative params (2012/11/27 18:35), sam.saffron (Sam Saffron) wrote: >> > The last point is API design. >> > "negative number" to this purpose is feasible? > I like negative numbers cause it has some parity with the range APIs, eg: [1,2,3][0..-2] # skip last I agree that it is similar to the negative end of range. However, range points *position* (index), not a size. I think similar, but different concept cause confusion. Ideas: (1) Accept your idea. Define new concept. (Do not refer Array#[]) (2) Introduce 3rd argument to specify eliminate I feel it is bad. (3) Consider argument (3-1) Accept Range object on 1st parameter caller(2..-2) #=> [foo2, ..., f/w2] on [ruby-core:50208] example. (3-2) ... no idea (3-1) seems good? It is same concept of Array#[]. Easy to explain. >> > Any other example for other methods? > I can not think of a use case for for the first param being negative, even though for arrays [1,2,3](-2..-1) makes sense, I can not think of a case where one would do caller_locations(-10, -1), the proposal is all about making the second param more flexible. I want to know other similar methods we can mimic. -- // SASADA Koichi at atdot dot net