From: Robert Dober Date: 2006-06-23T20:06:31+09:00 Subject: Re: Class#name= ------=_Part_20162_7840398.1151060787710 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 6/23/06, Yukihiro Matsumoto wrote: > > Hi, > > In message "Re: Class#name=3D" > on Fri, 23 Jun 2006 18:12:27 +0900, "Robert Dober" < > robert.dober@gmail.com> writes: > > |irb(main):003:0> A =3D mod > |=3D> A > |irb(main):004:0> mod.name > |=3D> "A" > |most surprising > |irb(main):005:0> B =3D mod > |=3D> A > |irb(main):006:0> mod.name > |=3D> "A" > |even more surprising > |irb(main):007:0> B.name > |=3D> "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. > > matz. > > I really did appreciate your reply, I really really did not want to be too direct or not polite but obviously I did not make myself clear. :( First let us establish what we all three seem to agree to, ty David too. * Two references to the same object will respond identical to an identical message. Agreed? * It is impossible to gurantee expected behavior, I understand that rule as "Ruby will not do something weird unless there is a good reason". * I made one very stupid ???? above because I had already commented on the behavior of the same object. What follows will not ever doubt these principles. If you are still with me (and if you are not please silently and politly ignore that post, I will survive ) the key question is, and please take no offence I will use a wording appropriate to how I feel about it. We have an object x, ok we create it now :) x=3D mod.new oh it has a name method, let us see x.name =3D> "" great, that is a good name. BTW I need a constant reference to that object A =3D x A.name will be "" of course I just assigned another reference to the object= , I am a clever guy, I know that pointing another reference to an object can not possibly change the behavior (please let us be precise here, behavior not sate, state is internal, behavior is what counts to the programmer) A.name =3D=3D x.name =3D> true As I told you, I am sooo great A.name =3D> "A" What??? You must be kidding no way. ok, ok you convinced me I see the reason now, but I am a quick learner let us go on, "A" is even better a name than "", much longer, indefinitely longer, well seems to be a very, very long name ;) B =3D x Of course B.name =3D=3D x.name =3D> true Ha you cannot kill a good man, and of course B.name =3D=3D "B" =3D> false B.name =3D> A What did you do to me?????? I am dead, unless, please, please you explain or change ruby ;) Hopefully I was not too blunt. Cheers Robert --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_20162_7840398.1151060787710--