From: Yukihiro Matsumoto Date: 2007-12-10T17:33:07+09:00 Subject: Re: redefineable not operator Hi, In message "Re: redefineable not operator" on Mon, 10 Dec 2007 17:17:51 +0900, murphy writes: |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? As I said before we try our best to stabilize features before Christmas. 1.9.1 on Christmas will not be as stable as you (or we) expected. |- it seems I can no longer rely on !x returning a boolean :( | how do I make my !!x hacks 1.9-compatible? We don't encourage to redefine ! operator, unless you know what you are going to do. |- does it affect performance? reading the source, I assume that a != b | is now slower than a == b, because it does another funcall. It does. But eventually Koichi will prepare call avoidance unless !/!= is redefined, I hope. |- can someone give an example where it would be useful to redefine !, | != or !~? For example, big_sized_narray.delete_if{|x| x != 0} to invoke x.!= which creates C coded filter, to avoid evaluating a block for each elements in the NArray. |- 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) Perhaps, you need to fetch again from the repository. |I hope you make %...() and :: redefinable next ;) They are fundamentally not redefinable, I think. matz.