From: dvandeun@... (Dirk van Deun) Date: 2006-02-22T23:23:37+09:00 Subject: Re: dirty ranges : This is another face of Dirk/Tony's concern. Perhaps the first : element should be cloned for symmetry and safety. But how: #dup, : #clone, something else...? You'd also be adding a new requirement : that non-immediate range elements must be copyable. Hmmm... The requirement could be weakened a bit, because you do not need to clone range elements immediately. The begin and end could stay uncloned; and cloning could be delayed until a min is asked for; so that the min would be an ad hoc calculated value like the max. Methods like to_a and each would then need to use min and max, not begin and end, but they probably already are. "Safe" methods, like ===, could use begin and end in their implementation, so that ranges of non-copyable elements would still be possible and useful. (But only to be used in "safe" circumstances.) Of course, the weakened solution would not prevent the following from happening, but this is really "asking for it": irb(main):001:0> a="a" => "a" irb(main):002:0> z="z" => "z" irb(main):003:0> rng=a..z => "a".."z" irb(main):004:0> a[0]="b" => "b" irb(main):005:0> rng => "b".."z" Accidents that happen indirectly via innocuous-looking to_a and each calls would be prevented. Dirk van Deun -- Ceterum censeo Redmond delendum