Browse thread
exception safety / RAII ?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jon Harrop <jon@j...> |
| Subject: | Re: [Caml-list] Re: exception safety / RAII ? |
On Tuesday 08 March 2005 11:33, Ville-Pertti Keinonen wrote: > I'm not sure I understand Jon Harrop's concern about using resources > after they've been deallocated. This has been addressed in the obvious > way (return errors for operations on remaining references) in various > languages for decades, and unlike memory management and type errors, > AFAIK hasn't been a major source of bugs or complaints. A great deal of effort has been put into writing static verifiers to ensure correct use, in order to remove this class of run-time errors. So I think this is unquestionably a source of bugs. Could it not be said that having a GC is a way to avoid such errors in the context of memory allocation and deallocation? On Tuesday 08 March 2005 13:07, Damien Doligez wrote: > On Mar 7, 2005, at 18:10, Jon Harrop wrote: > > I believe that OCaml guarantees to close your files at least upon program > > termination, > > OCaml does no such thing. The OS does. Yipes! In that case I take back what I said before and agree with Stefan - it is sloppy coding style to not explicitly close a file. That seems most odd though. Is this for historical reasons - closing files was added long before object finalisers? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. Objective CAML for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists