On Mon, 08 Mar 2004 12:58:45 +0900, Yukihiro Matsumoto wrote: > on 04/03/08, Simon Strandgaard <neoneye / adslhome.dk> writes: > |> 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. > > You didn't explain why you need "extended" for singleton class > definition. Why don't you use extend for your purpose, before > changing the language? I don't have a serious need for 'class<<obj'. I have recently initiated working on a book about testing, with a few chapters about Ruby. My first attempt of making an good example of how to use the 'class<<obj', I discovered that no init method got invoked. Thus I got curious to if that was a missing feature. My initial thought were first to describe 'obj.extend(Mod)' and next describe 'class<<obj' as being similar, but this isn't true. So its probably better to describe them in separate. > |> 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.. > > I want you to take a break and learn about Ruby before claiming apples > and oranges are similar. Yes, they are. But not the same. Besides > that, singleton class definition is a kind of class re-opening, so > that they should remain same. Ok, I am learning every day ;-) > Class re-opening is a class definition whose target is an existing > class, for example: > > class String > def foo # String#foo become available > end > end > > there's no hook for class re-opening. > I wasn't sure about what kind of reopening you talked about in last mail. Yes, I have used this a few times. However I am only interested in modifying a specific instance with 'class<<obj'. Sorry for todays noise. ;-) -- Simon Strandgaard