ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:42579] [ruby-trunk - Bug #6012][Open] Proc#source_location also return the column
@ 2012-02-14  0:17 Roger Pack
  2012-02-14  0:18 ` [ruby-core:42580] [ruby-trunk - Bug #6012] " Roger Pack
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: Roger Pack @ 2012-02-14  0:17 UTC (permalink / raw)
  To: ruby-core


Issue #6012 has been reported by Roger Pack.

----------------------------------------
Bug #6012: Proc#source_location also return the column
https://bugs.ruby-lang.org/issues/6012

Author: Roger Pack
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: 1.9.3


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-



-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:42580] [ruby-trunk - Bug #6012] Proc#source_location also return the column
  2012-02-14  0:17 [ruby-core:42579] [ruby-trunk - Bug #6012][Open] Proc#source_location also return the column Roger Pack
@ 2012-02-14  0:18 ` Roger Pack
  2012-02-25 20:06 ` [ruby-core:42928] [ruby-trunk - Feature " Koichi Sasada
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Roger Pack @ 2012-02-14  0:18 UTC (permalink / raw)
  To: ruby-core


Issue #6012 has been updated by Roger Pack.


oops make that a feature request, but I'm unable to edit them myself.
Cheers!
-r
----------------------------------------
Bug #6012: Proc#source_location also return the column
https://bugs.ruby-lang.org/issues/6012

Author: Roger Pack
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: 1.9.3


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-



-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:42928] [ruby-trunk - Feature #6012] Proc#source_location also return the column
  2012-02-14  0:17 [ruby-core:42579] [ruby-trunk - Bug #6012][Open] Proc#source_location also return the column Roger Pack
  2012-02-14  0:18 ` [ruby-core:42580] [ruby-trunk - Bug #6012] " Roger Pack
@ 2012-02-25 20:06 ` Koichi Sasada
  2012-02-26 14:32 ` [ruby-core:42951] " Thomas Sawyer
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Koichi Sasada @ 2012-02-25 20:06 UTC (permalink / raw)
  To: ruby-core


Issue #6012 has been updated by Koichi Sasada.

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


----------------------------------------
Feature #6012: Proc#source_location also return the column
https://bugs.ruby-lang.org/issues/6012

Author: Roger Pack
Status: Open
Priority: Normal
Assignee: Nobuyoshi Nakada
Category: core
Target version: 2.0.0


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-



-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:42951] [ruby-trunk - Feature #6012] Proc#source_location also return the column
  2012-02-14  0:17 [ruby-core:42579] [ruby-trunk - Bug #6012][Open] Proc#source_location also return the column Roger Pack
  2012-02-14  0:18 ` [ruby-core:42580] [ruby-trunk - Bug #6012] " Roger Pack
  2012-02-25 20:06 ` [ruby-core:42928] [ruby-trunk - Feature " Koichi Sasada
@ 2012-02-26 14:32 ` Thomas Sawyer
  2012-02-26 14:33 ` [ruby-core:42952] " Thomas Sawyer
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Thomas Sawyer @ 2012-02-26 14:32 UTC (permalink / raw)
  To: ruby-core


Issue #6012 has been updated by Thomas Sawyer.


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  #=>  #<SourceLocation @file="foo.rb" @line=12 @column=14>

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

  proc.source_location.to_a  #=>  ["foo.rb", 12, 14]
  proc.source_location.to_s  #=>  "foo.rb:12"
  proc.source_location.values_at(:file, :line)  #=>  ["foo.rb", 12]

Or what have you.
----------------------------------------
Feature #6012: Proc#source_location also return the column
https://bugs.ruby-lang.org/issues/6012

Author: Roger Pack
Status: Open
Priority: Normal
Assignee: Nobuyoshi Nakada
Category: core
Target version: 2.0.0


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-



-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:42952] [ruby-trunk - Feature #6012] Proc#source_location also return the column
  2012-02-14  0:17 [ruby-core:42579] [ruby-trunk - Bug #6012][Open] Proc#source_location also return the column Roger Pack
                   ` (2 preceding siblings ...)
  2012-02-26 14:32 ` [ruby-core:42951] " Thomas Sawyer
@ 2012-02-26 14:33 ` Thomas Sawyer
  2012-02-26 20:18   ` [ruby-core:42961] " Eric Hodel
  2012-02-27  0:39 ` [ruby-core:42964] " Thomas Sawyer
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 14+ messages in thread
From: Thomas Sawyer @ 2012-02-26 14:33 UTC (permalink / raw)
  To: ruby-core


Issue #6012 has been updated by Thomas Sawyer.


BTW & OT: When is any one going to explain how we format code examples as monospace text on this site?
----------------------------------------
Feature #6012: Proc#source_location also return the column
https://bugs.ruby-lang.org/issues/6012

Author: Roger Pack
Status: Open
Priority: Normal
Assignee: Nobuyoshi Nakada
Category: core
Target version: 2.0.0


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-



-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:42961] Re: [ruby-trunk - Feature #6012] Proc#source_location also return the column
  2012-02-26 14:33 ` [ruby-core:42952] " Thomas Sawyer
@ 2012-02-26 20:18   ` Eric Hodel
  0 siblings, 0 replies; 14+ messages in thread
From: Eric Hodel @ 2012-02-26 20:18 UTC (permalink / raw)
  To: ruby-core

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'

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:42964] [ruby-trunk - Feature #6012] Proc#source_location also return the column
  2012-02-14  0:17 [ruby-core:42579] [ruby-trunk - Bug #6012][Open] Proc#source_location also return the column Roger Pack
                   ` (3 preceding siblings ...)
  2012-02-26 14:33 ` [ruby-core:42952] " Thomas Sawyer
@ 2012-02-27  0:39 ` Thomas Sawyer
  2012-02-27  0:40 ` [ruby-core:42965] " Thomas Sawyer
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Thomas Sawyer @ 2012-02-27  0:39 UTC (permalink / raw)
  To: ruby-core


Issue #6012 has been updated by Thomas Sawyer.


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.

----------------------------------------
Feature #6012: Proc#source_location also return the column
https://bugs.ruby-lang.org/issues/6012

Author: Roger Pack
Status: Open
Priority: Normal
Assignee: Nobuyoshi Nakada
Category: core
Target version: 2.0.0


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-



-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:42965] [ruby-trunk - Feature #6012] Proc#source_location also return the column
  2012-02-14  0:17 [ruby-core:42579] [ruby-trunk - Bug #6012][Open] Proc#source_location also return the column Roger Pack
                   ` (4 preceding siblings ...)
  2012-02-27  0:39 ` [ruby-core:42964] " Thomas Sawyer
@ 2012-02-27  0:40 ` Thomas Sawyer
  2012-10-25 12:58 ` [ruby-core:48281] " yhara (Yutaka HARA)
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Thomas Sawyer @ 2012-02-27  0:40 UTC (permalink / raw)
  To: ruby-core


Issue #6012 has been updated by Thomas Sawyer.


Well, that failed miserably. LOL :-)
----------------------------------------
Feature #6012: Proc#source_location also return the column
https://bugs.ruby-lang.org/issues/6012

Author: Roger Pack
Status: Open
Priority: Normal
Assignee: Nobuyoshi Nakada
Category: core
Target version: 2.0.0


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-



-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:48281] [ruby-trunk - Feature #6012] Proc#source_location also return the column
  2012-02-14  0:17 [ruby-core:42579] [ruby-trunk - Bug #6012][Open] Proc#source_location also return the column Roger Pack
                   ` (5 preceding siblings ...)
  2012-02-27  0:40 ` [ruby-core:42965] " Thomas Sawyer
@ 2012-10-25 12:58 ` yhara (Yutaka HARA)
  2018-12-28  6:05 ` [ruby-core:90769] [Ruby trunk Feature#6012] " mame
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: yhara (Yutaka HARA) @ 2012-10-25 12:58 UTC (permalink / raw)
  To: ruby-core


Issue #6012 has been updated by yhara (Yutaka HARA).

Target version changed from 2.0.0 to next minor


----------------------------------------
Feature #6012: Proc#source_location also return the column
https://bugs.ruby-lang.org/issues/6012#change-31572

Author: rogerdpack (Roger Pack)
Status: Assigned
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: core
Target version: next minor


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-



-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:90769] [Ruby trunk Feature#6012] Proc#source_location also return the column
  2012-02-14  0:17 [ruby-core:42579] [ruby-trunk - Bug #6012][Open] Proc#source_location also return the column Roger Pack
                   ` (6 preceding siblings ...)
  2012-10-25 12:58 ` [ruby-core:48281] " yhara (Yutaka HARA)
@ 2018-12-28  6:05 ` mame
  2019-01-20 22:14 ` [ruby-core:91197] " samuel
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: mame @ 2018-12-28  6:05 UTC (permalink / raw)
  To: ruby-core

Issue #6012 has been updated by mame (Yusuke Endoh).


Now the abstract syntax tree has column information, so we can implement this issue.  We even add the last point of method.

```
# test.rb
◆def foo # ◆: line 2, column 0
end★     # ★: line 3, column 3

p method(:foo).source_location #=> ["test.rb", 2, 0, 3, 3]
```

----------------------------------------
Feature #6012: Proc#source_location also return the column
https://bugs.ruby-lang.org/issues/6012#change-75941

* Author: rogerdpack (Roger Pack)
* Status: Assigned
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 
----------------------------------------
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-




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:91197] [Ruby trunk Feature#6012] Proc#source_location also return the column
  2012-02-14  0:17 [ruby-core:42579] [ruby-trunk - Bug #6012][Open] Proc#source_location also return the column Roger Pack
                   ` (7 preceding siblings ...)
  2018-12-28  6:05 ` [ruby-core:90769] [Ruby trunk Feature#6012] " mame
@ 2019-01-20 22:14 ` samuel
  2019-02-12  1:24 ` [ruby-core:91512] " samuel
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: samuel @ 2019-01-20 22:14 UTC (permalink / raw)
  To: ruby-core

Issue #6012 has been updated by ioquatix (Samuel Williams).


If changing this API is too complicated due to backwards compatibility, why not introduce new more general API:

```
Method#source -> Source.new(path, line_number, line_count, code, ...)
```

Usage:

```
method.source.code
method.source.path
method.source.location -> [2, 0, 3, 3]
```

Maybe including byte offset and length would also be useful (for seek).

----------------------------------------
Feature #6012: Proc#source_location also return the column
https://bugs.ruby-lang.org/issues/6012#change-76429

* Author: rogerdpack (Roger Pack)
* Status: Assigned
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 
----------------------------------------
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-




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:91512] [Ruby trunk Feature#6012] Proc#source_location also return the column
  2012-02-14  0:17 [ruby-core:42579] [ruby-trunk - Bug #6012][Open] Proc#source_location also return the column Roger Pack
                   ` (8 preceding siblings ...)
  2019-01-20 22:14 ` [ruby-core:91197] " samuel
@ 2019-02-12  1:24 ` samuel
  2019-02-12  2:24 ` [ruby-core:91514] " samuel
  2019-02-12  7:49 ` [ruby-core:91518] " duerst
  11 siblings, 0 replies; 14+ messages in thread
From: samuel @ 2019-02-12  1:24 UTC (permalink / raw)
  To: ruby-core

Issue #6012 has been updated by ioquatix (Samuel Williams).


I also wish there was some meaningful implementation of `proc.source.hash` that was reasonably consistent across invocations of Ruby. Even if it was just best effort.

----------------------------------------
Feature #6012: Proc#source_location also return the column
https://bugs.ruby-lang.org/issues/6012#change-76772

* Author: rogerdpack (Roger Pack)
* Status: Assigned
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 
----------------------------------------
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-




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:91514] [Ruby trunk Feature#6012] Proc#source_location also return the column
  2012-02-14  0:17 [ruby-core:42579] [ruby-trunk - Bug #6012][Open] Proc#source_location also return the column Roger Pack
                   ` (9 preceding siblings ...)
  2019-02-12  1:24 ` [ruby-core:91512] " samuel
@ 2019-02-12  2:24 ` samuel
  2019-02-12  7:49 ` [ruby-core:91518] " duerst
  11 siblings, 0 replies; 14+ messages in thread
From: samuel @ 2019-02-12  2:24 UTC (permalink / raw)
  To: ruby-core

Issue #6012 has been updated by ioquatix (Samuel Williams).


I was playing around with this idea trying to make an implementation of `class Source`.

Is the source file cached in Ruby? Or should we use `File.read` to load it into memory?

It seems inefficient for large files, to find line/column offset. It would be nice to have absolute offset to seek to.

Maybe it's possible for `source_location` to append one more thing - the actual source code - if possible. This would be useful for situations like eval, where you might define something for a path that doesn't actually exist, but the source code is still available.

----------------------------------------
Feature #6012: Proc#source_location also return the column
https://bugs.ruby-lang.org/issues/6012#change-76774

* Author: rogerdpack (Roger Pack)
* Status: Assigned
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 
----------------------------------------
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-




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:91518] [Ruby trunk Feature#6012] Proc#source_location also return the column
  2012-02-14  0:17 [ruby-core:42579] [ruby-trunk - Bug #6012][Open] Proc#source_location also return the column Roger Pack
                   ` (10 preceding siblings ...)
  2019-02-12  2:24 ` [ruby-core:91514] " samuel
@ 2019-02-12  7:49 ` duerst
  11 siblings, 0 replies; 14+ messages in thread
From: duerst @ 2019-02-12  7:49 UTC (permalink / raw)
  To: ruby-core

Issue #6012 has been updated by duerst (Martin Dürst).


ioquatix (Samuel Williams) wrote:
> I also wish there was some meaningful implementation of `proc.source.hash` that was reasonably consistent across invocations of Ruby. Even if it was just best effort.

Please make that a separate feature if you are serious about it.

----------------------------------------
Feature #6012: Proc#source_location also return the column
https://bugs.ruby-lang.org/issues/6012#change-76778

* Author: rogerdpack (Roger Pack)
* Status: Assigned
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 
----------------------------------------
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-




-- 
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>

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-02-12  7:49 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-14  0:17 [ruby-core:42579] [ruby-trunk - Bug #6012][Open] Proc#source_location also return the column Roger Pack
2012-02-14  0:18 ` [ruby-core:42580] [ruby-trunk - Bug #6012] " Roger Pack
2012-02-25 20:06 ` [ruby-core:42928] [ruby-trunk - Feature " Koichi Sasada
2012-02-26 14:32 ` [ruby-core:42951] " Thomas Sawyer
2012-02-26 14:33 ` [ruby-core:42952] " Thomas Sawyer
2012-02-26 20:18   ` [ruby-core:42961] " Eric Hodel
2012-02-27  0:39 ` [ruby-core:42964] " Thomas Sawyer
2012-02-27  0:40 ` [ruby-core:42965] " Thomas Sawyer
2012-10-25 12:58 ` [ruby-core:48281] " yhara (Yutaka HARA)
2018-12-28  6:05 ` [ruby-core:90769] [Ruby trunk Feature#6012] " mame
2019-01-20 22:14 ` [ruby-core:91197] " samuel
2019-02-12  1:24 ` [ruby-core:91512] " samuel
2019-02-12  2:24 ` [ruby-core:91514] " samuel
2019-02-12  7:49 ` [ruby-core:91518] " duerst

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).