"Glenn Parker" <glenn.parker / comcast.net> schrieb im Newsbeitrag
news:41C03A4D.90503 / comcast.net...
> Robert Klemme wrote:
> >
> > module Foo
> >   def initialize
> >     @bar = 0
> >   end
> > end
> >
> > becomes
> >
> > module Foo
> >   def initialize(*a,&b)
> >     super
> >     @bar = 0
> >   end
> > end
> >
> > Pro: this change allows for easy initialization of instance variables
> > needed by modules even if there are multiple modules included:
> >
> > What do others think?
>
> What happens when somebody naively updates the first version of module
> Foo from above as follows?
>
> module Foo
>    def initialize(default = 0)
>      @bar = default
>    end
> end
>
> It might seem like a safe enough change, but it wouldn't be.

Good point.

> I think you can't change the meaning of "initialize" that drastically,
> but you could define a new "super_initialize" if it was really
important.

What would that do?  The aim was to have a method that does initialization
but does not disturb the calling chain of initialize.  Maybe it would be
better to have a new method (initialize_locally or whatever) that does not
call super and is called individually, i.e. for each class in the chain of
ancestors.

Kind regards

    robert