[ruby-core:124464] [Ruby Feature#6012] Proc#source_location also return the column
Issue #6012 has been updated by Eregon (Benoit Daloze). mame (Yusuke Endoh) wrote in #note-50:
"I don't know exactly what users are using the `method_source` gem for, but since it's used so much, we should provide equivalent functionality as a built-in feature"
This argument can hardly persuade anyone... However, let’s assume we proceed with that logic. In that case, `source_location` would have to follow the behavior of the `method_source` gem exactly, without questioning its validity (including heredocs and the glitch-like behavior you pointed out). Since we do not know the user's ultimate purpose, there is a possibility that those glitch-like behaviors happen to be exactly what satisfies the user.
Is that really what you want?
Of course there is nuance there. I think the high usage of that gem means that some functionality there is found useful by many. I think looking a bit further than the number of usages to what the usages look like I did in https://bugs.ruby-lang.org/issues/6012#note-47 is good. I think knowing the exact ultimate purpose of each usage is unnecessary and would require way too much work, and that this grouping of some ultimate purposes is enough:
The above snippets show examples of source transformation, instrumentation of code by adding extra code in the method body, displaying the source code of a method to the user, and other use cases which would need more time to find out.
Also the analysis above showing e.g. having `end_line` is a recurrent need. That is I believe enough to justify the extended `source_location`, and the fact #21795 doesn't address some of these usages (or would it be a roundabout/inefficient way to get that information). Separately, the fact this has been asked 14 years ago and lots of people want it (in this and related issues), and that there seems to be no significant downside to it is IMO enough. Also, I find it weird that you question (a lot) the need for it now, when it has already been approved a year ago: https://bugs.ruby-lang.org/issues/6012#note-25 And approved again in https://github.com/ruby/ruby/pull/15580#issuecomment-3691058342. The change has been in master for a year, no compatibility concern has been raised, so why be so worried now when it was the same a year ago? ---------------------------------------- Feature #6012: Proc#source_location also return the column https://bugs.ruby-lang.org/issues/6012#change-116015 * 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/
participants (1)
-
Eregon (Benoit Daloze)