From: "Aryeh M. Frierdman" Date: 2003-07-07T07:33:36+09:00 Subject: Re: Freezing an arbitary object Joel VanderWerf wrote: > Brian Candler wrote: > >> - local variables: cannot be frozen, since they don't belong to an object >> and are not an object themselves. They can always be reassigned to >> point to another object. Sorry, that's a Ruby fact of life. > > I wonder why this doesn't work? I didn't expect it to, but I'm curious. > > irb(main):005:0> b = binding > # > irb(main):006:0> eval "y=1", b > 1 > irb(main):007:0> eval "y", b > 1 > irb(main):008:0> b.freeze > # > irb(main):009:0> eval "y=2", b > 2 > > Would it be useful to be able to freeze the current binding? Disastrous? > Inefficient? Being new to ruby I would not know the exact reasons but I susbect that at the interpreter level a local is implimented as a ptr into a stack frame vs. a ptr to the free store thus it would be dangerous to freeze a tempurary object. On second thought this might not be true since how whould you handle doing garbage collection on a long running method that "free's" a local????