Gavin Kistner wrote:
> On Jul 13, 2005, at 6:52 AM, Sylvain Joyeux wrote:
>>> module Foo
>>>    attr_reader :foo
>>>    def initialize( *args )
>>>      super
>>>      @foo = 'foo'
>>>    end
>>> end
>>>
>> I think that what you want is
>>     super(*args)
>
> Calling super without any parentheses is a special case where it
> passing along the argument list to the current function automatically.

Answering your earlier question: I'd do

module X
  def initialize(*a,&b)
    ...
    super
  end
end

The problem with this (and you see it in your example) is that the super
class initialize does not take any arguments.  So you should rather have
done:

class Bar2
   include Foo
   def initialize( bar_value )
     super()
     @bar = bar_value
   end
end

(Explicitely use an empty arg list on super)

The whole issue is so complicated (because of dynamism, because of all
possible combinations of initialize with and without arguments and with
and without block...) that sometimes I think the mechanism should be
changed for modules.  For example by allowing only initialize(*a,&b) in
modules (or redifining it to this) to avoid breaking the inheritance
initialization chain.  Another option is to completely forbit initialize
in modules (which I don't like because there are cases where you rather
want it).  etc.

Kind regards

    robert