r181182 - Don't put a space before ellipsis.

Richard Smith richard at metafoo.co.uk
Mon May 6 10:33:05 PDT 2013

On Mon, May 6, 2013 at 2:39 AM, John McCall <rjmccall at apple.com> wrote:

> On May 5, 2013, at 11:45 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> On Sun, May 5, 2013 at 11:35 PM, Daniel Jasper <djasper at google.com> wrote:
>> Author: djasper
>> Date: Mon May  6 01:35:44 2013
>> New Revision: 181182
>> URL: http://llvm.org/viewvc/llvm-project?rev=181182&view=rev
>> Log:
>> Don't put a space before ellipsis.
>> Before: template <class ... Ts> void Foo(Ts ... ts) { Foo(ts ...); }
>> After:  template <class... Ts> void Foo(Ts... ts) { Foo(ts...); }
> I would think the star-on-the-right crowd (that is, the people who are
> right ;)) would actually want:
> template <class ...Ts> void Foo(Ts ...ts) { Foo(ts...); }
> ... since the ellipsis, just like an & or *, binds to the thing on its
> right.
> Eh.  Star-on-the-right is born of wanting to make people mindful of the
> declarator grammar in the important places where you can have multiple
> declarators, and then just being consistent with that everywhere.  If
> declarator syntax didn't work that way, i.e. if types weren't awkwardly
> wrapped around the name at all or if the first declarator "prefix" was
> shared across all the declarations, I think star-on-the-right would clearly
> be the wrong thing to do.
> Since, thankfully, there's no context that lets you re-use the tag
> keyword (template <class ...A,B,C>!), and the template clause is its own
> wonky thing in the grammar, I find that putting the ellipsis with the rest
> of the kind (in the formal sense) makes more sense.

The meaning of the ellipsis is (very nearly!) consistently determined by
the thing on its right; I want ellipsis-on-the-right to remind people of
that. As with & and *, the "kind" is wrapped around the identifier, not
just on the left. For instance, while ellipsis-on-the-left may look
reasonable for "Ts... a[4]", it's deeply confusing for "int... a[Ns]". Plus
"Ts &&... ts" looks dumb, whereas any of "Ts&&... ts", "Ts &&...ts", and
"Ts&& ...ts" seem fine to me.

... and then there are the cases where we *must* put a space before the
ellipsis, such as "f(xs + 1 ...)". In the interest of consistency, I think
always putting a space before the ellipsis and never putting one after is
the right choice (except for sizeof..., where the ellipsis is logically
part of the token).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130506/3f3e107d/attachment.html>

More information about the cfe-commits mailing list