Boost logo

Boost :

From: Stewart, Robert (stewart_at_[hidden])
Date: 2002-03-20 15:45:41


From: Brey, Edward D [mailto:EdwardDBrey_at_[hidden]]
>
> > From: Stewart, Robert [mailto:stewart_at_[hidden]]
>
> > Why is it so important to know that the file didn't exist
> > when remove() tried to remove it!
>
> It depends on why you're removing it, of course. Say you've
> called program
> A to create a script, which you feed into program B, which
> you delete when
> program B is done. If you get to the delete, and the script
> file isn't
> there, you know you're in trouble. You wonder why program B didn't
> complain. Maybe A didn't put the file where you expected and B used
> internal defaults. Better to get a nice exception rather
> than have the
> sequence silently "work".

I don't buy it. If this is important, program A will check to see that the
script exists before calling B. If B doesn't complain about the script's
absence, then it isn't important to B. When A regains control, it's only
concern is to ensure that the script no longer exists; no exception needed.

> Consider a utility that dumps your heap when a program exits.
> If there is
> something in your heap, you have a leak. By the time the problem is
> detected, there isn't any programmatic action that you can
> take to recover
> from the error. However, it is still valuable for
> diagnostics to have the
> check in place.

You lost me. How does this illustrate the need for remove() to throw an
exception when the file doesn't exist?

> Checking that a file that you expected to exist actually
> exists is likewise
> useful for spotting bugs that may otherwise be hard to detect.

Please give me good examples of this. I can't think of one.

> > > This is a good demonstration that there are at least two
> > > different use cases
> > > for the file IO library. Setting up try blocks for each
> > > remove is too much
> > > coding. Likewise, checking the return value from each remove
> > > is too much
> >
> > But you don't need to check it in most cases.
>
> The need to check is a matter of degree. I'd say that there
> is often a
> "desire to check for diagnostic purposes".

Please give me good examples of this need.

Rob
Susquehanna International Group, LLP
http://www.sig.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk