From: Mystifier Date: 2005-01-15T00:04:39+09:00 Subject: Re: Mutable strings Dear Austin, Immutability as I understand is preserving state of the Object. State of Object are instance variables in Ruby. My example does sot change class variables, but the instance variable. Symbol class being immutable or not is besides the point. I am talking about symbol instance, and ability to change symbol instance variables makes them not immutable as such. Yes, the sequence of chars they represent are immutable. Hence, I get an impression that the Symbol is a immutable string class. About learning things before writing VM, I am sure I have to. What I feel No VM or Interpreter can exists with reasonable performance with have an immutable string class. It is altogether a different matter what you call them. -----Original Message----- From: Austin Ziegler [mailto:halostatue@gmail.com] Sent: Friday, January 14, 2005 7:59 PM To: ruby-talk ML Subject: Re: Mutable strings On Fri, 14 Jan 2005 14:00:07 +0900, Mystifier wrote: > Dear Charles, > > I have no intensions of changing the language APIs for it really does > not matter to a VM Implementation. All the components that inherently > affects the VM implementations are those that VM uses natively like > File, Strings, Numbers and Threads. > > I surprisingly found Symbols are exactly not Immutable...., they are > just like any other class Um. That's not the same at all. Symbols themselves are immutable. The Symbol Class is not immutable. Yes, this means that someone could override #to_s on Symbol to do something else entirely, but Symbols themselves are immutable -- and they cannot have virtual (singleton) classes: irb(main):001:0> foo = :foo => :foo irb(main):002:0> class << foo irb(main):003:1> end TypeError: no virtual class for Symbol from (irb):2 irb(main):004:0> There is a significant difference between the two sorts of immutability that you would be advised to understand before even thinking of attempting to implement a VM to support Ruby. -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca