From: peter.vandenabeele.be / gmail.com [mailto:peter.vandenabeele.be / gmail.com] On Behalf Of Peter Vandenabeele
Sent: 21 February 2012 10:01
To: ruby-talk ML
Subject: Re: Difference between 1.9.2 and 1.9.3

On Tue, Feb 21, 2012 at 9:40 AM, Bartosz Dziewoski <matma.rex / gmail.com<mailto:matma.rex / gmail.com>> wrote:
That's because super with parentheses passes the same args your method

I assume this was a typo, meaning "without" parentheses.

was called with (like Dave said), and default Object#initialize method
takes no arguments.

But that's interesting. You might want to mention it at Ruby's bug
tracker: bugs.ruby-lang.org<http://bugs.ruby-lang.org> - maybe the default initializer should
take any number of args and just discard them.

I think that is not a good idea. With the current implementation, it
is still possible to add optional arguments later. If a method (e.g.
initialize) would accept any number of arguments and just discard
them, then later on, adding 1 or more optional arguments in the
definition would suddenly cause bugs as these initially discarded
arguments would then interpreted as a real, optional argument.

Just write `super()` when calling the higher up initializer.

HTH,

Peter


Calling super() does fix this trivial example but I also happen to include the module from a class that inherits from another class before Object, so it breaks that. What we need to figure out is how does one write initialize() in a module such that it seamlessly integrates into any inheritance chain in 1.9.3. It doesn¡Çt seem possible (at least without some hacking) in 1.9.3. Maybe it is actually a bug somewhere.

I will probably hack round it with

  def initialize(*args, &block)
    if self.class.superclass === Object
      super()
    else
      super
    end
  end

Is there a better way?