
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().
Comments?
Sounds like you're making the right choice here. -- Dave Abrahams BoostPro Computing http://www.boostpro.com