Slide 1

Slide 1 text

Dart のこれから
 FlutterKaigi 2022 Day1


Slide 2

Slide 2 text

おかやまん / blendthink
 株式会社ゆめみ
 Android・Flutter テックリード
 将棋・プログラミング


Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Agenda
 01 近年、どのような進化を遂げてきたか 
 02 Dart の進化プロセス 
 03 仕様化を進めている新機能 
   ・Patterns and related features 
   ・Static Metaprogramming 
   ・Views on an object without a wrapper object 
   ・Sound declaration-site variance 
 04 おわりに


Slide 10

Slide 10 text

Agenda
 01 近年、どのような進化を遂げてきたか 
 02 Dart の進化プロセス 
 03 仕様化を進めている新機能 
   ・Patterns and related features 
   ・Static Metaprogramming 
   ・Views on an object without a wrapper object 
   ・Sound declaration-site variance 
 04 おわりに


Slide 11

Slide 11 text

bool isEmpty(String s) => s.length == 0; void main() { // Runtime error isEmpty(null); } Dart 2.12 - Null safety
 bool isEmpty(String s) => s.length == 0; void main() { // Compile-time error isEmpty(null); } 01 近年、どのような進化を遂げてきたか 
 https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md#2120---2021-03-03 


Slide 12

Slide 12 text

bool isEmpty(String s) => s.length == 0; void main() { // Runtime error isEmpty(null); } Dart 2.12 - Null safety
 bool isEmpty(String s) => s.length == 0; void main() { // Compile-time error isEmpty(null); } 01 近年、どのような進化を遂げてきたか 
 https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md#2120---2021-03-03 


Slide 13

Slide 13 text

class A { int x; A(this.x); A.fromString(String s) : x = int.parse(s); } void main() { final listOfInts = [1, 2, 3]; final listOfStrings = ["1", "2", "3"]; for(final a in listOfInts.map((x) => A(x))) { print(a.x); } for(final a in listOfStrings.map((x) => A.fromString(x))) { print(a.x); } } Dart 2.15 - Constructor tear-offs
 class A { int x; A(this.x); A.fromString(String s) : x = int.parse(s); } void main() { final listOfInts = [1, 2, 3]; final listOfStrings = ["1", "2", "3"]; for(final a in listOfInts.map(A.new)) { print(a.x); } for(final a in listOfStrings.map(A.fromString)) { print(a.x); } }
 01 近年、どのような進化を遂げてきたか 
 https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md#2150---2021-12-08 


Slide 14

Slide 14 text

class A { int x; A(this.x); A.fromString(String s) : x = int.parse(s); } void main() { final listOfInts = [1, 2, 3]; final listOfStrings = ["1", "2", "3"]; for(final a in listOfInts.map((x) => A(x))) { print(a.x); } for(final a in listOfStrings.map((x) => A.fromString(x))) { print(a.x); } } Dart 2.15 - Constructor tear-offs
 class A { int x; A(this.x); A.fromString(String s) : x = int.parse(s); } void main() { final listOfInts = [1, 2, 3]; final listOfStrings = ["1", "2", "3"]; for(final a in listOfInts.map(A.new)) { print(a.x); } for(final a in listOfStrings.map(A.fromString)) { print(a.x); } } 01 近年、どのような進化を遂げてきたか 
 https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md#2150---2021-12-08 


Slide 15

Slide 15 text

enum Status { success, failure } extension StatusToCode on Status { int get code { switch (this) { case Status.success: return 0; case Status.failure: return 1; } } } Dart 2.17 - Enhanced enums with members
 enum Status { success(0), failure(1); final int code; const Status(this.code); } 01 近年、どのような進化を遂げてきたか 
 https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md#2170---2022-05-11 


Slide 16

Slide 16 text

enum Status { success, failure } extension StatusToCode on Status { int get code { switch (this) { case Status.success: return 0; case Status.failure: return 1; } } } Dart 2.17 - Enhanced enums with members
 enum Status { success(0), failure(1); final int code; const Status(this.code); } 01 近年、どのような進化を遂げてきたか 
 https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md#2170---2022-05-11 


Slide 17

Slide 17 text

class CupertinoPage extends Page { const CupertinoPage({ required this.child, this.maintainState = true, this.title, this.fullscreenDialog = false, LocalKey? key, String? name, Object? arguments, String? restorationId, }) : super( key: key, name: name, arguments: arguments, restorationId: restorationId, ); // ... } Dart 2.17 - Super parameters
 class CupertinoPage extends Page { const CupertinoPage({ required this.child, this.maintainState = true, this.title, this.fullscreenDialog = false, super.key, super.name, super.arguments, super.restorationId, }); // ... } 01 近年、どのような進化を遂げてきたか 
 https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md#2170---2022-05-11 


Slide 18

Slide 18 text

class CupertinoPage extends Page { const CupertinoPage({ required this.child, this.maintainState = true, this.title, this.fullscreenDialog = false, LocalKey? key, String? name, Object? arguments, String? restorationId, }) : super( key: key, name: name, arguments: arguments, restorationId: restorationId, ); // ... } Dart 2.17 - Super parameters
 class CupertinoPage extends Page { const CupertinoPage({ required this.child, this.maintainState = true, this.title, this.fullscreenDialog = false, super.key, super.name, super.arguments, super.restorationId, }); // ... } 01 近年、どのような進化を遂げてきたか 
 https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md#2170---2022-05-11 


Slide 19

Slide 19 text

main() { test('A test description', () { // Very long function body here... }, skip: true); } Dart 2.17 - Named args everywhere
 main() { test(skip: true, 'A test description', () { // Very long function body here... }); } 01 近年、どのような進化を遂げてきたか 
 https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md#2170---2022-05-11 


Slide 20

Slide 20 text

main() { test('A test description', () { // Very long function body here... }, skip: true); } Dart 2.17 - Named args everywhere
 main() { test(skip: true, 'A test description', () { // Very long function body here... }); } 01 近年、どのような進化を遂げてきたか 
 https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md#2170---2022-05-11 


Slide 21

Slide 21 text

● Dart 2.18
 ○ Enhanced type inference for generic invocations with function literals 
 ● Dart 2.17
 ○ Enhanced enums with members
 ○ Super parameters
 ○ Named args everywhere
 ● Dart 2.15
 ○ Constructor tear-offs
 ○ Generic type literals
 ○ Explicit generic method instantiations
 ○ Generic instantiation of function objects
 ● Dart 2.14
 ○ Unsigned shift operator
 ○ Removed some restrictions on type arguments
 ● Dart 2.13
 ○ Non-function type aliases
 ● Dart 2.12
 ○ Null safety
 01 近年、どのような進化を遂げてきたか 
 https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md 


Slide 22

Slide 22 text

Agenda
 01 近年、どのような進化を遂げてきたか 
 02 Dart の進化プロセス 
 03 仕様化を進めている新機能 
   ・Patterns and related features 
   ・Static Metaprogramming 
   ・Views on an object without a wrapper object 
   ・Sound declaration-site variance 
 04 おわりに


Slide 23

Slide 23 text

Dart の言語チーム
 ※ 2020 年 6 月時点 
 leafpetersen 
 lrhn
 eernstg
 munificent
 natebosch
 jakemac53
 stereotype441 
 mit-mit
 02 Dart の進化プロセス 
 https://github.com/dart-lang/language/blob/master/README.md#dart-language-team 


Slide 24

Slide 24 text

機能が追加されるまでの流れ
 
 02 Dart の進化プロセス 
 https://github.com/dart-lang/language/blob/master/doc/life_of_a_language_feature.md 


Slide 25

Slide 25 text

機能が追加されるまでの流れ
 02 Dart の進化プロセス 
 https://github.com/dart-lang/language/issues/2534 


Slide 26

Slide 26 text

機能が追加されるまでの流れ
 02 Dart の進化プロセス 
 https://github.com/dart-lang/language/issues/2558 


Slide 27

Slide 27 text

機能が追加されるまでの流れ
 02 Dart の進化プロセス 
 https://github.com/dart-lang/language/projects/1 


Slide 28

Slide 28 text

機能が追加されるまでの流れ
 02 Dart の進化プロセス 
 ※ 2022 年 10 月時点 
 https://github.com/dart-lang/language/projects/1 


Slide 29

Slide 29 text

機能が追加されるまでの流れ
 02 Dart の進化プロセス 
 https://github.com/dart-lang/language/projects/1 
 https://github.com/dart-lang/language/blob/master/working/macros/feature-specification.md 


Slide 30

Slide 30 text

機能が追加されるまでの流れ
 02 Dart の進化プロセス 
 https://github.com/dart-lang/language/blob/master/accepted/2.14/triple-shift-operator/implementation-plan.md 
 https://github.com/dart-lang/language/blob/master/accepted/2.14/triple-shift-operator/feature-specification.md 
 https://github.com/dart-lang/language/issues/478 


Slide 31

Slide 31 text

機能が追加されるまでの流れ
 02 Dart の進化プロセス 


Slide 32

Slide 32 text

Agenda
 01 近年、どのような進化を遂げてきたか 
 02 Dart の進化プロセス 
 03 仕様化を進めている新機能 
   ・Patterns and related features 
   ・Static Metaprogramming 
   ・Views on an object without a wrapper object 
   ・Sound declaration-site variance 
 04 おわりに


Slide 33

Slide 33 text

Patterns and related features
 03 仕様化を進めている新機能 - Patterns and related features 
 https://github.com/dart-lang/language/projects/1 


Slide 34

Slide 34 text

Patterns and related features
 03 仕様化を進めている新機能 - Patterns and related features 
 https://github.com/dart-lang/language/issues/546 


Slide 35

Slide 35 text

コンセプト
 ● パターン
 ● パターンマッチング
 ● 網羅性
 ● 分割代入
 ● タプル
 ● 代数的データ型
 ● データクラス
 03 仕様化を進めている新機能 - Patterns and related features 


Slide 36

Slide 36 text

Record 機能 - 提案の動機
 03 仕様化を進めている新機能 - Patterns and related features 
 Future getPersonName() async => 'John'; Future getUnreadCount() async => 10; void main() async { // List final result = await Future.wait([ getPersonName(), getUnreadCount(), ]); final personName = result[0] as String; final unreadCount = result[1] as int; final lowOrHigh = unreadCount < 10 ? 'low' : 'high'; // John's unread count is high. print("$personName’s unread count is $lowOrHigh."); }

Slide 37

Slide 37 text

Record 機能 - 提案の動機
 03 仕様化を進めている新機能 - Patterns and related features 
 Future getPersonName() async => 'John'; Future getUnreadCount() async => 10; void main() async { // List final result = await Future.wait([ getPersonName(), getUnreadCount(), ]); final personName = result[0] as String; final unreadCount = result[1] as int; final lowOrHigh = unreadCount < 10 ? 'low' : 'high'; // John's unread count is high. print("$personName's unread count is $lowOrHigh."); }

Slide 38

Slide 38 text

Record 機能 - 提案の動機
 03 仕様化を進めている新機能 - Patterns and related features 
 Future getPersonName() async => 'John'; Future getUnreadCount() async => 10; void main() async { // List final result = await Future.wait([ getPersonName(), getUnreadCount(), ]); final personName = result[0] as String; final unreadCount = result[1] as int; final lowOrHigh = unreadCount < 10 ? 'low' : 'high'; // John's unread count is high. print("$personName's unread count is $lowOrHigh."); }

Slide 39

Slide 39 text

Record 機能 - 概要
 03 仕様化を進めている新機能 - Patterns and related features 
 var tuple = ("first", 2, true);
 var record = (number: 123, name: "Main", type: "Street"); var record = ("first", number: 123, 2, name: "Main", true, type: "Street");

Slide 40

Slide 40 text

Record 機能 - 概要
 03 仕様化を進めている新機能 - Patterns and related features 
 var record = (1, a: 2, 3, b: 4); print(record.$0); // Prints "1". print(record.a); // Prints "2". print(record.$1); // Prints "3". print(record.b); // Prints "4".

Slide 41

Slide 41 text

Record 機能 - 概要
 03 仕様化を進めている新機能 - Patterns and related features 
 var record = (1, a: 2, 3, b: 4); print(record.$0); // Prints "1". print(record.a); // Prints "2". print(record.$1); // Prints "3". print(record.b); // Prints "4".

Slide 42

Slide 42 text

Record 機能 - 概要
 03 仕様化を進めている新機能 - Patterns and related features 
 var record = (1, a: 2, 3, b: 4); print(record.$0); // Prints "1". print(record.a); // Prints "2". print(record.$1); // Prints "3". print(record.b); // Prints "4".

Slide 43

Slide 43 text

Record 機能 - 概要
 03 仕様化を進めている新機能 - Patterns and related features 
 var record = (1, a: 2, 3, b: 4); print(record.$0); // Prints "1". print(record.a); // Prints "2". print(record.$1); // Prints "3". print(record.b); // Prints "4".

Slide 44

Slide 44 text

Record 機能 - 注釈
 03 仕様化を進めている新機能 - Patterns and related features 
 (int, String name, bool) triple; ({int n, String s}) pair; (bool, num, {int n, String s}) quad;

Slide 45

Slide 45 text

Record 機能 - 注釈
 03 仕様化を進めている新機能 - Patterns and related features 
 (int, String name, bool) triple; ({int n, String s}) pair; (bool, num, {int n, String s}) quad;

Slide 46

Slide 46 text

Record 機能 - 注釈
 03 仕様化を進めている新機能 - Patterns and related features 
 (int, String name, bool) triple; ({int n, String s}) pair; (bool, num, {int n, String s}) quad;

Slide 47

Slide 47 text

Record 機能 - 注釈
 03 仕様化を進めている新機能 - Patterns and related features 
 (int, String name, bool) triple; ({int n, String s}) pair; (bool, num, {int n, String s}) quad;

Slide 48

Slide 48 text

Record 機能 - 注釈
 03 仕様化を進めている新機能 - Patterns and related features 
 (int, String name, bool) triple; ({int n, String s}) pair; (bool, num, {int n, String s}) quad;

Slide 49

Slide 49 text

Record 機能 - 注釈
 03 仕様化を進めている新機能 - Patterns and related features 
 @metadata (a, b) function() {}


Slide 50

Slide 50 text

Record 機能 - 注釈
 03 仕様化を進めている新機能 - Patterns and related features 
 @metadata (a, b) function() {}

Slide 51

Slide 51 text

Record 機能 - 注釈
 03 仕様化を進めている新機能 - Patterns and related features 
 @metadata (a, b) function() {}

Slide 52

Slide 52 text

Record 機能 - toString()
 03 仕様化を進めている新機能 - Patterns and related features 
 // デバッグビルド print((1, 2, 3).toString()); // "(1, 2, 3)". print((a: 'str', 'int').toString()); // "(a: str, int)".

Slide 53

Slide 53 text

Record 機能 - 等価性
 03 仕様化を進めている新機能 - Patterns and related features 
 var a = (x: 1, 2); var b = (2, x: 1); print(a == b); // true.

Slide 54

Slide 54 text

Record 機能 - with()
 03 仕様化を進めている新機能 - Patterns and related features 
 void main() { (int, int, {Color color}) x = (0, 1, color: Color.red); var x2 = x.with(7); // Just changes x[0]. var x3 = x.with(_, 3); // Just changes x[1]. var x4 = x.with(1: 3); // Also just changes x[1]. var x5 = x.with(color: Color.Blue); // Just changes x.color. }

Slide 55

Slide 55 text

Pattern 機能 - 提案の動機
 03 仕様化を進めている新機能 - Patterns and related features 
 void main() async { try { await fetchData(); } on SocketException { handleException(); } on TimeoutException { handleException(); } }

Slide 56

Slide 56 text

Pattern 機能 - 提案の動機
 03 仕様化を進めている新機能 - Patterns and related features 
 void main() async { try { await fetchData(); } on SocketException, TimeoutException { handleException(); } }

Slide 57

Slide 57 text

Pattern 機能 - 概要
 03 仕様化を進めている新機能 - Patterns and related features 
 パターンに関する基本的な考え方
 ● パターンが値と一致するかどうかを判断するために、ある値に対してテストすること ができる
 ● いくつかのパターンは、マッチした場合、マッチした値からデータを取り出すことに よって、マッチした値を再構築する
 ● 変数パターンは、マッチした値または非構造化された値に新しい変数をバインドす る。変数は、パターンがマッチしたときにのみ到達可能なコード領域内にスコープさ れる


Slide 58

Slide 58 text

Pattern 機能 - 概要
 03 仕様化を進めている新機能 - Patterns and related features 
 種類 例 論理和 subpattern1 | subpattern2 論理積 subpattern1 & subpattern2 関連 == expression, < expression キャスト foo as String null チェック subpattern? null アサート subpattern! 定数 123, null, 'string', math.pi, SomeClass.constant, const Thing(1, 2), const (1 + 2) 変数 foo, var bar, String str, _, int _ 括弧付き (subpattern) List [subpattern1, subpattern2] Map {"key": subpattern1, someConst: subpattern2} Record (subpattern1, subpattern2), (x: subpattern1, y: subpattern2) 抽出 SomeClass(x: subpattern1, y: subpattern2) https://github.com/dart-lang/language/blob/master/working/0546-patterns/patterns-feature-specification.md 


Slide 59

Slide 59 text

Pattern 機能 - 論理和パターン
 03 仕様化を進めている新機能 - Patterns and related features 
 var isPrimary = switch (color) { case Color.red | Color.yellow | Color.blue => true; default => false; };

Slide 60

Slide 60 text

Pattern 機能 - 論理和パターン
 03 仕様化を進めている新機能 - Patterns and related features 
 var isPrimary = switch (color) { case Color.red | Color.yellow | Color.blue => true; default => false; };

Slide 61

Slide 61 text

Pattern 機能 - 論理和パターン
 03 仕様化を進めている新機能 - Patterns and related features 
 switch (shape) { case Square(size: var s) | Circle(size: var s) when s > 0: print('Non-empty symmetric shape'); case Square() | Circle(): print('Empty symmetric shape'); default: print('Asymmetric shape'); }

Slide 62

Slide 62 text

Pattern 機能 - 論理和パターン
 03 仕様化を進めている新機能 - Patterns and related features 
 switch (shape) { case Square(size: var s) | Circle(size: var s) when s > 0: print('Non-empty symmetric shape'); case Square() | Circle(): print('Empty symmetric shape'); default: print('Asymmetric shape'); }

Slide 63

Slide 63 text

Pattern 機能 - 論理和パターン
 03 仕様化を進めている新機能 - Patterns and related features 
 switch (list) { // Matches a two-element list whose first element is 'a' or 'b': case ['a' | 'b', var c]: }

Slide 64

Slide 64 text

網羅性チェック - 概要
 03 仕様化を進めている新機能 - Patterns and related features 
 ● 網羅性
 
 
 ● 到達可能性
 switch (b) { case true: print('yes'); case false: print('no'); }
 switch (b) { case true: print('yes'); case false: print('no'); case bool b: print('unreachable'); }


Slide 65

Slide 65 text

Static Metaprogramming
 03 仕様化を進めている新機能 - Static Metaprogramming 
 https://github.com/dart-lang/language/projects/1 


Slide 66

Slide 66 text

Static Metaprogramming
 03 仕様化を進めている新機能 - Static Metaprogramming 
 https://github.com/dart-lang/language/issues/1482 


Slide 67

Slide 67 text

マクロ - 提案の動機
 03 仕様化を進めている新機能 - Static Metaprogramming 
 data class User(val name: String, val age: Int)


Slide 68

Slide 68 text

マクロ - 提案の動機
 03 仕様化を進めている新機能 - Static Metaprogramming 
 @immutable class User { const User({ required this.name, required this.age, }); final String name; final int age; @override bool operator ==(Object other) => other is User && other.runtimeType == runtimeType && other.name == name && other.age == age; @override int get hashCode => Object.hash( runtimeType, name, age, ); @override String toString() => 'User(' 'name=$name, ' 'age=$age' ')'; User copy({ String? name, int? age, }) => User( name: name ?? this.name, age: age ?? this.age, ); }

Slide 69

Slide 69 text

マクロ - 提案の動機
 03 仕様化を進めている新機能 - Static Metaprogramming 
 import 'package:freezed_annotation/freezed_annotation.dart'; part 'user.freezed.dart'; @freezed class User with _$User { const factory User({ required String name, required int age, }) = _User; }

Slide 70

Slide 70 text

マクロ - 概要
 03 仕様化を進めている新機能 - Static Metaprogramming 
 macro class DataClass implements ClassDeclarationsMacro, ClassDefinitionMacro { const DataClass(); @override Future buildDeclarationsForClass( ClassDeclaration clazz, ClassMemberDeclarationBuilder context) async { await Future.wait([ const AutoConstructor().buildDeclarationsForClass(clazz, context), const CopyWith().buildDeclarationsForClass(clazz, context), const HashCode().buildDeclarationsForClass(clazz, context), const Equality().buildDeclarationsForClass(clazz, context), const ToString().buildDeclarationsForClass(clazz, context), ]); } @override Future buildDefinitionForClass( ClassDeclaration clazz, ClassDefinitionBuilder builder) async { await Future.wait([ const HashCode().buildDefinitionForClass(clazz, builder), const Equality().buildDefinitionForClass(clazz, builder), const ToString().buildDefinitionForClass(clazz, builder), ]); } }

Slide 71

Slide 71 text

マクロ - 概要
 03 仕様化を進めている新機能 - Static Metaprogramming 
 macro class DataClass implements ClassDeclarationsMacro, ClassDefinitionMacro { const DataClass(); @override Future buildDeclarationsForClass( ClassDeclaration clazz, ClassMemberDeclarationBuilder context) async { await Future.wait([ const AutoConstructor().buildDeclarationsForClass(clazz, context), const CopyWith().buildDeclarationsForClass(clazz, context), const HashCode().buildDeclarationsForClass(clazz, context), const Equality().buildDeclarationsForClass(clazz, context), const ToString().buildDeclarationsForClass(clazz, context), ]); } @override Future buildDefinitionForClass( ClassDeclaration clazz, ClassDefinitionBuilder builder) async { await Future.wait([ const HashCode().buildDefinitionForClass(clazz, builder), const Equality().buildDefinitionForClass(clazz, builder), const ToString().buildDefinitionForClass(clazz, builder), ]); } }

Slide 72

Slide 72 text

マクロ - 概要
 03 仕様化を進めている新機能 - Static Metaprogramming 
 https://github.com/dart-lang/sdk/tree/main/pkg/_fe_analyzer_shared/lib/src/macros 


Slide 73

Slide 73 text

マクロ - 概要
 03 仕様化を進めている新機能 - Static Metaprogramming 
 https://github.com/dart-lang/language/tree/master/working/macros/example 


Slide 74

Slide 74 text

Views on an object without a wrapper object
 03 仕様化を進めている新機能 - Views on an object without a wrapper object 
 https://github.com/dart-lang/language/projects/1 


Slide 75

Slide 75 text

Views on an object without a wrapper object
 03 仕様化を進めている新機能 - Views on an object without a wrapper object 
 https://github.com/dart-lang/language/issues/1474 


Slide 76

Slide 76 text

View - 提案の動機
 03 仕様化を進めている新機能 - Views on an object without a wrapper object 
 ● 拡張メソッドのように、ラッパーオブジェクトなしで、ゼロコストで特定のオブジェクト を拡張したい
 ● ラッピングすることで、不適切な操作を禁止したり、回帰的な処理をより便利かつ安 全に実装したりしたい


Slide 77

Slide 77 text

View - 概要
 03 仕様化を進めている新機能 - Views on an object without a wrapper object 
 view class IdNumber(int i) { operator <(IdNumber other) => i < other.i; bool verify(Some parameters) => ...; }

Slide 78

Slide 78 text

View - 概要
 03 仕様化を進めている新機能 - Views on an object without a wrapper object 
 view class IdNumber(int i) { operator <(IdNumber other) => i < other.i; bool verify(Some parameters) => ...; }

Slide 79

Slide 79 text

View - 概要
 03 仕様化を進めている新機能 - Views on an object without a wrapper object 
 view class IdNumber(int i) { operator <(IdNumber other) => i < other.i; bool verify(Some parameters) => ...; }

Slide 80

Slide 80 text

View - 概要
 03 仕様化を進めている新機能 - Views on an object without a wrapper object 
 view class IdNumber(int i) { operator <(IdNumber other) => i < other.i; bool verify(Some parameters) => ...; } void main() { int myUnsafeId = 42424242; var safeId = IdNumber(42424242); safeId + 10; // Compile-time error 10 + safeId; // Compile-time error myUnsafeId = safeId; // Compile-time error }

Slide 81

Slide 81 text

View - 概要
 03 仕様化を進めている新機能 - Views on an object without a wrapper object 
 view class IdNumber(int i) { operator <(IdNumber other) => i < other.i; bool verify(Some parameters) => ...; } void main() { int myUnsafeId = 42424242; var safeId = IdNumber(42424242); safeId + 10; // Compile-time error 10 + safeId; // Compile-time error myUnsafeId = safeId; // Compile-time error }

Slide 82

Slide 82 text

Sound declaration-site variance
 03 仕様化を進めている新機能 - Sound declaration-site variance 
 https://github.com/dart-lang/language/projects/1 


Slide 83

Slide 83 text

Sound declaration-site variance
 03 仕様化を進めている新機能 - Sound declaration-site variance 
 https://github.com/dart-lang/language/issues/524 


Slide 84

Slide 84 text

提案の動機
 03 仕様化を進めている新機能 - Sound declaration-site variance 
 class Writer { void write(T x) => print(x); } void main() { Writer objectWriter = Writer(); // Runtime error objectWriter.write("I'm a string!"); }

Slide 85

Slide 85 text

提案の動機
 03 仕様化を進めている新機能 - Sound declaration-site variance 
 class Writer { void write(T x) => print(x); } void main() { Writer objectWriter = Writer(); // Runtime error objectWriter.write("I'm a string!"); }

Slide 86

Slide 86 text

概要
 03 仕様化を進めている新機能 - Sound declaration-site variance 
 class Writer { void write(T x) => print(x); } void main() { // Compile-time error Writer objectWriter = Writer(); objectWriter.write("I'm a string!"); }

Slide 87

Slide 87 text

概要
 03 仕様化を進めている新機能 - Sound declaration-site variance 
 class Writer { void write(T x) => print(x); } void main() { // Compile-time error Writer objectWriter = Writer(); objectWriter.write("I'm a string!"); }

Slide 88

Slide 88 text

概要
 03 仕様化を進めている新機能 - Sound declaration-site variance 
 https://github.com/dart-lang/language/pull/557 


Slide 89

Slide 89 text

Agenda
 01 近年、どのような進化を遂げてきたか 
 02 Dart の進化プロセス 
 03 仕様化を進めている新機能 
   ・Patterns and related features 
   ・Static Metaprogramming 
   ・Views on an object without a wrapper object 
   ・Sound declaration-site variance 
 04 おわりに


Slide 90

Slide 90 text

Dart の進化を支えている
 言語チームメンバーに感謝!


Slide 91

Slide 91 text

ご清聴ありがとうございました