From: Michael Neumann Date: 2001-07-10T17:02:46+09:00 Subject: [ruby-talk:17600] Re: Constants and Variables On Tue, Jul 10, 2001 at 04:12:23PM +0900, HarryO wrote: > Thanks to Hal and Dave for clearing that up. > > However, this makes me feel even more like the concept of "constant" > doesn't really mean anything and that numbers aren't first-class objects. Matz once called Ruby's constants "Shared Variables", IIRC, which is probably a more correct term for it. That is they contain objects, which are shared between multiple pieces of code, but in contrast to global varibales, without reassigning them to another object. Correct me if I am wrong. There are two types of integers: Fixnums (< 31 bit) and Bignums. Fixnums are not objects that reside in garbage collected memory. In Ruby every object is internally represented by a VALUE (which is a C ulong), which first byte (bits?) is reserved for the type of the object. Fixnum is special here, in that if the first bit of a VALUE is set (or unset?) the rest of it is the Fixnum value. Other objects than Fixnum (and true/false/nil ?) are stored in memory. Because Fixnum's do not really exist in memory, you cannot change their value. But look at Perl, Python or Smalltalk, they work the same way, or is there for every number an object in memory? Numbers are first class objects. But they are passed by value not by reference. Regards, Michael -- Michael Neumann *** eMail uu9r@rz.uni-karlsruhe.de