C++ Logo

std-proposals

Advanced search

Removing ellipsis from the catch-all handler sequence

From: Kyle Knoepfel <kyleknoepfel_at_[hidden]>
Date: Mon, 22 Jun 2020 20:39:35 -0500
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.

Thanks,
Kyle Knoepfel

Received on 2020-06-22 20:42:48