Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: CHANGELOG.md

Issue 2906453002: Add a changelog entry for the function-type syntax. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: CHANGELOG.md
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8031041231dbc39b2cbccba7a22ac517a555df62..7b8a311652b5465c17645a4d3e494473a5258dd9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,30 @@
type `void` now allows the returned expression to have any type. For example,
assuming the declaration `int x;`, it is now type correct to have
`void f() => ++x;`.
+* A new function-type syntax has been added to the language.
+ Intuitively, the type of a function can be constructed by textually replacing
+ the function's name with `Function` in its declaration. For instance, the
+ type of `void foo() {}` would be `void Function()`. The new syntax may be used
+ wherever a type can be written. It is thus now possible to declare fields
+ containing functions without needing to write typedefs: `void Function() x;`.
+ The new function type has one restriction: it may not contain the old-style
+ function-type syntax for its parameters. The following is thus
+ illegal: `void Function(int f())`.
+ `typedefs` have been updated to support this new syntax.
+ Examples:
+ ```
+ typedef F = void Function(); // F is the name for a `void` callback.
+ int Function(int) f; // A field `f` that contains an int->int function.
+
+ class A<T> {
+ // The parameter `callback` is a function that takes a `T` and returns
+ // `void`.
+ void forEach(void Function(T) callback);
+ }
+
+ // The new function type supports generic arguments.
+ typedef Invoker = T Function<T>(T Function() callback);
+ ```
#### Strong Mode
@@ -24,6 +48,7 @@ entirely to allow inference to fill in the type.
* The following is also a change in strong mode: During static analysis, a
function or setter declared using `=>` with return type `void` now allows the
returned expression to have any type.
+* The new function-type syntax is also supported by strong mode.
### Core library changes
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698