[ruby-core:32946] Re: Behavior of initialize in 1.9

From: Ryan Davis <ryand-ruby@...>
Date: 2010-10-28 19:25:56 UTC
List: ruby-core #32946
On Oct 28, 2010, at 08:15 , Run Paint Run Run wrote:

> On Thu, Oct 28, 2010 at 12:12 PM, Aaron Patterson
> <aaron@tenderlovemaking.com> wrote:
>> The behavior of initialize in 1.9 seems to have changed.  Here is an irb
>> sample from 1.8 and 1.9 to illustrate the difference:
> [deletia]
>> Is this change intentional?  If so, why?  If you're testing first during
>> development, this behavior seems surprising to me.
> 
> I believe this is caused by r26135:
> http://redmine.ruby-lang.org/issues/show/2451 .

This seems bad to me. YES, there is a downside: you lose the expected argument checking you normally get.

class X
  def y
  end
end

why is:

  X.new(42)

OK to do, but not:

  X.new.y(42)

?

We have argument checking for a reason, we shouldn't throw it on the floor. If you want to loosen it, then monkeypatch BasicObject#initialize. That's what monkeypatching is for. But the current semantics don't make any sense to me.

I think 2451 should be rolled out.


In This Thread