Re: Objective C++ and ObjC exceptions

  • On 21.09.2007, at 21:35, Kai BrĂ¼ning wrote:

    >> Well, you need to catch exceptions and either throw a C++ wrapper
    >> exception or handle them before they exit a scope where you've
    >> used RAII.  A bit of a pain, perhaps...
    > [....]
    > ... some substantial code ...
    > and have the compiler guarantee that the destructor of 'o' does the
    > release no matter what.

    no. Use autorelease.

    > But than again, if I think about it, wrapping such calls in a catch
    > block is necessary in the above example anyway to do the release,
    > so maybe exception wrapping is a valid approach.

    It is AFAIK the only under all circumstances working approach, which
    brings me to my personal conclusion that Objective-C++ is only apt
    for shallow interface layers as bracketing each language (Obj-C and C+
    +) with approproate exception handlers is a PITA. IOW, it allows to
    use C++ objects without adding an C interface layer. Note that that's
    the standpoint for writing "correct"  code and not "Umm, usually it
    works, will add an fix/workaround when user reports errors" software.

    One could, of course, use only nothrow() C++ methods or only handle
    std::exception as a NSException does not mean "unwind transaction,
    report and continue" but "Completely failed. Bad programmer. Fix your

previous month september 2007 next month
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today