On Nov 4, 9:37 ¨Βν¬ ΣεεβΌυσεξετ­ξοσ®®®ΐσεεβσ®ξετχςοτεΊ
> On 2009-11-04, Marnen Laibow-Koser <mar... / marnen.org> wrote:
>
> > I believe you are quite wrong.  ¨Βδεστςυγτιφζυξγτιοξ μιλε ησυβγα> > be implemented as a method, then I see no reason that +=, |=, or postfix
> > ++ couldn't be.
>
> gsub! is implemented as a method on objects which contain data. + would
> have to be implemented as a method on objects which ARE their data -- which
> have no distinction between the object and its "contents".
>
> gsub! can work because somewhere inside the object there is a hunk of storage
> which is separate from the object itself.  ¨Βιψξυθαξο συγθ στοςαητο
> refer to.
>
> -s
> --
> Copyright 2009, all wrongs reversed.  ¨Βετες Σεεβαγυσεξετ­ξοσ®®®ΐσεεβσ®ξετθττπΊ――χχχ®σεεβσ®ξετ―μοη―Ό­μαχσυιτσςεμιηιοξαξζυξξπιγτυςεσθττπΊ――εξ®χιλιπεδια®οςη―χιλι―ΖαιςίΗανεί¨Σγιεξτομοηω© Ό­ηεεδυγατεδ

> ++ would have to be implemented as a method on objects which ARE their data

Not true. Check out the following, step by step:

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 there 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.

Do you agree?

Best wishes,
Richard