From: Florian Gross Date: 2005-01-11T01:56:20+09:00 Subject: Re: Immediate values Eustaquio Rangel de Oliveira Jr. wrote: > Forgive me if I misunderstood, but so VALUEs are variables? > > a = 1 > > a is the VALUE, with 32 bit length? a is mapped to a VALUE. VALUEs are pointers to Ruby Object Structs. Immediate objects are not represented by any Ruby Object Struct -- they are identified directly by the pointer's destination. If Ruby sees such a special pointer it does not need to resolve it. Because there is no actual Ruby Object Struct there are no flags (which means you can't (un)taint them), no instance variables and no singleton classes for immediate values. (false, true and nil act as if FalseClass, TrueClass and NilClass were their meta classes.) Floats and Bignums are not actually immediate values, but they are immutable and act as if they were immediate by default in some other contexts. (You can't define singleton methods on them because they use a custom singleton_method_added callback that raises an exception. It's implemented by Numeric#singleton_method_added.) false, nil and true and the special undef value that is not visible anywhere in Ruby are represented by VALUEs of 0, 2, 4 and 6. Fixnums are represented by VALUEs with bit 0 set to 1. This means that there can be up to 2147483648 possible values (-1073741824 .. 1073741823) on 32 bit and up to 9223372036854775808 possible values (-4611686018427387904 .. 4611686018427387903) on 64 bit systems. Symbols are represented by VALUEs with bit 0 to 7 set to 01110000. This means that there can be up to 16777216 different Symbols on 32 bit and up to 72057594037927936 different Symbols on 64 bit systems. If I'm wrong with any of those please correct me. It would also be interesting if somebody could find out what values VALUEs that are not immediate Objects can have.