From: Daniel Carrera Date: 2002-12-01T05:55:42+09:00 Subject: Re: Ruby ++, the one element and generators [snip] > In algebra, the one element is a particularly important element (along with > zero) because you can generate all values by systematically adding the one > element to the previous result, starting with the zero element. Their importance is not that 0 is the additive identity, and if we have a ring, then there is a multiplicative identity 1. [snip] > It appears to me that all the talk about why ++ is not valid due to > anti-shoe-box behaviour is beside the point, because the would also be true > for += : The anti-shoe-box explanation, as I understand it, is that assignment (ie. "=") is distinctly different from object methods (e.g. +). This explains why += cannot be a method. Indeed, it is not a method. The analogy does not say that we cannot have a '++'. It only explains why, if we did, it would not be a method either. [snip] > The point, is that whatever problems there are with ++ and object > modifications applies equally to += and the next, next! method, and these > problems have been solved. True. Maybe the difference is that '+=' has an '=', so it looks like a binding operator. Maybe Matz feels that '++' is just not "The Ruby way". [snip] > Note that integers do not have a next! operation and float do not have > a next method at all - this makes perfect sense: > > In algebraic terms, there is no 'one' element for Real numbers, while > natural numbers (integers) do have a one element. Please don't call it "one". There is a multiplicative identity, it's just 1. It just happens that 1 is not an additive generator. Call it "generator". [snip] > a++ as a synonym for > a = a.next [snip] > a++! as a synom for > a.next! Perhaps we can make 'a++' a synonym for 'a.next' (i.e. no inplace change) and 'a++!' a synonym for 'a.next!' (i.e. inplace change). Maybe Matz will like that. Daniel.