[#11439] comments needed for Random class — "NAKAMURA, Hiroshi" <nakahiro@...>

-----BEGIN PGP SIGNED MESSAGE-----

15 messages 2007/06/12

[#11450] Re: new method dispatch rule (matz' proposal) — David Flanagan <david@...>

This is a late response to the very long thread that started back in

17 messages 2007/06/13

[#11482] Ruby Changes Its Mind About Non-Word Characters — James Edward Gray II <james@...>

Does this look like a bug to anyone else?

10 messages 2007/06/16

[#11505] Question about the patchlevel release cycle — Sylvain Joyeux <sylvain.joyeux@...4x.org>

1.8.6 thread support was broken in bad ways. It stayed for three months

20 messages 2007/06/20
[#11512] Re: Question about the patchlevel release cycle — Urabe Shyouhei <shyouhei@...> 2007/06/20

Hi, I'm the 1.8.6 branch manager.

[#11543] Re: Apple reportedly to ship with ruby 1.8.6-p36 unless informed what to patch — James Edward Gray II <james@...>

On Jun 27, 2007, at 4:47 PM, Bill Kelly wrote:

10 messages 2007/06/27

Re: new method dispatch rule (matz' proposal)

From: Alex Young <alex@...>
Date: 2007-06-14 07:18:03 UTC
List: ruby-core #11456
Daniel DeLorme wrote:
> David Flanagan wrote:
>> In Ruby 1.8, we can write code like this:
>>
>> class Test
>>   def initialize(greeting)
>>     @greeting = greeting
>>     @greeter = lambda { |x| puts "#@greeting #{x}" }
>>   end
>>
>>   def greet(x)
>>     @greeter[x]
>>   end
>> end
>>
>> t = Test.new("hello")
>> t.greet("world")
>>
>> In this code, the instance variable @greeter refers to a local 
>> function that is completely hidden from subclasses and cannot be altered.
> 
> class Test2 < Test; end
> t2 = Test2.new("hello")
> t2.greet("world") #=> "hello world"
> 
> How is this hidden from subclasses? Or did I miss something?
> 
> But this touches on an idea I was thinking about recently... how about 
> giving a warning when a subclasses overrides a method and doesn't use 
> "super"? IMHO in 99% of cases if you override a method you should call 
> super. In the other 1% of cases you could use an idiom like "super if 
> false" which makes it very clear when reading the code that we are 
> (dangerously) skipping the normal inheritance chain. It solves the same 
> problem as the new method dispatch rule but for *both* public and 
> private methods, while still leaving the programmer freedom to override 
> private methods if he knows what he's doing. Comments?
That ends up looking a lot like a magical side-effect to me.  Besides, I 
don't think the assumption (that you should often be calling super) 
necessarily valid.

What it sounds to me like you're pining for is the "override" keyword 
from C#.  I guess an equivalent implementation in Ruby might be for 
methods defined with "def" to pop a warning when they redefine a 
superclass method, and to introduce a "redef" keyword to do specifically 
that.

Not sure I like the look of it (introducing new keywords, bad), but I 
think it would fit the bill here.

-- 
Alex

In This Thread