From: Robert Klemme Date: 2004-10-13T00:34:35+09:00 Subject: Re: Ruby Directions (was Re: quality of error messages) "Markus" schrieb im Newsbeitrag news:1097593941.20674.27.camel@lapdog.reality.com... > On Tue, 2004-10-12 at 00:09, Robert Klemme wrote: > > Regardless of whether Ranges should rather be immutable or not, I plead > > for sticking with the current immutability. The reason is simply that a > > change of mutability of a class is a major change, which is likely to > > break a lot of code. Everybody that relied on a Range being immutable and > > thus stored an instance as member of his own classes might recognize the > > range suddenly changed when it's no longer immutable. > > I'm not sure I understand your point; could you provide an example > of how this might happen? Specifically, how code that did not attempt > to modify something would be affected if it became, in theory, possible > to modify it. Or am I misunderstanding? class Demo < Struct.new(:range) def show range.each {|val| puts val} end end r = 1..10 d = Demo.new r d.show # modify r in place d.show In this scenario the second "d.show" will unexpectedly print something else if r could be modified in place. Kind regards robert