From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id 239453858D1E; Tue, 16 Jan 2024 05:48:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 239453858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1705384098; bh=gXrux6eJwjsmCAwaaNl215UTPeO6Tk4xIbXouRqrOnI=; h=To:Subject:Date:From:From; b=EMBM7n1w0J01kBDcqF7rCuP8mKBsQ36oQCOpzCoAevBO/LbrhFr2qHyXLKv4ccKxp R2xTMGJxD8xTo2UA1IiNvPFpMi+1+xgmqRmhMk3jfEQKAjoKTjLBYhWupI0woo2T7z /cHOYqC01Zf4K19bpWmPDhi98/ecFQEDcx22Z0Ok= To: gcc-cvs-wwwdocs@gcc.gnu.org Subject: gcc-wwwdocs branch master updated. 26e513cbcd050538bc40b8c53186024bdc2b413a X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 111b7b2cbf7269a060f9692a55353dfdf6fc0849 X-Git-Newrev: 26e513cbcd050538bc40b8c53186024bdc2b413a Message-Id: <20240116054818.239453858D1E@sourceware.org> Date: Tue, 16 Jan 2024 05:48:18 +0000 (GMT) From: Jason Merrill List-Id: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "gcc-wwwdocs". The branch, master has been updated via 26e513cbcd050538bc40b8c53186024bdc2b413a (commit) from 111b7b2cbf7269a060f9692a55353dfdf6fc0849 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 26e513cbcd050538bc40b8c53186024bdc2b413a Author: Jason Merrill Date: Thu Jan 11 16:10:43 2024 -0500 codingconventions: add lambda guidelines diff --git a/htdocs/codingconventions.html b/htdocs/codingconventions.html index f5a356a8..78ef472e 100644 --- a/htdocs/codingconventions.html +++ b/htdocs/codingconventions.html @@ -76,6 +76,7 @@ the conventions separately from any other changes to the code.

  • Templates
  • Extern "C"
  • Namespaces
  • +
  • Lambdas
  • @@ -1488,6 +1489,65 @@ with a right brace, optional closing comment, and a new line. Definitions within the body of a namespace are not indented.

    +

    Lambdas

    + +

    There should be a space between the lambda-introducer and the parameter + list, if any.

    +

    Lambdas that do not outlive their enclosing function should + typically use [&] implicit capture.

    + +
    auto l = [&] (tree arg) { ... };
    +
    + +

    If a lambda does not fit on one line, the left brace should be indented like +the body of a for-statement.

    + +
    auto l = [&] (tree arg)
    +  {
    +    ...
    +  };
    +
    + +

    This also applies if the lambda is the last argument, and only lambda +argument, to a function.

    + +
    std::for_each (start, end, [&] (tree arg)
    +  {
    +    ...
    +  });
    +
    + +To get the above behavior from + + GNU Emacs CC Mode, you can add this to your .emacs: + +
    (defun lambda-offset (elem)
    +  "If the opening brace of a lambda is on a new line, indent it one step."
    +  (if (assq 'inline-open c-syntactic-context) '+ 0))
    +(add-hook 'c++-mode-hook
    +	  '(lambda () (c-set-offset 'inlambda 'lambda-offset)))
    +
    + +

    If the multi-line lambda is not the last argument, or there are multiple +lambda arguments, you are encouraged to make them local variables, as +the l examples above. If you do pass them directly, they should +be indented like other parameters. + +

    my_algo (start, end,
    +	 [&] (tree arg)
    +           {
    +             thing one...
    +           },
    +	 [&] (tree arg)
    +           {
    +             thing two...
    +           });
    +
    + +

    See also the + + GDB coding standards.

    +

    Python Language Conventions

    Python scripts should follow PEP 8 – Style Guide for Python Code ----------------------------------------------------------------------- Summary of changes: htdocs/codingconventions.html | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) hooks/post-receive -- gcc-wwwdocs