Re: Abi string class


Subject: Re: Abi string class
From: Sam TH (sam@uchicago.edu)
Date: Thu Feb 01 2001 - 19:48:20 CST


On Thu, Feb 01, 2001 at 02:37:12PM +0100, Mike Nordell wrote:
>
> Exceptions. If you try to modify an object and that can't be done (such as
> out of mem) the object hasn't got the users intended state. Yet, with and
> operation like
>
> string& operator+=(const string&)
>
> The only way you could ever report failure is using exceptions. The return
> value from the operator will still return a legal string, just not the
> string you would expect. i.e.
> string s3 = string("foo") + string("bar");
> might result in s3 == "foo", not "foobar" as you'd expect if it was correct.
>
> The two possibilities are
> 1) allow exceptions to report out-of-mem conditions.
> 2) don't allow this syntax, require
> bool append(const string& rhs);
> and report any error via the returned bool.

So, what happens if you get an OOM error is that it fails silently,
and you keep the old value?

This seems like a really bad idea. How can we detect errors?
           
        sam th
        sam@uchicago.edu
        http://www.abisource.com/~sam/
        GnuPG Key:
        http://www.abisource.com/~sam/key




This archive was generated by hypermail 2b25 : Thu Feb 01 2001 - 19:48:16 CST