From: Marek Polacek <polacek@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: GCC Mailing List <gcc@gcc.gnu.org>
Subject: Re: lambda coding style
Date: Wed, 10 Jan 2024 15:59:29 -0500 [thread overview]
Message-ID: <ZZ8FMYDzLiDg9maL@redhat.com> (raw)
In-Reply-To: <7b2c4b10-4134-4f1b-9597-de66d6072f16@redhat.com>
On Wed, Jan 10, 2024 at 02:58:03PM -0500, Jason Merrill via Gcc wrote:
> What formatting style do we want for non-trivial lambdas in GCC sources?
> I'm thinking the most consistent choice would be
>
> auto l = [&] (parms) // space between ] (
> { // brace on new line, indented two spaces
> return stuff;
> };
Sure, why not. Consistency is what matters. Thus far we seem
to have been very inconsistent. ;)
> By default, recent emacs lines up the { with the previous line, like an
> in-class function definition; I talked it into the above indentation with
>
> (defun lambda-offset (elem)
> (if (assq 'inline-open c-syntactic-context) '+ 0))
> (add-to-hook 'c++-mode-hook '(c-set-offset 'inlambda 'lambda-offset))
>
> I think we probably want the same formatting for lambdas in function
> argument lists, e.g.
>
> algorithm ([] (parms)
> {
> return foo;
> });
And what about lambdas in conditions:
if (foo ()
&& [&] (params) mutable
{
return 42;
} ())
should the { go just below [?
Marek
next prev parent reply other threads:[~2024-01-10 20:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-10 19:58 Jason Merrill
2024-01-10 20:47 ` I am causing valgrind errors Robert Dubner
2024-01-10 20:51 ` Jakub Jelinek
2024-01-10 21:17 ` Robert Dubner
2024-01-10 20:59 ` Marek Polacek [this message]
2024-01-10 21:24 ` lambda coding style Jason Merrill
2024-01-10 21:41 ` Marek Polacek
2024-01-11 2:34 ` Jason Merrill
2024-01-11 5:30 ` waffl3x
2024-01-20 2:22 ` Hans-Peter Nilsson
2024-01-11 17:45 ` Tom Tromey
2024-01-11 17:48 ` Martin Jambor
[not found] ` <65328.124011112484300622@us-mta-617.us.mimecast.lan>
2024-01-11 19:25 ` Jason Merrill
2024-01-12 11:06 ` Martin Jambor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZZ8FMYDzLiDg9maL@redhat.com \
--to=polacek@redhat.com \
--cc=gcc@gcc.gnu.org \
--cc=jason@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).