From: murphy Date: 2007-12-10T17:17:51+09:00 Subject: Re: redefineable not operator David Flanagan wrote: > I saw the following commit the other day: > Commit by matz :: r14162 /trunk/ (7 files in 2 dirs): > * parse.y (expr): redefinable not (!) operator. > * parse.y (arg): ditto. > * object.c (rb_obj_not): new method "!". > * object.c (rb_obj_not_equal): new method "!=". > * object.c (rb_obj_not_match): new method "!~". why such heavy syntax changes, two weaks before the release of Ruby 1.9.1? I mean, I'm happy that changes are always possible here, but I thought 1.9 was fixed some time ago. it's really confusing for me, since I don't know any (English) website that's summarizing what's going on recently... so there is no 1.9-stable branch? no feature-fixed release candidates before 1.9.1? anyway, the change is interesting. I remember having a lot of arguments for != not being a method when I tried to explain the exception in the German Ruby forum. I thought it was a design decision with positive side-effects on performance and simplicity. the change raises some questions: - it seems I can no longer rely on !x returning a boolean :( how do I make my !!x hacks 1.9-compatible? - does it affect performance? reading the source, I assume that a != b is now slower than a == b, because it does another funcall. - can someone give an example where it would be useful to redefine !, != or !~? - when I tried it in irb, I got this. I have no idea what's happening. irb(main):001:0> def !; 42; end => nil irb(main):002:0> public :! /usr/local/lib/ruby/1.9/irb/input-method.rb:100:in `gets': private method `!' called for false:FalseClass (NoMethodError) [ long callchain ] I hope you make %...() and :: redefinable next ;) [murphy]