On 2014-06-11, 1:42 PM, Botond Ballo wrote:
I'd very much like to see this as well!
The C++11 attribute syntax might be a good way to accomplish this without
inventing new syntax. For example, the standard could define an "exhaustive"
attribute on a switch statement for an enumeration:
enum A { a, b, c };
A x;
...
switch (x) [[exhaustive]] {
case a:
return true;
case b:
return false;
} // error: 'c' is not handled
I'll find out if something like this has ever been discussed.
That would be wonderful to see!
Assuming that this hasn't been already discussed and passed up for some
technical reason, it's very much possible that all that is required for
something like this to be standardized is for someone to write a paper
proposing it, and someone to present it at a committee meeting. I'd
gladly do the second task, and help someone with the first.
I second what Botond said here. We've been trying to work on a proposal
for adding support for named arguments to C++ and as someone who has
never done this kind of thing before, it's been much simpler than I
originally anticipated. It would be great to see others from Mozilla
participate in this process we well.
Large parts of the standard library are unusable or nearly unusable when
exceptions are disabled, such as the standard containers. Sometimes they
can be used if the default allocator is changed to abort on out-of-memory,
but often abort-on-OOM is not what you want. Thus, much (most?) Gecko code
cannot use a huge part of the standard library. For example, it should be
made possible to call std::resize() when exceptions are disabled and
without triggering abort-on-OOM, such that the caller can detect when the
resize fails. Similarly, it should be possible to attempt to append an
element to std::vector without an exception being throw or the process
being aborted on failure, but with the error still detectable.
From what I've heard at committee meetings, the dominant opinion on this
topic seems to be that, since exceptions are part of the standard language,
library writers shouldn't have to go out of their way to cater to people
who don't use them.
That said, there are some libraries which have an option to use an error
code instead of an exception for error handling. I'm thinking in particular
of the Filesystem TS [1].
I'll try to find out some more concrete information on this topic.
Thank you. It would be really nice to try to at least get the committee
consider the experience of many large projects who have had to disable
C++ exceptions for years. I think that would be a first step in order
to get to an agreement on how to deal with these types of issues.
Cheers,
Ehsan
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform