On Saturday 01 February 2003 05:58 am, Mauricio FernáÏdez wrote: > Would these instant attributes live between method calls? > > class Bar > def foo > x = 1 > end > def foo2 > puts x > end > end > > a = Bar.new > a.foo > a.foo2 # puts 1 ?? eeee.....well, they wouldn't be local then :) on the other hand is self became associated to the def, then other problems would arise. okay, so that was actually a dumb idea. :0o > You possibly break GC, as blocks can access variables deeply down the > stack, so you're in fact capturing a substantial part of the environment > in each closure. > > def foo > x = "a" * 100000 > proc do |i| > self[i].x # Ouch, self.x can never be reclaimed for any self down > # the stack! > end > # normally x could be reclaimed here unless explicitly used by the > # closure > end > > def foo2 > x = "b" * 100000 > foo > # normally x could be reclaimed here, but the closure might use it > end > > foo.call(1) > foo2.call(2) > foo.call(100) # now, what was x 100 stack-frames ago? > > I had better never use self[i].tmp inside one of these super-closures :) > > Maybe I got it wrong, but I have the feeling this is too powerful. > I'll think more on this. > > Now, I sound like matz ;-) > > These super-closures sure are very seductive :) like the the whole universe in a nutshell. amazing how complex things can be come. thanks for responding. i knew these were amiss notions i just needed someone to point it out for me. -- tom sawyer, aka transami transami / transami.net