1. Default Object Lifetime Is Non-Deterministic 2. Object Lifetime is Not Determined by Scope
For a GC based language? Seriously? Sorry, but this article should not be voted up. One wonders if it was done so to peddle the Author's book.
1. Default Object Lifetime Is Non-Deterministic 2. Object Lifetime is Not Determined by Scope
For a GC based language? Seriously? Sorry, but this article should not be voted up. One wonders if it was done so to peddle the Author's book.
In C++, if you declare the object on the stack, the destructor will be called when the scope is closed. Which is very handy for e.g. lock.
The thing is, garbage collection could be use together with scope lifetime (aka RAII) just let the programmer choose which is best/more convenient for him given his resources.
The article is clearly written for pogrammers coming from C++ to C#, which there are a lot of, including myself. I like both C++ and C# a lot but have to admit that managing object lifetime in C# is one of the things I really dislike. There's the suggestion that RAII is reasonable in C# but for me always ends up being a headache.