[#68137] improve semantics of manpages — "Anthony J. Bentley" <anthony@...>
Hi,
1 message
2015/02/17
[#68144] Re: Future of test suites for Ruby — Anthony Crumley <anthony.crumley@...>
FYI...
4 messages
2015/02/17
[#68343] [Ruby trunk - Bug #10916] [Open] What the Ruby? SegFault? — ruby@...
Issue #10916 has been reported by why do i need this acct just to create a bug report.
5 messages
2015/02/27
[#68373] Re: [Ruby trunk - Bug #10916] [Open] What the Ruby? SegFault?
— "Martin J. Dürst" <duerst@...>
2015/03/02
> * Author: why do i need this acct just to create a bug report
[#68358] [Ruby trunk - Bug #10902] require("enumerator") scans LOAD_PATH 2x on every invocation — [email protected]
Issue #10902 has been updated by Aman Gupta.
3 messages
2015/02/28
[ruby-core:68079] [Ruby trunk - Feature #9781] Feature Proposal: Method#super_method
From:
eregontp@...
Date:
2015-02-10 13:38:32 UTC
List:
ruby-core #68079
Issue #9781 has been updated by Benoit Daloze.
Marc-Andre Lafortune wrote:
> I must be tired.
>
> Nobu: Sorry, I was confused, there's no problem with `UnboundMethod#super_method` because we retain which class this method was accessed from.
>
> Ryan: That's actually a good example, there is no api to get the "original owner" of an unbound method, so in general it's not possible to implement `super_method` in Ruby. E.g. from `Hash.instance_method(:map)`, I don't know of a way to get back `Hash` in pure Ruby, and thus no way to go through Hash's ancestry chain.
Actually there is a caveat with an UnboundMethod created with Module#instance_method, from a module (and not a class), as it has no idea what is the actual super method (as that can change in different ancestry chains).
Instead it will just return a method if there is a module "M" included in the former module with a corresponding method, and that method might be somewhere in the ancestry of an object including M or not (if "M" was included after).
----------------------------------------
Feature #9781: Feature Proposal: Method#super_method
https://bugs.ruby-lang.org/issues/9781#change-51463
* Author: Richard Schneeman
* Status: Closed
* Priority: Normal
* Assignee: okkez _
----------------------------------------
When `super` is called in a method the Ruby VM knows how to find the next ancestor that has that method and call it. It is difficult to do this manually, so I propose we expose this information in Method#super_location.
Ruby Method class (http://www.ruby-doc.org/core-2.1.1/Method.html) is returned by calling Object.method and passing in a method name (http://www.ruby-doc.org/core-2.1.1/Object.html#method-i-method). This is useful for debugging:
```ruby
# /tmp/code.rb
class Foo
def bar
end
end
puts Foo.new.method(:bar).source_location
# => ["/tmp/code.rb", 3]
```
The Object#method allows a ruby developer to easily track the source location of the method and makes debugging very easy. However if the code is being invoked by a call to `super` it is difficult to track down:
```ruby
# /tmp/code.rb
class BigFoo
def bar
end
end
class Foo < BigFoo
def bar
super
end
end
```
In this code sample it is easy to find the method definition inside of Foo but it is very difficult in large projects to find what code exactly `super` is calling. This simple example is easy, but it can be hard when there are many ancestors. Currently if I wanted to find this we can inspect ancestors
```ruby
Foo.ancestors[1..-1].map do |ancestor|
next unless ancestor.method_defined?(:bar)
ancestor.instance_method(:bar)
end.compact.first.source_location
```
To make this process simpler I am proposing a method on the Method class that would return the result of `super`
It could be called like this:
```ruby
Foo.new.method(:bar).super_method
```
I believe adding Method#super_method, or exposing this same information somewhere else, could greatly help developers to debug large systems easily.
--
https://bugs.ruby-lang.org/