From: Brian H. <bh...@sp...> - 2004-06-29 03:40:55
|
On Mon, 28 Jun 2004, Jere Sanisalo wrote: > Also coming from a C++ background, I've found the lack of a scope finalizera > bit disappointing. I'm not sure that scope finalization is even possible in Ocaml. I am sure it's neither needed nor a good idea. The problem comes in that the "scope" of a function can last longer than the function call can. This is especially true if you return an inner function, like the following code: let myfunc x = let myret y = x + y in myret ;; When does the "scope" end? You shouldn't be depending upon when things get finalized. If things need to get done at a certain time, explicitly do them. IMHO, you shouldn't be doing signifigant work (i.e. more than just free resources) in a C++ destructor either. It's a confusing way to structure the code, and throwing an exception when unrolling the stack due to another exception is bad. -- "Usenet is like a herd of performing elephants with diarrhea -- massive, difficult to redirect, awe-inspiring, entertaining, and a source of mind-boggling amounts of excrement when you least expect it." - Gene Spafford Brian |