From: MikkelFJ Date: 2003-05-21T05:14:06+09:00 Subject: Re: An Object Going Out Of Scope "Jim Weirich" wrote in message news:1053406677.17559.8.camel@traken... > How about this syntax ... > > auto(foo=MyObject.new, :cleanup) do > # use foo > end fine if you can handle multiple objects this way. Mauricios suggestion does that, but does not allow you to specify cleanup method. This, of course can be done in many ways. > > { auto(:$critsec, :exit); @critsec.enter; .... } > > > > Critcal sections are better handled by blocks ... > > lock(mutex) do > # critical section > end Like files, except when you want both at the same time. You can probably get a way with nesting though. Mikkel