From: Robert Klemme Date: 2007-05-25T18:45:06+09:00 Subject: Re: Introducing the "it" keyword On 25.05.2007 10:21, Greg Fodor wrote: >> And don't tell me that this is too much typing for you. > Well, it is kinda, but that's not as bad as the fact that > 'it' will be un Gc-able till the end of the block unless > we do: > > it = v+1 > return it if it < 10 > it = nil > > It's reminiscent of the all too common ruby memory 'leak': > (http://whytheluckystiff.net/articles/theFullyUpturnedBin.html) > > x = [1, 2, 3] > loop do > # add some crap to x and use it > end > > slow_method_that_doesnt_use_x() > > This problem is even trickier w/ closures grabbing x into their > binding too AFAIK. "it" needs to show "it"self to the door > when "it"'s no longer wanted. (It's late) I see your point. I do wonder though how relevant this is in practice. If you write 100+ lines methods then you have other problems than a few objects that are kept around longer than needed. Even with short methods that exhibit the behavior you described above it is only an issue if the object kept around keeps a lot of memory from being reclaimed (which is not the case for the example above) or if the method is active multiple times. After all the cost of changing the language should be smaller than the cost incurred by this missing feature. Kind regards robert