On Mon, 08 Mar 2004 11:18:42 +0900, Yukihiro Matsumoto wrote:
> In message "Re: proposal:  class<<obj to invoke extend_object"
>     on 04/03/08, Simon Strandgaard <neoneye / adslhome.dk> writes:
> 
> |Still... I propose that 'class<<self' should invoke #extended or some sort
> |of suitable replacement, so that initialization can take place.
> |What do you think ?
> |
> |Should it be named #extended ?  or  have another name?
> 
> Describe yourself deeper.  What exactly is your proposal? 

When 'class<<obj' is seen by Ruby, then an init method should be invoked.
I propose to reuse #extend_object and #extended for this.


> And why do you think it's needed?

Its difficult to add an new instance variable to obj.
Its inflexible compared to obj.extend(Mod), because there isn't
invoked an #extend_object method when the extension occurs.

An alternative to what I propose may be to do something 
ala (warning pseudo code).. which isn't intuitive..

class << obj
  def singleton_method_added(parent)
    if first time we got invoked
      @str = "hello"
    end
  end
end


> Remember, since singleton class always exists for each object
> (virtually), 'class <<obj' is rather corresponds to class re-opening.
>

I am only little familiar with class re-opening..

--
Simon Strandgaard