Feature #6012

Proc#source_location also return the column

Added by Roger Pack about 2 years ago. Updated over 1 year ago.

[ruby-core:42579]
Status:Assigned
Priority:Normal
Assignee:Nobuyoshi Nakada
Category:core
Target version:next minor

Description

As originally suggested in http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/42418

Suggestion/feature request:
have #source_location also return the beginning column where it was defined.
["test.rb", 8, 33]

Thanks!
-roger-


Related issues

Related to CommonRuby - Feature #8751: Add offsets to method#source_location Open 08/08/2013

History

#1 Updated by Roger Pack about 2 years ago

oops make that a feature request, but I'm unable to edit them myself.
Cheers!
-r

#2 Updated by Hiroshi Nakamura about 2 years ago

  • Tracker changed from Bug to Feature

#3 Updated by Koichi Sasada about 2 years ago

  • Category set to core
  • Assignee set to Nobuyoshi Nakada
  • Target version set to 2.0.0

#4 Updated by Thomas Sawyer about 2 years ago

Would this effect Method#source_location too?

I'm not sure I am really digging this idea. First of all it means I have to go back and fix some code. Secondly it means I have to always worry about the additional piece of data even though most of the time it doesn't matter. And if the return can vary between 2 or 3 elements that's another thing to worry with.

On the other hand I can understand that it could be useful information in some cases.

In times like this that I think "Embrace the Object".

proc.source_location #=> #

And then a few different methods could provide that information in various useful forms.

proc.sourcelocation.toa #=> ["foo.rb", 12, 14]
proc.sourcelocation.tos #=> "foo.rb:12"
proc.sourcelocation.valuesat(:file, :line) #=> ["foo.rb", 12]

Or what have you.

#5 Updated by Thomas Sawyer about 2 years ago

BTW & OT: When is any one going to explain how we format code examples as monospace text on this site?

#6 Updated by Eric Hodel about 2 years ago

On Feb 26, 2012, at 6:33 AM, Thomas Sawyer wrote:

BTW & OT: When is any one going to explain how we format code examples as monospace text on this site?

Click the RD button and use RD formatting (two spaces).

Here's a bash alias to help, which works for rdoc too.

alias rdindent='pr -l1 -o2'

#7 Updated by Thomas Sawyer about 2 years ago

Thanks Eric! I ((never)) noticed that ((%RD%)) "button" before (hardly looks like a button).

Why did it put:

=begin
=end

In the textarea when I clicked on it? ... maybe I'll find out by submitting this...

=begin
What's with the =begin =end?

Testing 1 2 3...

Try ((em)) (({code})) ((|ls|)) ((%var%)).
=end

Sorry for the noise.

#8 Updated by Thomas Sawyer about 2 years ago

Well, that failed miserably. LOL :-)

#9 Updated by Shyouhei Urabe about 2 years ago

  • Status changed from Open to Assigned

#10 Updated by Yutaka HARA over 1 year ago

  • Target version changed from 2.0.0 to next minor

Also available in: Atom PDF