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

Side by Side Diff: docs/newsletter/20170728.md

Issue 2989963002: Add first newsletter. (Closed)
Patch Set: Created 3 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Dart Language and Library Newsletter
2 2017-07-28
3 @floitschG
4
5 Welcome to the Dart Language and Library newsletter.
6
7 ## Introduction
8 In this, hopefully, regular newsletter, I will discuss topics the language/libra ry team spends time on. Some of the selected subjects are still under discussion and few decisions presented in this document are final. On the one hand this me ans that readers can't assume that the information is accurate, on the other han d it allows me to give better insights and talk about interesting subjects much earlier than if I waited for final decisions.
9
10 This newsletters is written from my personal perspective. Especially for activel y discussed topics, not all team-members always agree, and you might find differ ent opinions on the mailing lists. I will try to keep these conflicts to a minim um, but it is unlikely that I will be able to remove all personal bias.
11
12 ## If You Missed It
13 Dart 1.24 has been released some time ago. It included some nice changes to the languages. Here is a small description of the more important ones, in case you m issed them.
14
15 ### Function Types
16 We added a new way to write function types:
17 ``` dart
18 typedef F = void Function();
19
20 int foo(int Function(int) f) => f(499);
21 ```
22
23 The following text is a copy of the 1.24 Changelog entry:
24
25 > 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 o f `void foo() {}` would be `void Function()`. The new syntax may be used whereve r a type can be written. It is thus now possible to declare fields containing fu nctions without needing to write typedefs: `void Function() x;`.
26
27 > The new function type has one restriction: it may not contain the old-style fu nction-type syntax for its parameters. The following is thus illegal: `void Func tion(int f())`.
28
29 > `typedefs` have been updated to support this new syntax. Examples:
30 ``` dart
31 typedef F = void Function(); // F is the name for a `void` callback.
32 int Function(int) f; // A field `f` that contains an int->int function.
33
34 class A<T> {
35 // The parameter `callback` is a function that takes a `T` and returns
36 // `void`.
37 void forEach(void Function(T) callback);
38 }
39
40 // The new function type supports generic arguments.
41 typedef Invoker = T Function<T>(T Function() callback);
42 ```
43
44 While a possibility, we haven't yet decided if we want to deprecate the old synt ax. On the other end of the spectrum, we haven't yet decided if we want to allow the old-style syntax within the `Function` syntax. (Feedback welcome).
45
46 We have plans to change the semantics of old-style function types when there is only one identifier for the argument. For example, `typedef F(int);` is currentl y a typedef for a function that takes `dynamic`. The new syntax gets this right: `typedef F = Function(int);` correctly makes this a typedef for a function that takes `int`.
47
48 We can't make this change (from argument-name to type-name) in one go. Instead, we want to deprecate and disallow the one-identifier syntax (making `typedef F(i nt)` illegal) first, and then, at a later point, change the behavior to read it as a type.
49
50 Here is an informal spec for the function syntax change:
51 https://gist.github.com/eernstg/ffc7bd281974e9018f10f0cb6cfee4aa
52
53 ### Void Changes
54 Dart 1.24 came with two changes on how we handle `void`.
55
56 1. `void` arrow functions may now have non-void expressions on the right-hand si de. This is purely for convenience. For example, users can now write:
57 ``` dart
58 void foo() => x++;
59 void set bar(v) => _bar = v;
60 ```
61
62 We still need to update the style guide (which is currently recommending curly b races for `void` functions).
63
64 2. in checked mode, `void` does not require the value to be `null` anymore. This was a prerequisite for (1), but was necessary for independent reasons. Dart all ows void functions to be subclassed with non-void functions, and it was thus har d to guarantee that `void` always became `null`.
65
66 ``` dart
67 class A {
68 void foo() { ... }
69 }
70 class B extends A {
71 int foo() { ... }
72 }
73
74 // In the function, `a` could be a `B` and thus return an `int` from the
75 // `foo` call. With the old behavior the function would then throw in checked mode.
76 void bar(A a) => a.foo();
77 ```
78 Now this is not a problem anymore.
79
80 ## Progress
81 The Dart team is currently doing big refactorings to migrate towards a unified f ront-end. In the long run this reduces code duplication and provides a more unif ied experience. For example, the errors and warnings of all our tools will be th e same. At the same time, it will make it easier to do language changes that req uire front-end support (which is the case for almost every language change).
82
83 This means that it is currently a bad timing to do language changes: not only ar e we spending resources on front-ends that will eventually disappear, but most t ools are currently in refactoring mode, where things change rapidly and conflict ing merges are common. For these reasons, the team focuses on areas that are eit her high priority, or don't need (lots of) front-end changes.
84
85 ## Under Active Development
86 This section summarizes areas we are actively working on.
87
88 ### Better Organization
89 The Dart team produces lots of documents (proposals, ...). So far, we didn't do a good job in collecting them and organizing them. It was not always clear which document was the most recent or agreed upon. We want to do a better job there.
90
91 As a first step, we will focus our attention on `docs/language` in the SDK repo. Every feature we agreed on, should have a document there. Since updating the ac tual spec is very time consuming, we use an `informal` folder for specifications that aren't yet integrated into the specification.
92
93 We will also be more aggressive in writing separate specs of features that aren' t planned for immediate implementation, or store documents that aren't completel y finished, yet.
94
95 ### Resolved part-of
96 Resolved "part of"s have been implemented. (http://dartbug.com/20792)
97
98 In future versions of the Dart SDK it will be possible to use a URI to refer bac k from a part to its library:
99 ``` dart
100 part of "myLibrary.dart";
101 ```
102
103 ### Make Zones strong-mode clean.
104 A lot of work went into making `Zone`s strong-mode clean. This work was gated on having generic function types (and a syntax for it). With the new function-type syntax, this was made possible. For example, the `RunHandler` typedef is now:
105 ``` dart
106 typedef RunHandler =
107 R Function<R>(Zone self, ZoneDelegate parent, Zone zone, R Function() f);
108 ```
109
110 Unfortunately, this is a breaking change, and some code needs to be updated. We have patches for most of the packages that are affected (often in a separate bra nch as for the `pool` package: https://github.com/dart-lang/pool/tree/zone.stron g). If your code uses zones (especially creating new `ZoneSpecification`s), feel free to reach out to me to prepare for the upcoming change.
111
112 ### Void as a Type.
113 We want to allow `void` as a type also in some situations where it is not a retu rn type. In particular, we want to make it possible to write `Future<void>`. Thi s will have two important consequences:
114 1. Users can express their intent in a better way than with `Future<Null>`. Not only is `Future<Null>` not expressing the intended behavior, it is also assignab le to *every* other `Future` (since `Null` is now at the bottom of the hierarchy ). This is the exact opposite of what users want when they don't have a value.
115 2. The type inference will be able to infer `void`. We have seen this fail most often in cases, where the argument to a function uses the return-type of an argu ment for inference. For example, `zone.run(voidFunction)`.
116
117 The exact details are still under development, but this feature is very high on our priority list, and we have made some progress on it.
118
119 ### Enhanced Type Promotion
120 Dart uses `is` expressions in `if` conditions to promote the type of a variable within the corresponding branch: `if (x is String) { x.toUpperCase(); }`.
121
122 We found that the current promotion is very useful, but misses lots of common ca ses. For example, `if (x is! A) throw "not an A";` would not promote `x` to be a n `A` in the rest of the body.
123
124 Since the analyzer already had its own, more advanced, type promotion we reached out to the analyzer team, and @bwilkerson wrote a proposal (thanks!). We have b een discussing this proposal in a pull request: https://github.com/dart-lang/sdk /pull/29624
125
126 ### Updates to the Core Libraries
127 As part of our OKRs we want to clean up the core libraries. This includes, depre cating some rarely used classes/methods, and adding functionality that should ha ve been there in the first place.
128
129 This is still work in progress, and we don't have a list of planned changes yet, but here are some that are likely to make the cut:
130 * Add a `BigInt` class to `dart:typed_data`. In Dart 2.0, integers will be fixed -sized, and this class provides a way to migrate code that relies on arbitrary-s ize integers.
131 * Deprecate `SplayTreeMap`, `SplayTreeSet`, `DoubleLinkedQueue` and `DoubleLinke dList`. We are going to copy these classes to the `collection` package to ease t he migration.
132
OLDNEW
« 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