Title: [252395] trunk/Websites/webkit.org
Revision
252395
Author
[email protected]
Date
2019-11-13 01:25:17 -0800 (Wed, 13 Nov 2019)

Log Message

Add punctuation rules for C++ lambdas
https://bugs.webkit.org/show_bug.cgi?id=204021

Reviewed by Zalan Bujtas.

Added rules for not putting spaces between [] and () and omitting () whenever possible for C++ lambdas.

* code-style.md:

Modified Paths

Diff

Modified: trunk/Websites/webkit.org/ChangeLog (252394 => 252395)


--- trunk/Websites/webkit.org/ChangeLog	2019-11-13 08:45:17 UTC (rev 252394)
+++ trunk/Websites/webkit.org/ChangeLog	2019-11-13 09:25:17 UTC (rev 252395)
@@ -1,3 +1,14 @@
+2019-11-08  Ryosuke Niwa  <[email protected]>
+
+        Add punctuation rules for C++ lambdas
+        https://bugs.webkit.org/show_bug.cgi?id=204021
+
+        Reviewed by Zalan Bujtas.
+
+        Added rules for not putting spaces between [] and () and omitting () whenever possible for C++ lambdas.
+
+        * code-style.md:
+
 2019-10-26  Chris Lord  <[email protected]>
 
         Put OffscreenCanvas behind a build flag

Modified: trunk/Websites/webkit.org/code-style.md (252394 => 252395)


--- trunk/Websites/webkit.org/code-style.md	2019-11-13 08:45:17 UTC (rev 252394)
+++ trunk/Websites/webkit.org/code-style.md	2019-11-13 09:25:17 UTC (rev 252395)
@@ -234,6 +234,22 @@
 f( a, b );
 ```
 
+[](#spacing-lambda-paren) Do not place spaces between square brackets and parentheses of a lambda function but do place a space before braces.
+
+###### Right:
+
+```cpp
+[](int x) { return x; }
+[this] { return m_member; }
+```
+
+###### Wrong:
+
+```cpp
+[] (int x) { return x; }
+[this]{ return m_member; }
+```
+
 [](#spacing-braced-init) When initializing an object, place a space before the leading brace as well as between the braces and their content.
 
 ###### Right:
@@ -881,6 +897,22 @@
     (*it)->updateLayoutAndStyleIfNeededRecursive();
 ```
 
+[](#punctuation-omit-lambda-paren) Omit parentheses for a C++ lambda whenever possible.
+
+###### Right:
+
+```cpp
+[this] { return m_member; }
+[this]() mutable { return doWork(WTFMove(m_object)); }
+```
+
+###### Wrong:
+
+```cpp
+[this]() { return m_member; }
+[]() { return static_cast<unsigned>(-1); }
+```
+
 ### Pointers and References
 
 [](#pointers-non-cpp) **Pointer types in non-C++ code**
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to