From: Mathieu Bouchard Date: 2001-12-10T13:50:27+09:00 Subject: [ruby-talk:28058] Re: Perl/Python Module Porting On Sun, 9 Dec 2001, Massimiliano Mirra wrote: > On Sat, Dec 08, 2001 at 01:29:52PM +0900, Mathieu Bouchard wrote: > > 2. In Ruby, there is _no_ equivalent to SCALAR. In Ruby, variables are not > > objects; in Perl they are fcv ("first-class value") > Is that the reason why something like this cannot be done? > class Integer > def double! > self = self * 2 > end > end yes. For that reason I'd call Perl/C++ "variable-oriented", and I'd call Ruby/Lisp/Smalltalk "value-oriented". If you could change the value of "self" in Ruby, following value-oriented style, it would just mean that the rest of the method is going to be in the context of a different object; the object originally pointed by "self" wouldn't be changed, nor would the variable you used in the expression that called that method. > (A delegate with @value as the Intenger would be a solution, but I > wonder: is there any redefinition or inheritance way to do the above?) I don't think there's much benefit going beyond delegation. I may even do explicit #value/#value= instead. My main use for integer variables would be for model/view intboxes, scrollbar, sliders, etc; not much more than that. ________________________________________________________________ Mathieu Bouchard http://hostname.2y.net/~matju