From: Eric Hodel Date: 2005-08-21T05:31:59+09:00 Subject: Re: Non-overridable and non-redefinable methods On 20 Aug 2005, at 02:05, Eric Mahurin wrote: > Seems like I've seen somewhere referring to Matz discouraging > redefining core class methods. I've found discouragement in ruby to be something entirely different than making these things an absolute impossibility. For example: $ cat y.rb block = proc { } def foo(*x) 5 end def bar(&b) end foo (1 + 1) foo () bar &block def foo(x) 5 end foo *[1] [ ~ ] [13:26] drbrain@kaa$ ruby -w y.rb y.rb:5: warning: (...) interpreted as grouped expression y.rb:6: warning: don't put space before argument parentheses y.rb:7: warning: `&' interpreted as argument prefix y.rb:11: warning: `*' interpreted as argument prefix y.rb:9: warning: method redefined; discarding old foo I like warnings, they're gentle. Also, by naming. instance_variable* looks very clumsy because you usually can't get away with chaining of ivar set/get in 80 characters. ObjectSpace.each_object (that doesn't include Enumerable, which can be truly annoying when you want to exploit it). I like that ruby makes discouraged things look ugly over than one that forces me not to do things. I don't think ruby would be ruby anymore with your proposed changes. -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04