public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* lambda coding style
@ 2024-01-10 19:58 Jason Merrill
  2024-01-10 20:47 ` I am causing valgrind errors Robert Dubner
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Jason Merrill @ 2024-01-10 19:58 UTC (permalink / raw)
  To: GCC Mailing List

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;
   };

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;
   });

Any other opinions?

Jason


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-01-20  2:22 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-10 19:58 lambda coding style 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 ` lambda coding style Marek Polacek
2024-01-10 21:24   ` 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

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).