From: Michael Neumann Date: 2001-09-05T20:44:17+09:00 Subject: [ruby-talk:20920] Re: RCR: non-bang equivalent to []= Florian G. Pflug wrote: > > But this will not be compatible. Array#delete, #fill and all the others > > must be changed to the bang version. Any change to existing method names > > will break code. A solution would be to introduce #delete! etc.. > > that are just an alias to #delete. But this would break IMO PoLP. > > I think, you either > 1) See the bang as a help, especially in situations where is is not clear. > that array#delete_at modifies the receiver is quite clear I think. > 2) See it as a part of the languages syntax. Then is should be enforced by > the interpreter. > > I prefer the opinion 1). me, too. > However, the change _would_ be possible. > > One would have to define two include files, ruby_old and ruby_new. > > First, ruby_old would be an empty file, and ruby_new would change the array > class (and perhaps other classes) accordingly. > > After the change is done in ruby itself, ruby_new would be empty, and > ruby_old would restore the previous behaviour. > > Of course, when phase two is reached, code breaks. But by then, everyone has > hd the change to either fix his code, or add a "require 'ruby_old'" at the > beginning of each file. This would IMHO not work in all situations. Imagine you use an old library using "ruby_old" implicitly. But in your program you use the "ruby_new". What happens if you pass an Array from your program to the old library, and this calls Array#delete or something else? Would it break? Yes it would, because there's only one Array class, unless your new program uses a class named e.g. NewArray. Regards, Michael -- Michael Neumann merlin.zwo InfoDesign GmbH http://www.merlin-zwo.de