From: transfire@... Date: 2006-06-23T20:47:24+09:00 Subject: Re: Class#name= Yukihiro Matsumoto wrote: > Hi, > > In message "Re: Class#name=" > on Fri, 23 Jun 2006 18:12:27 +0900, "Robert Dober" writes: > > |irb(main):003:0> A = mod > |=> A > |irb(main):004:0> mod.name > |=> "A" > |most surprising > |irb(main):005:0> B = mod > |=> A > |irb(main):006:0> mod.name > |=> "A" > |even more surprising > |irb(main):007:0> B.name > |=> "A" > |?????? > |irb(main):008:0> > | > |Well this kind of shocks me, is there an idea behind this which I am > |missing? > > The module referenced from A and B are the same object (mod). If same > module reports different name depends on how it is called, I would > surprise VERY MUCH. For your note, Ruby does not promise that you > don't surprise. It's just impossible. It tries its best to do > reasonable job as much as it can. Hmm.... This occured to me: cut Bc < B def name; 'B'; end end B.name #=> B A.name #=> A I'm not saying this is how it works or should work neccessarily, it just makes me realize that it might possible b/c the cut is a separate object. OTOH, one wonders if maybe module#name isn't such a good thing. Considering my own use of the method, I think in every case I have been dissatisfied with the solution and eventually removed it. T.