Re: We do not use C++ exceptions
On Feb 3, 12:06 am, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
Seungbeom Kim <musip...@bawi.org> writes:
if (!fexists(fn)) {
// error: file not exists
(...)
else {
// finally we know we can open the file
FILE* fp = fopen(fn, "r");
// let's hope this succeeded
The filesystem might have changed in the meantime.
That's why Seungbeom wrote:
// finally we know we can open the file
// but if somehow we cannot, because for example we failed
// to check for something, or something changed between the
// checking and the opening, then the behaviour is
undefined!!
....to say that the file system might have changed in the meantime. :)
Also, Seungbeom's argument is equally applicable in the context of
serialization:
Socket s;
Foo f; // A Foo is massively complex data structure containing member
lists, maps, etc.
s >> f;
What now? Should f refuse to construct itself from the data coming out
of s until it has verified such data is "safe"?
Even if the answer were "yes", what would the code look like?
-Le Chaud Lapin-
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]