ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:119320] [Ruby master Feature#6012] Proc#source_location also return the column
       [not found] <redmine.issue-6012.20120214091730.59@ruby-lang.org>
@ 2024-09-27 15:06 ` Eregon (Benoit Daloze) via ruby-core
  2024-09-27 15:21 ` [ruby-core:119322] " Eregon (Benoit Daloze) via ruby-core
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2024-09-27 15:06 UTC (permalink / raw)
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

Issue #6012 has been updated by Eregon (Benoit Daloze).


It seems good to revisit this, the workarounds are pretty messy and CRuby-specific, e.g. https://github.com/rails/rails/pull/53055/files

I think @mame 's suggestion in https://bugs.ruby-lang.org/issues/6012#note-12 is fine although I think it would be convenient to also expose the byte offsets (start and end):
`.source_location #=> [path, start_line, start_column, start_offset, end_line, end_column, end_offset]`

Then it would be really easy to "get the source code of a Proc".
And of course we should do the same for Method/UnboundMethod (#8751).

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

* Author: rogerdpack (Roger Pack)
* Status: Assigned
* Assignee: nobu (Nobuyoshi Nakada)
----------------------------------------
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/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:119322] [Ruby master Feature#6012] Proc#source_location also return the column
       [not found] <redmine.issue-6012.20120214091730.59@ruby-lang.org>
  2024-09-27 15:06 ` [ruby-core:119320] [Ruby master Feature#6012] Proc#source_location also return the column Eregon (Benoit Daloze) via ruby-core
@ 2024-09-27 15:21 ` Eregon (Benoit Daloze) via ruby-core
  2025-01-05 14:05 ` [ruby-core:120485] " Eregon (Benoit Daloze) via ruby-core
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2024-09-27 15:21 UTC (permalink / raw)
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

Issue #6012 has been updated by Eregon (Benoit Daloze).


I also really like @ioquatix 's suggestion in https://bugs.ruby-lang.org/issues/6012#note-13 and it is a lot more flexible and more efficient too (since computing e.g. column information if unused is not cheap).
For instance `method.source.code` is great because it completely hides the details how to get the source code and slice it.
TruffleRuby currently keeps the source code in memory and so could provide this automatically without needing to reread the file from disk.
CRuby keeps it but only if `RubyVM.keep_script_lines = true`, so then could use that if available and automatically fallback to read the file from disk (great, because we should avoid users/gems referring to `RubyVM` in their code).

One question is where would we place/how would we name this class?
We could reuse `Thread::Backtrace::Location` as it's quite similar and already has `path`, `lineno`.
But it's not really related to a backtrace here.
Still it seems quite a good fit, and I don't have much idea where to place it otherwise (top-level `Source` seems way too prone for conflicts).

I think in term of the interface we should have:
* start_line
* start_column
* start_offset
* end_line
* end_column
* end_offset
* code: gets the source of the Proc/Method/UnboundMethod

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

* Author: rogerdpack (Roger Pack)
* Status: Assigned
* Assignee: nobu (Nobuyoshi Nakada)
----------------------------------------
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/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:120485] [Ruby master Feature#6012] Proc#source_location also return the column
       [not found] <redmine.issue-6012.20120214091730.59@ruby-lang.org>
  2024-09-27 15:06 ` [ruby-core:119320] [Ruby master Feature#6012] Proc#source_location also return the column Eregon (Benoit Daloze) via ruby-core
  2024-09-27 15:21 ` [ruby-core:119322] " Eregon (Benoit Daloze) via ruby-core
@ 2025-01-05 14:05 ` Eregon (Benoit Daloze) via ruby-core
  2025-01-05 21:06 ` [ruby-core:120489] " bkuhlmann (Brooke Kuhlmann) via ruby-core
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2025-01-05 14:05 UTC (permalink / raw)
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

Issue #6012 has been updated by Eregon (Benoit Daloze).


One idea for this new SourceLocation/CodeLocation class would be under the new `Ruby` module, see https://bugs.ruby-lang.org/issues/20884#note-3

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

* Author: rogerdpack (Roger Pack)
* Status: Assigned
* Assignee: nobu (Nobuyoshi Nakada)
----------------------------------------
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/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:120489] [Ruby master Feature#6012] Proc#source_location also return the column
       [not found] <redmine.issue-6012.20120214091730.59@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2025-01-05 14:05 ` [ruby-core:120485] " Eregon (Benoit Daloze) via ruby-core
@ 2025-01-05 21:06 ` bkuhlmann (Brooke Kuhlmann) via ruby-core
  2025-01-09 11:26 ` [ruby-core:120566] " nobu (Nobuyoshi Nakada) via ruby-core
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: bkuhlmann (Brooke Kuhlmann) via ruby-core @ 2025-01-05 21:06 UTC (permalink / raw)
  To: ruby-core; +Cc: bkuhlmann (Brooke Kuhlmann)

Issue #6012 has been updated by bkuhlmann (Brooke Kuhlmann).


💡 Please see [Feature 21005](https://bugs.ruby-lang.org/issues/21005) as an evolution of this discussion based on feedback I've had with Kevin Newton and Benoit Daloze. Thanks.

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

* Author: rogerdpack (Roger Pack)
* Status: Assigned
* Assignee: nobu (Nobuyoshi Nakada)
----------------------------------------
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/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:120566] [Ruby master Feature#6012] Proc#source_location also return the column
       [not found] <redmine.issue-6012.20120214091730.59@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2025-01-05 21:06 ` [ruby-core:120489] " bkuhlmann (Brooke Kuhlmann) via ruby-core
@ 2025-01-09 11:26 ` nobu (Nobuyoshi Nakada) via ruby-core
  2025-01-09 11:51 ` [ruby-core:120572] " mame (Yusuke Endoh) via ruby-core
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2025-01-09 11:26 UTC (permalink / raw)
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #6012 has been updated by nobu (Nobuyoshi Nakada).


I'm not sure about attributes and `Binding#source_location`.

https://github.com/ruby/ruby/pull/12539

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

* Author: rogerdpack (Roger Pack)
* Status: Assigned
* Assignee: nobu (Nobuyoshi Nakada)
----------------------------------------
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/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:120572] [Ruby master Feature#6012] Proc#source_location also return the column
       [not found] <redmine.issue-6012.20120214091730.59@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2025-01-09 11:26 ` [ruby-core:120566] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2025-01-09 11:51 ` mame (Yusuke Endoh) via ruby-core
  2025-01-09 14:31 ` [ruby-core:120576] " Eregon (Benoit Daloze) via ruby-core
  2025-01-09 15:55 ` [ruby-core:120581] " Dan0042 (Daniel DeLorme) via ruby-core
  7 siblings, 0 replies; 8+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2025-01-09 11:51 UTC (permalink / raw)
  To: ruby-core; +Cc: mame (Yusuke Endoh)

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


This was discussed at the October 2024 dev meeting and @matz approved `source_location` to return `[path, start_line, start_column, end_line, end_column]`.

https://github.com/ruby/dev-meeting-log/blob/28e0f45f334b31e60c7e07d25b6b6cb3655b2c75/2024/DevMeeting-2024-10-03.md?plain=1#L176

Matz was negative neither on adding a new class like Ruby::CodeLocation for this purpose, or adding offset information.

We briefly re-asked matz about this at today's dev meeting, and he had not changed his mind.

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

* Author: rogerdpack (Roger Pack)
* Status: Assigned
* Assignee: nobu (Nobuyoshi Nakada)
----------------------------------------
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/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:120576] [Ruby master Feature#6012] Proc#source_location also return the column
       [not found] <redmine.issue-6012.20120214091730.59@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2025-01-09 11:51 ` [ruby-core:120572] " mame (Yusuke Endoh) via ruby-core
@ 2025-01-09 14:31 ` Eregon (Benoit Daloze) via ruby-core
  2025-01-09 15:55 ` [ruby-core:120581] " Dan0042 (Daniel DeLorme) via ruby-core
  7 siblings, 0 replies; 8+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2025-01-09 14:31 UTC (permalink / raw)
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

Issue #6012 has been updated by Eregon (Benoit Daloze).


Great to see this was accepted and even already implemented! (thanks @nobu!)

Byte offsets would be mostly for performance ("character" columns in multibyte files can be expensive to compute) and convenience (e.g. read the code at the given source_location from the file).
They are not strictly necessary.

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

* Author: rogerdpack (Roger Pack)
* Status: Closed
* Assignee: nobu (Nobuyoshi Nakada)
----------------------------------------
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/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:120581] [Ruby master Feature#6012] Proc#source_location also return the column
       [not found] <redmine.issue-6012.20120214091730.59@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2025-01-09 14:31 ` [ruby-core:120576] " Eregon (Benoit Daloze) via ruby-core
@ 2025-01-09 15:55 ` Dan0042 (Daniel DeLorme) via ruby-core
  7 siblings, 0 replies; 8+ messages in thread
From: Dan0042 (Daniel DeLorme) via ruby-core @ 2025-01-09 15:55 UTC (permalink / raw)
  To: ruby-core; +Cc: Dan0042 (Daniel DeLorme)

Issue #6012 has been updated by Dan0042 (Daniel DeLorme).


mame (Yusuke Endoh) wrote in #note-25:
> Matz was negative neither on adding a new class like Ruby::CodeLocation for this purpose

Any idea why? Because it seems like the "obviously correct" design so I'm curious why it was decided against.

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

* Author: rogerdpack (Roger Pack)
* Status: Closed
* Assignee: nobu (Nobuyoshi Nakada)
----------------------------------------
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/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

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

end of thread, other threads:[~2025-01-09 15:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-6012.20120214091730.59@ruby-lang.org>
2024-09-27 15:06 ` [ruby-core:119320] [Ruby master Feature#6012] Proc#source_location also return the column Eregon (Benoit Daloze) via ruby-core
2024-09-27 15:21 ` [ruby-core:119322] " Eregon (Benoit Daloze) via ruby-core
2025-01-05 14:05 ` [ruby-core:120485] " Eregon (Benoit Daloze) via ruby-core
2025-01-05 21:06 ` [ruby-core:120489] " bkuhlmann (Brooke Kuhlmann) via ruby-core
2025-01-09 11:26 ` [ruby-core:120566] " nobu (Nobuyoshi Nakada) via ruby-core
2025-01-09 11:51 ` [ruby-core:120572] " mame (Yusuke Endoh) via ruby-core
2025-01-09 14:31 ` [ruby-core:120576] " Eregon (Benoit Daloze) via ruby-core
2025-01-09 15:55 ` [ruby-core:120581] " Dan0042 (Daniel DeLorme) via ruby-core

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 NNTP newsgroup(s).