C++ Logo


Advanced search

Re: Removing ellipsis from the catch-all handler sequence

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Wed, 24 Jun 2020 13:23:51 -0400
On Mon, Jun 22, 2020 at 9:39 PM Kyle Knoepfel via Std-Proposals
<std-proposals_at_[hidden]> wrote:
> The catch-all handler sequence of a try-block is denoted by the 'catch (…)’ syntax. My proposal is that the ‘(…)’ characters could/should be removed (e.g.):
> try {
> ...
> }
> catch (std::exception const& e) {
> ...
> }
> catch { // i.e. no catch(…) anymore
> ...
> }
> The motivation here is two-fold: first, it is easier to read for the cases where access to the exception object is unnecessary; and second, it gets a closer to using ellipses for only variadic templates. My hope is that eventually C-style variadic arguments will be become a thing of the past, but that is not the topic of this post.
> In making the above suggestion, I am reminded of a response Ville made to one of my other ideas: "There's nothing impossible in it, but ideas that require changing every c++ parser on the planet need to cure cancer, and this idea doesn’t.” That is true enough in this case, but if influences from C are sometimes cancerous, then this is a step in the right direction.

OK, but you said that "influences from C are *sometimes* cancerous".
If that's your justification for the change, then you need to show
that this particular use of `...` is *actually* cancerous. That it's
fundamentally a problem in some respect other than that it is an
"influence from C". Especially since `catch(...)` means something
rather different from `function(...)`.

I don't really see a sufficiently strong motivation here. C++ is not a
clean language; it reuses and repurposes the same syntax for wildly
different purposes in several cases. Removing precisely one instance
of that will not change what C++ is. I know that sounds like "if you
can't fix everything perfectly, don't fix anything at all", but this
particular change is so trivial that I think it warrants more
justification than being a step towards one day having a version of
C++ where we "use ellipses for only variadic templates".

Especially when the next step towards that world is decidedly unlikely
to be taken.

Received on 2020-06-24 12:27:13