From: Eric Mahurin Date: 2005-10-06T23:23:12+09:00 Subject: Re: foo= ... the only exception to the implicit-self rule ? --- itsme213 wrote: > Have you decided whether 2.0 will require all local vars to > be distinguished > via some syntax (e.g. |...|), or will 2.0 continue the > current special-case > handling for self.foo= ? This would really make ruby ugly. One of the beauties about ruby is that you don't have to declare your variables (type or existance). There are currently deficiencies in the flexibility of variable scoping (only def/class/module can make real local variables as far as I know), but I would hope that could be solved without adding variable declarations. Take a look at my RCR 307. In this one, you can do this: obj.foo(arg1,arg2) = value which would be equivalent to: obj.send(:foo=,arg1,arg2,value) Well, there is no reason this RCR couldn't handle the no receiver case: foo(arg1,arg2) = value And the no receiver/no arg case: foo() = value which would be equivalent to: self.foo = value Just like the case when you already are using a local variable "foo" where you use "foo()" to call the method foo, the same can be done for assignment. But, I think the self.foo=value syntax would still be preferred by most. I'm not sure why you dislike it so much to propose making such radical changes. We are also talking about inside the class, so you know the implementation. Unless foo= is complex, you might want to just inline it whenever you want to use it (typically @foo=value). This will give you a performance boost since you are cutting out a method call (runtime is probably dominated by the method call mechanism in most cases). __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com