[haiku-development] Re: BPath::Append() resets the original path in case of failure.

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 25 Feb 2009 17:11:09 +0100

Bruno Albuquerque schrieb:
Stephan Aßmus wrote:

This all becomes clear when reading through the BeBook documentation for BPath. So both the BeOS and Haiku version perform as documented. Append() is implemented via SetTo(). SetTo() is destructive even in case of error. It becomes a matter of liking (or not) the fact that Append() is destructive... and whether this can even be changed, or if this would break any existing apps.

Yes, but an append operation should not have the side-effect of an error resulting in the original object being cleared up. I am pretty sure that if we were coming with this API today, we would not do something like that.

That said, we may break code that rely on checking the path for being NULL after an append operation to determine error, but I would argue that this code is also broken (as it should check for the return value of Append() instead).

Since also SetTo() returns an error, and it could be argued that it should not be destructive either, we may as well change that to behave more like one would expect. What do other think? The problem with such changes is that we don't really have the resources to check a lot of existing applications for the effect of such a change. :-\

Best regards,
-Stephan


Other related posts: