[c++-pthreads] Re: C++ and posix threads
Nathan Myers
ncm at cantrip.org
Sun Dec 28 04:54:06 UTC 2003
On Sat, Dec 27, 2003 at 03:24:44PM -0800, Richard Henderson wrote:
> On Thu, Dec 25, 2003 at 02:35:31PM -0500, David Abrahams wrote:
> > I'm not sure I understand what you're saying. The POSIX C binding
> > standard is in direct conflict with the ISO C++ standard, so _some_
> > standard will be violated. [...] If that's what you're saying, why
> > is it better to violate the POSIX standard than the ISO C++ standard?
>
> I think there are degrees here.
>
> The conflict with ISO C++ is that it says that ISO C functions can't
> throw. Reverting that clause seems to me to be a minor change.
Do you _really_ see breaking just about every existing thread-safe
library as a minor change? (It would be disingenuous to remark that
those libraries are "already broken". Thousands of them have been
working fine on millions of systems, year after year.) Exception-safe
code distinguishes points that may throw from those that can't. Those
functions have not reasonably been expected ever to throw. Code that
calls them frequently and reasonably depends, for correctness, on them
returning normally.
It is manifestly clear that, for C++, requiring all those thousands of
libraries to be rewritten is unnecessary.
> The proposed change to POSIX such that it does not use abnormal return
> semantics is a *major* change.
Nobody proposed changing POSIX.
The proposed semantics is for the C++ _binding_ to POSIX, which
(I understand) doesn't exist yet. This implementation would be a
demonstration of a simple C++ binding, to present to POSIX, which
might later be elaborated with a C++-like interface to matching
semantics. The only risk I see in this first effort is if some of
the required cancellation points do not have any means to report
failure; there would be some work in identifying those, if indeed
there are any.
(There would certainly be plenty of C programmers who would welcome a
mode in which cancellation means syscalls return failure, so they can
use those thousands of libraries that have been rendered inoperative
by late implemention activity -- but that's none of our business here.)
I have been reading archives of discussion of the POSIX C binding:
Whenever a C++ compatibility concern was raised, in the messages
I read, someone was quick to retort that it was the C, not the C++
binding, that was under discussion. Such rejections implied a promise
that for C++ the semantics could reasonably differ as needed to be
compatible with C++ language semantics. To assert now that the C++
binding cannot depart from the C binding in any detail would be a
deep betrayal of that implied promise.
Nathan Myers
ncm at cantrip.org
More information about the c++-pthreads
mailing list