From: Charles Hixson Date: 2002-08-13T03:08:39+09:00 Subject: Re: ambiguity between local variable assignment and writter method Tom Sawyer wrote: >On Fri, 2002-08-09 at 12:05, Paul Brannan wrote: > > >>Why not use: >> >> self.localvar = x >> >> >> > >code smell. > > Proc.new { > self.i_am_a_writter_method = 'so i need my self' > but_i_am_not('so i'm cool without it') > self.there_could_be_a_lot_of_these = 'that's a lot of ego ;-)' > } > > > > To me it seems that efficiency issues can dominate here (as to which form should be used). The argument for having a setter method be the same as a direct reference (for externally accessible variables) seems impecable. The caller shouldn't need to know. Internal use, however, can be quite different. Sometimes the validation methods can be a bit expensive (e.g.: Is value actually referred to in the file?) Even an expensive check may be highly desireable when an external call is being made, but internally, calls that are known to be safe should be able to short-circuit the validation, and set the method directly. Otherwise processing can become unbearably slow. And this is a kind of slowness that changing languages won't fix. -- -- Charles Hixson Gnu software that is free, The best is yet to be.