On Tue, Jun 19, 2012 at 10:12 PM, Hal Fulton <[email protected]> wrote: > >> > Freezing an object also reduces its contract. >> >> Kind of. But I consider that a special case because freeze prevents >> all mutations but not other operations. It also does not restrict the >> range of valid state - it just freezes it. > > Hmm. If a Symbol is-a frozen String, how does that reduce the range > of valid state any more than a "real" frozen String?
Freezing does _not_ reduce the state, which is what I said above. With inheritance Symbol is-a String - not "frozen String". If at all the inheritance would be the other way round: a String is-a Symbol and it would extend the contract by mutating methods. > What operations > other than mutations are prohibited? For example: String has method << which is part of the public contract and that will be broken by _all_ Symbol instances. So you give someone something and say "this is a String" but in reality it is not because all instances lack many of the functionality of String. While with actually freezing Strings << works most of the time and there are just some instances which are in a state (frozen) which does not allow successful execution of the method. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ -- You received this message because you are subscribed to the Google Groups ruby-talk-google group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at https://groups.google.com/d/forum/ruby-talk-google?hl=en
