From: Jean-Hugues ROBERT Date: 2004-04-24T06:37:03+09:00 Subject: Re: Creating bang methods At 05:52 24/04/2004 +0900, Jim Weirich wrote: >Jean-Hugues ROBERT said: > > About ++ ... > > At 03:48 24/04/2004 +0900, you wrote: > >>Just like +=, ++ can not be defined as a method on an object. > > > > but + can be redefined and ++ could as well. > >+ is a method. It is sent to an object. (e.g. 1+2 === 1.+(2) ) > >= is not a method. It is never sent to an object. It binds objects to >names within a scope. (e.g. x=1 means that the name "x" is now bound >to the value "1") > >++ cannot be a method because it changes bindings, just like =. Let me rephrase. If ruby was to understand: this++ ++that as (syntax sugar for): (tmp = this, this = something.postplusplus(), tmp) (that = that.preplusplus()) then one could redefine methods postplusplus() and preplusplus() (whose default definitions should be: self.plusplus(); in a decent world). I understand that = is not a method as of today. And need not to be for ++ to be re definable (as rephrased). BTW: Making = a method (of class Binding I guess) would open interesting perspectives... ;-) Jean-Hugues