ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:67745] [ruby-trunk - Feature #10771] [Open] An easy way to get the source location of a constant
       [not found] <redmine.issue-10771.20150122055018@ruby-lang.org>
@ 2015-01-22  5:50 ` sawadatsuyoshi
  2015-01-27 11:04 ` [ruby-core:67833] [ruby-trunk - Feature #10771] " ko1
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: sawadatsuyoshi @ 2015-01-22  5:50 UTC (permalink / raw
  To: ruby-core

Issue #10771 has been reported by Tsuyoshi Sawada.

----------------------------------------
Feature #10771: An easy way to get the source location of a constant
https://bugs.ruby-lang.org/issues/10771

* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
For constants, it is difficult to get the source location where it was (last) defined. I request either of the following to be implemented:

* Tracepoint emits a signal when a constant is defined.
* Implement a `Constant` class (similar to `Method` class) and a `constant` method (similar to `method` method) that behave as follows:

        foo1.rb
        1| module Foo
        2|   Bar = :bar
        3| end
        4| Foo.constant(:Bar) #=> #<Constant: Foo#Bar>
        5| Foo.constant(:Bar).source_location #=> ["foo1.rb", 2]

* Implement `Module#constant_source_location`

        foo2.rb
        1| module Foo
        2|   Bar = :bar
        3| end
        4| Foo.constant_source_location(:Bar) #=> ["foo2.rb", 2]






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

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

* [ruby-core:67833] [ruby-trunk - Feature #10771] An easy way to get the source location of a constant
       [not found] <redmine.issue-10771.20150122055018@ruby-lang.org>
  2015-01-22  5:50 ` [ruby-core:67745] [ruby-trunk - Feature #10771] [Open] An easy way to get the source location of a constant sawadatsuyoshi
@ 2015-01-27 11:04 ` ko1
  2017-06-25  9:08 ` [ruby-core:81765] [Ruby trunk Feature#10771] " jeremy.phelps
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: ko1 @ 2015-01-27 11:04 UTC (permalink / raw
  To: ruby-core

Issue #10771 has been updated by Koichi Sasada.

Assignee set to Yukihiro Matsumoto

Matz issue.


----------------------------------------
Feature #10771: An easy way to get the source location of a constant
https://bugs.ruby-lang.org/issues/10771#change-51241

* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
----------------------------------------
For constants, it is difficult to get the source location where it was (last) defined. I request either of the following to be implemented:

* Tracepoint emits a signal when a constant is defined.
* Implement a `Constant` class (similar to `Method` class) and a `constant` method (similar to `method` method) that behave as follows:

        foo1.rb
        1| module Foo
        2|   Bar = :bar
        3| end
        4| Foo.constant(:Bar) #=> #<Constant: Foo#Bar>
        5| Foo.constant(:Bar).source_location #=> ["foo1.rb", 2]

* Implement `Module#constant_source_location`

        foo2.rb
        1| module Foo
        2|   Bar = :bar
        3| end
        4| Foo.constant_source_location(:Bar) #=> ["foo2.rb", 2]






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

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

* [ruby-core:81765] [Ruby trunk Feature#10771] An easy way to get the source location of a constant
       [not found] <redmine.issue-10771.20150122055018@ruby-lang.org>
  2015-01-22  5:50 ` [ruby-core:67745] [ruby-trunk - Feature #10771] [Open] An easy way to get the source location of a constant sawadatsuyoshi
  2015-01-27 11:04 ` [ruby-core:67833] [ruby-trunk - Feature #10771] " ko1
@ 2017-06-25  9:08 ` jeremy.phelps
  2017-06-25  9:59   ` [ruby-core:81766] " Eric Wong
  2017-06-26  1:34 ` [ruby-core:81768] " jeremy.phelps
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 10+ messages in thread
From: jeremy.phelps @ 2017-06-25  9:08 UTC (permalink / raw
  To: ruby-core

Issue #10771 has been updated by jphelps (Jeremy Phelps).


I've got a patch ready for this, but I have no idea how to submit it. There are serious contradictions in this page:

https://bugs.ruby-lang.org/projects/ruby/wiki/HowToContribute

It says that the changes should be against "the trunk of Ruby", and that "only Ruby 2.4 may accept new features." But the trunk on GitHub is Ruby 2.5.

It says that the patch should be a unified diff, but it also says different changes should not be mixed in a single commit. But diff files don't have commits; only pull requests and whole repos do. But it says that you only accept PRs for "tiny fixes", and only if they don't require discussion.


----------------------------------------
Feature #10771: An easy way to get the source location of a constant
https://bugs.ruby-lang.org/issues/10771#change-65462

* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
For constants, it is difficult to get the source location where it was (last) defined. I request either of the following to be implemented:

* Tracepoint emits a signal when a constant is defined.
* Implement a `Constant` class (similar to `Method` class) and a `constant` method (similar to `method` method) that behave as follows:

        foo1.rb
        1| module Foo
        2|   Bar = :bar
        3| end
        4| Foo.constant(:Bar) #=> #<Constant: Foo#Bar>
        5| Foo.constant(:Bar).source_location #=> ["foo1.rb", 2]

* Implement `Module#constant_source_location`

        foo2.rb
        1| module Foo
        2|   Bar = :bar
        3| end
        4| Foo.constant_source_location(:Bar) #=> ["foo2.rb", 2]






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

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

* [ruby-core:81766] Re: [Ruby trunk Feature#10771] An easy way to get the source location of a constant
  2017-06-25  9:08 ` [ruby-core:81765] [Ruby trunk Feature#10771] " jeremy.phelps
@ 2017-06-25  9:59   ` Eric Wong
  0 siblings, 0 replies; 10+ messages in thread
From: Eric Wong @ 2017-06-25  9:59 UTC (permalink / raw
  To: ruby-core

jeremy.phelps@instacart.com wrote:
> I've got a patch ready for this, but I have no idea how to
> submit it. There are serious contradictions in this page:
>
> https://bugs.ruby-lang.org/projects/ruby/wiki/HowToContribute
>
> It says that the changes should be against "the trunk of
> Ruby", and that "only Ruby 2.4 may accept new features." But
> the trunk on GitHub is Ruby 2.5.

Make the change against trunk, any mentions of specific version
numbers is probably outdated.  Maybe you have permissions to edit
that page?  (I can't stand <form> inputs in web browsers and
reply to redmine via email)

> It says that the patch should be a unified diff, but it also
> says different changes should not be mixed in a single commit.
> But diff files don't have commits; only pull requests and
> whole repos do. But it says that you only accept PRs for "tiny
> fixes", and only if they don't require discussion.

The output of "git format-patch" is a superset of unified diff,
you should use that to generate diffs if using git.  "git am"
can be used to apply that output and preserve authorship info
and the commit message.

You can also publish your work to any publically accessible git
repository tell us about how to pull it, here.  The
"git request-pull" command can generate the message text for you.

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

* [ruby-core:81768] [Ruby trunk Feature#10771] An easy way to get the source location of a constant
       [not found] <redmine.issue-10771.20150122055018@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2017-06-25  9:08 ` [ruby-core:81765] [Ruby trunk Feature#10771] " jeremy.phelps
@ 2017-06-26  1:34 ` jeremy.phelps
  2017-06-26  2:45   ` [ruby-core:81770] " Eric Wong
  2017-06-26  3:59 ` [ruby-core:81771] " duerst
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 10+ messages in thread
From: jeremy.phelps @ 2017-06-26  1:34 UTC (permalink / raw
  To: ruby-core

Issue #10771 has been updated by jphelps (Jeremy Phelps).

File const_source_location.tar.gz added

Ok, then here's my patch. I called the method "const_source_location" instead of "constant_source_location", because it uses a lot of the same code as "const_get".

I don't have access to edit the wiki page.


----------------------------------------
Feature #10771: An easy way to get the source location of a constant
https://bugs.ruby-lang.org/issues/10771#change-65465

* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
For constants, it is difficult to get the source location where it was (last) defined. I request either of the following to be implemented:

* Tracepoint emits a signal when a constant is defined.
* Implement a `Constant` class (similar to `Method` class) and a `constant` method (similar to `method` method) that behave as follows:

        foo1.rb
        1| module Foo
        2|   Bar = :bar
        3| end
        4| Foo.constant(:Bar) #=> #<Constant: Foo#Bar>
        5| Foo.constant(:Bar).source_location #=> ["foo1.rb", 2]

* Implement `Module#constant_source_location`

        foo2.rb
        1| module Foo
        2|   Bar = :bar
        3| end
        4| Foo.constant_source_location(:Bar) #=> ["foo2.rb", 2]




---Files--------------------------------
const_source_location.tar.gz (1.96 KB)


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

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

* [ruby-core:81770] Re: [Ruby trunk Feature#10771] An easy way to get the source location of a constant
  2017-06-26  1:34 ` [ruby-core:81768] " jeremy.phelps
@ 2017-06-26  2:45   ` Eric Wong
  0 siblings, 0 replies; 10+ messages in thread
From: Eric Wong @ 2017-06-26  2:45 UTC (permalink / raw
  To: ruby-core

jeremy.phelps@instacart.com wrote:
> Ok, then here's my patch. I called the method
> "const_source_location" instead of "constant_source_location",
> because it uses a lot of the same code as "const_get".

Thanks. The code looks fine.
I'd suggest rb_ary_new_from_args to avoid the temporary array
(instead of rb_ary_new4) but we can fix it at commit time.

It's up to matz now to approve/deny the feature itself.

Thanks again

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

* [ruby-core:81771] [Ruby trunk Feature#10771] An easy way to get the source location of a constant
       [not found] <redmine.issue-10771.20150122055018@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2017-06-26  1:34 ` [ruby-core:81768] " jeremy.phelps
@ 2017-06-26  3:59 ` duerst
  2018-11-28 13:13 ` [ruby-core:90120] " shevegen
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: duerst @ 2017-06-26  3:59 UTC (permalink / raw
  To: ruby-core

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


jphelps (Jeremy Phelps) wrote:
> I've got a patch ready for this, but I have no idea how to submit it. There are serious contradictions in this page:
> 
> https://bugs.ruby-lang.org/projects/ruby/wiki/HowToContribute

I updated this page a bit, hopefully removing the contradictions. Please tell us if there still are some problems.

----------------------------------------
Feature #10771: An easy way to get the source location of a constant
https://bugs.ruby-lang.org/issues/10771#change-65468

* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
For constants, it is difficult to get the source location where it was (last) defined. I request either of the following to be implemented:

* Tracepoint emits a signal when a constant is defined.
* Implement a `Constant` class (similar to `Method` class) and a `constant` method (similar to `method` method) that behave as follows:

        foo1.rb
        1| module Foo
        2|   Bar = :bar
        3| end
        4| Foo.constant(:Bar) #=> #<Constant: Foo#Bar>
        5| Foo.constant(:Bar).source_location #=> ["foo1.rb", 2]

* Implement `Module#constant_source_location`

        foo2.rb
        1| module Foo
        2|   Bar = :bar
        3| end
        4| Foo.constant_source_location(:Bar) #=> ["foo2.rb", 2]




---Files--------------------------------
const_source_location.tar.gz (1.96 KB)


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

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

* [ruby-core:90120] [Ruby trunk Feature#10771] An easy way to get the source location of a constant
       [not found] <redmine.issue-10771.20150122055018@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2017-06-26  3:59 ` [ruby-core:81771] " duerst
@ 2018-11-28 13:13 ` shevegen
  2018-11-29  0:26 ` [ruby-core:90143] " sawadatsuyoshi
  2018-12-12  6:59 ` [ruby-core:90441] " matz
  7 siblings, 0 replies; 10+ messages in thread
From: shevegen @ 2018-11-28 13:13 UTC (permalink / raw
  To: ruby-core

Issue #10771 has been updated by shevegen (Robert A. Heiler).


janfri suggested this issue for the next upcoming developer meeting
at December 2018 so I think it will be approved or rejected then.

I did not yet comment on it so I will comment on it briefly.

- I think the functionality would be nice to have; introspection 
is very useful, IMO.

Not sure how matz feels about the API suggested but the functionality
may be ok?

----------------------------------------
Feature #10771: An easy way to get the source location of a constant
https://bugs.ruby-lang.org/issues/10771#change-75242

* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
For constants, it is difficult to get the source location where it was (last) defined. I request either of the following to be implemented:

* Tracepoint emits a signal when a constant is defined.
* Implement a `Constant` class (similar to `Method` class) and a `constant` method (similar to `method` method) that behave as follows:

        foo1.rb
        1| module Foo
        2|   Bar = :bar
        3| end
        4| Foo.constant(:Bar) #=> #<Constant: Foo#Bar>
        5| Foo.constant(:Bar).source_location #=> ["foo1.rb", 2]

* Implement `Module#constant_source_location`

        foo2.rb
        1| module Foo
        2|   Bar = :bar
        3| end
        4| Foo.constant_source_location(:Bar) #=> ["foo2.rb", 2]




---Files--------------------------------
const_source_location.tar.gz (1.96 KB)


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

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

* [ruby-core:90143] [Ruby trunk Feature#10771] An easy way to get the source location of a constant
       [not found] <redmine.issue-10771.20150122055018@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2018-11-28 13:13 ` [ruby-core:90120] " shevegen
@ 2018-11-29  0:26 ` sawadatsuyoshi
  2018-12-12  6:59 ` [ruby-core:90441] " matz
  7 siblings, 0 replies; 10+ messages in thread
From: sawadatsuyoshi @ 2018-11-29  0:26 UTC (permalink / raw
  To: ruby-core

Issue #10771 has been updated by sawa (Tsuyoshi Sawada).


I am glad that this issue is going to be discussed in the next developer meeting, but now that we have a way to know not only the file name and the line number but the column number/position as well for method definitions, I request that this be done for constants as well.

----------------------------------------
Feature #10771: An easy way to get the source location of a constant
https://bugs.ruby-lang.org/issues/10771#change-75259

* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
For constants, it is difficult to get the source location where it was (last) defined. I request either of the following to be implemented:

* Tracepoint emits a signal when a constant is defined.
* Implement a `Constant` class (similar to `Method` class) and a `constant` method (similar to `method` method) that behave as follows:

        foo1.rb
        1| module Foo
        2|   Bar = :bar
        3| end
        4| Foo.constant(:Bar) #=> #<Constant: Foo#Bar>
        5| Foo.constant(:Bar).source_location #=> ["foo1.rb", 2]

* Implement `Module#constant_source_location`

        foo2.rb
        1| module Foo
        2|   Bar = :bar
        3| end
        4| Foo.constant_source_location(:Bar) #=> ["foo2.rb", 2]




---Files--------------------------------
const_source_location.tar.gz (1.96 KB)


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

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

* [ruby-core:90441] [Ruby trunk Feature#10771] An easy way to get the source location of a constant
       [not found] <redmine.issue-10771.20150122055018@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2018-11-29  0:26 ` [ruby-core:90143] " sawadatsuyoshi
@ 2018-12-12  6:59 ` matz
  7 siblings, 0 replies; 10+ messages in thread
From: matz @ 2018-12-12  6:59 UTC (permalink / raw
  To: ruby-core

Issue #10771 has been updated by matz (Yukihiro Matsumoto).


We picked `constant_source_location`. We will experiment with this method in 2.7 development.

Matz.


----------------------------------------
Feature #10771: An easy way to get the source location of a constant
https://bugs.ruby-lang.org/issues/10771#change-75599

* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
For constants, it is difficult to get the source location where it was (last) defined. I request either of the following to be implemented:

* Tracepoint emits a signal when a constant is defined.
* Implement a `Constant` class (similar to `Method` class) and a `constant` method (similar to `method` method) that behave as follows:

        foo1.rb
        1| module Foo
        2|   Bar = :bar
        3| end
        4| Foo.constant(:Bar) #=> #<Constant: Foo#Bar>
        5| Foo.constant(:Bar).source_location #=> ["foo1.rb", 2]

* Implement `Module#constant_source_location`

        foo2.rb
        1| module Foo
        2|   Bar = :bar
        3| end
        4| Foo.constant_source_location(:Bar) #=> ["foo2.rb", 2]




---Files--------------------------------
const_source_location.tar.gz (1.96 KB)


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

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

end of thread, other threads:[~2018-12-12  6:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-10771.20150122055018@ruby-lang.org>
2015-01-22  5:50 ` [ruby-core:67745] [ruby-trunk - Feature #10771] [Open] An easy way to get the source location of a constant sawadatsuyoshi
2015-01-27 11:04 ` [ruby-core:67833] [ruby-trunk - Feature #10771] " ko1
2017-06-25  9:08 ` [ruby-core:81765] [Ruby trunk Feature#10771] " jeremy.phelps
2017-06-25  9:59   ` [ruby-core:81766] " Eric Wong
2017-06-26  1:34 ` [ruby-core:81768] " jeremy.phelps
2017-06-26  2:45   ` [ruby-core:81770] " Eric Wong
2017-06-26  3:59 ` [ruby-core:81771] " duerst
2018-11-28 13:13 ` [ruby-core:90120] " shevegen
2018-11-29  0:26 ` [ruby-core:90143] " sawadatsuyoshi
2018-12-12  6:59 ` [ruby-core:90441] " matz

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