From: William Djaja Tjokroaminata Date: 2002-11-27T02:27:07+09:00 Subject: Re: Things That Newcomers to Ruby Should Know (11/24/02) Jason Persampieri wrote: > OK... I get it... I understood your argument (although > ya cleared up a few other things), but I still just > didn't GET why you couldn't do a '++' method that > simply did something like 'self = self.succ' Hi Jason, Let me try to clear things up. *Theoretically*, it is not impossible to be able to write in some non-standard Ruby x = 5 y = 5 x.succ! # -> x == 6, y == 5 in which case x and y actually have different id's. This can be accomplised if *all* objects/variables had simply been implemented as VALUE which is a pointer. I think this is done in some other languages such as Tcl and Python. However, *practically* we cannot do it in the current Ruby C implementation, because [Fixnum, Symbol, true, false, nil] have been implemented as VALUE which is an immediate object. (Each object is a "singleton" if you want to call it that way.) I guess Matz created the "immediate objects" for efficiency reason, but this has the consequence of the impossibility to have x.succ! if x is a Fixnum. Ruby is not 100% efficiency (something like C) and neither 100% consitency (something like Smalltalk). I think it is really a careful balance between the two. Regarding assignments of type 'self = something', you cannot do it in Ruby, but for objects which are not immediate, at least in theory you can do it if you use the Ruby C API's. Regards, Bill P.S. I don't know what happens in the Java implementation of Ruby (JRuby), whether it distinguishes between VALUE as pointer and as immediate object, as Java does not have pointers in the C sense.