From: Eric Mahurin Date: 2005-10-31T10:31:30+09:00 Subject: Re: characters (and small strings) in ruby 2.0 ------=_Part_14144_4840656.1130722287113 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 10/30/05, TRANS wrote: > > Symbols? > > I don't think it is a good idea to overload the Symbol API to also represen= t characters. If you do that then you start running into the same problem wit= h representing a character as a Fixnum (or even Bignum for bigger characters) - is it a character or an Integer? I think matz wants characters to have th= e same API as strings. But the question is: Is it OK if they are immutable an= d have a different class? I just looked at ruby.h a little. Here are the encodings I found for immediate objects: byte 3 2 1 0 Fixnum: VV VV VV vvvvvvv1 Symbol: VV VV VV 00001110 false: 00 00 00 00000000 true: 00 00 00 00000010 nil: 00 00 00 00000100 undef: 00 00 00 00000110 non-immediate: VV VV VV vvvvvv00 - excluding false/nil cases On a 32-bit machine, it looks like you could support 2^30 (lower bits=3D10)= - 2^24 (Symbols) - 2 (true/undef) more immediate objects. Plenty of room for 0-3 byte immutable strings/characters. On a 64-bit machine, you should be able to do 0-7 bytes. ------=_Part_14144_4840656.1130722287113--