"Jim Weirich" <jweirich / one.net> wrote in message news:1053238069.6843.15.camel / traken... > On Sun, 2003-05-18 at 00:47, vinita Papur wrote: > > A quick question. How can one discern when an object goes out of scope? > > I'd like to do something like this: > > Objects don't have scope. Variables do. (a subtle distinction) > Use a block to manage resources. Like this ... Still, it would actually be nice to have a feature in Ruby that would trigger a finalizer when the variable goes out of scope. There are problems becuase there could be more references at the time of finalization, but this could also be the case with cleanup using structs. I.e. closing a file doesn't guarantee there are no more references to the file. See the auto attribute of the D programming language: http://www.digitalmars.com/d/attribute.html#auto Mikkel