Benjamin Smedberg: Exceptions Don?t Solve the Problem (and create worse problems)

Brendan claims that the XPCOM nsresult return type is a significant cause of bloat due the need to rv-check every XPCOM method call, and proposes that XPCOM switch to use C++ exceptions. This is an idea that might appear attractive on the surface but would not only break the existing binary compatibility of XPCOM but would permanently destroy XPCOM as a component model with a standard binary API. XPCOM is a component system that is based on binary compatibility of interfaces. While the layout of interface vtables is based on C++ vtable layout, it does not depend on the peculiarities of the C++ ABI including the layout of concrete classes or how RTTI is calculated or how exception handling is implemented. Switching XPCOM component code to expect and use exceptions would immediately break not only any existing XPCOM binaries, and force a revision of the XPCOM ABI to version 2, but would also require a careful rewrite of the source code of these components. This would have the affect of breaking XPCOM’s current binary compatibility with MSCOM. Neither of these are automatic dealbreakers, thought they should be considered extremely carefully. But exceptions have other side-affects which should be dealbreakers: the implementation of C++ exceptions is extremely dependent on the compiler implementation, both of exceptions themselves and of the underlying RTTI needed to handle them correctly. view original article
Sat, 18 Feb 2006 15:00:30 +0100

more Planet Mozilla articles