> I suspect you're stuck in a C++ paradigm where you feel you have to > design objects that automatically eradicate themselves as soon as they > get out of scope. That's absolutely not the .NET paradigm. The finally
I'm groking all that just fine. I have read the Richter book that you mention and am schooled in the whole .NET paradigm (I hate that word almost as much as synergy!) However, you're, to some degree, correct. There are some things that my head is attempting to create a mapping for that just simply do not exist. ;-) > No, you are completely wrong here. .NET does not work like unmanaged Well, I would not say completely wrong. ;-) I know all the nuances of the GC and what it is doing. I should have been a little more specific earlier. Sorry about that. I _am_ specifically talking about objects that do need to implement IDisposable, such as FileStream so that resources are released on demand if need be. Obviously, we would not want a lock to remain on an object indefinitely if an exception occurred from inside the only block that had a root to it. And, forcing the GC to collect is clunky at best. Of course, using a __try/__finally block will take care of this, but I just wish there was a cleaner way in C++, much like C#'s 'using'. Again, it can't be too hard to craft a non-managed object with a deterministic destructor to manage that. This raises an interesting question about the GC implementation. Since it knows of all of the roots' existence, how hard/inefficient would it be for the GC to automagically call Dispose() on a type that implements IDisposable if it absolutely knew that the last known root to that type just went out of scope? I imagine this would require a significant amount of work to make it efficient compared to the current GC implementation. > I can't really tell if you're smoking anything, I suspect you just need > to read a good .NET introduction and get those C++ programming patterns > out of your mind. :-) The standard book on the .NET Framework is :-D C++ idioms, yes to some degree..... patterns? I think not. ;-) Thanks for the comments on my sometimes unguided ramblings. -Trey You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.
