From: David Abrahams (dave_at_[hidden])
Date: 2008-07-01 10:40:47
Beman Dawes wrote:
> The remove(p) function is currently specified to return a bool with a
> value of exist(p) before the post-condition is established. The
> post-condition is !exists(p).
You can't really guarantee that, can you? Can't some other process
sneak in and re-create p before remove returns?
> The original thought in providing this was that the return value might
> be useful and would cost nothing.
> It turns out that providing this return value does have several costs:
> * A call to exists() could be omitted if the actual system removal call
> succeeds. exists() is surprisingly expensive on some operating systems.
> * It makes the remove() function less reliable in that it introduces a
> potential race condition.
> * It makes flow of control more complex (and thus harder to test) for
> some implementations.
> Thus I'd like to change the return to void. Although that will break
> some code, the breakage will result in a noisy compile-time error that
> is easy to fix by inserting a call to exits() before the call to remove().
Sounds like you're making the right choice here.
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk