On Nov 4, 10:59 ¨Âí¬ Ùõëéèéòï Íáôóõíïô¼í®®®Àòõâùìáîç®ïòç¾ ÷òïôåº > Hi, > > In message "Re: Ruby doesn't implement x++ for Fixnum's because ???" > on Wed, 4 Nov 2009 23:31:46 +0900, Marnen Laibow-Koser <mar... / marnen.org> writes: > > |I believe you are quite wrong. ¨Âäåóôòõãôéöæõîãôéïî ìéëå çóõâãá> |be implemented as a method, then I see no reason that +=, |=, or postfix > |++ couldn't be. > > Only if you accept the language that can change the value of 1 to 2. > I don't. > > matz. Hi Matz, Thank you very much for your brilliant and enormous efforts in creating Ruby and offering to the programming world as gift. > Only if you accept the language that can change the value of 1 to 2. I know that you know Ruby extremely well. But I have written the following tests on this issue of whether "1" ever gets changed to "2". I assume you have not looked at my post yesterday on this issue. I'd be honored if you'd look at the following comments and code and point out anything you view as erroneous. BTW, I'm not advocating x++ for Ruby. I'm just trying to understand whether Ruby would literally change 1 to 2 as opposed to change a variable that contains 1 to subsequently contain 2. Best wishes, Richard def show(v) "Got #{v}, class = #{v.class}, object_id = #{v.object_id} (v.object_id-1)/2 = #{(v.object_id-1)/2 }" end class Fixnum def pp # We canÃÕ define ++ because of a compiler restriction. self + 1 end end These lines show that a & b values are stored in their object_ids held in the symbol table. DonÃÕ believe it? Read more. a = 1; show (a) => Got 1; class = Fixnum; object_id = 3; v >>3D 1 b = 1; show (b) => Got 1; class = Fixnum; object_id = 3; v >>3D 1 a == b => true Appending these lines shows that a & b values are distinct. That is, after incrementing, a =2, b is unchanged; b is not impacted by aÃÔ change a += 1; show (a) => Got 2; class = Fixnum; object_id = 5; v >> 1 = 2 show (b) => Got 1; class = Fixnum; object_id = 3; v >> 1 = 1 Appending these lines shows the ++ÃÔ alias pp works just find a=1; show(a.pp) => Got 2; class = Fixnum; object_id = 5; v >>3D 2 show(b) => Got 1; class = Fixnum; object_id = 3; v >> 1 = 1 Appending these lines show that ++ crosses the Fixnum/Bignum boundary a = 2**30-1; show (a) => Got 1073741823; class = Fixnum; object_id = 2147483647; v >> 1 = 1073741823 show(a.pp) => Got 1073741824; class = Bignum; object_id = 22738520; v >> 1 = 11369260 # Å× >> 1is irrelevant, of course.