View
4
Download
1
Category
Preview:
Citation preview
Perl 6 TodayPugs - An implementation of Perl 6
Perl 6 - Reconciling the Irreconcilable
Au!ey Tang1
PugsAn implementation of
Perl6鳳たん
2
Pugs自分を信じ、好きを貫け
Perl6の実装
訳: 竹迫良範 / 小飼弾
(Perl5の粗探ししてる暇があったら自分で何かやれ)
3
≝4
Pugsとは...(定義)
5
Pugsとは...(定義)
≝ Perl6コンパイラ
5
Pugsとは...(定義)
≝ Perl6コンパイラ
≝ Perl6ランタイム
5
Pugsとは...(定義)
≝ Perl6コンパイラ
≝ Perl6ランタイム
≝ Perl6テストスイート
5
6
7
8
9
✓10
Perl6のコード
11
Perl6のコード
✓ 130以上のモジュール
11
Perl6のコード
✓ 130以上のモジュール
✓ 160以上の実例
11
Perl6のコード
✓ 130以上のモジュール
✓ 160以上の実例
✓ 20,000を超えるテスト
11
“公式な”Perl6
12
“公式な”Perl6
✓ 過去のしがらみを捨てて、セマンティックで再定義
12
“公式な”Perl6
✓ 過去のしがらみを捨てて、セマンティックで再定義
✓ テストスイートとの互換性(JavaTest/TCK参照)
12
⇚15
1995年代のPerl
16
• use5.000;
1995年代のPerl
16
• use5.000;• require'fastcwd.pl';
1995年代のPerl
16
• use5.000;• require'fastcwd.pl';• require'newgetopt.pl';
1995年代のPerl
16
• use5.000;• require'fastcwd.pl';• require'newgetopt.pl';• require'exceptions.pl';
1995年代のPerl
16
2005年代のPerl
17
• use v6-alpha;
2005年代のPerl
17
• use v6-alpha;• use perl5:DBI;
2005年代のPerl
17
• use v6-alpha;• use perl5:DBI;• use perl5:Encode <encode decode>;
2005年代のPerl
17
• use v6-alpha;• use perl5:DBI;• use perl5:Encode <encode decode>;• use perl5:Template;
2005年代のPerl
17
• use v6-alpha;• use perl5:DBI;• use perl5:Encode <encode decode>;• use perl5:Template;•
# Implementation of "crypt"sub crypt ($text, $salt) {
2005年代のPerl
17
• use v6-alpha;• use perl5:DBI;• use perl5:Encode <encode decode>;• use perl5:Template;•
# Implementation of "crypt"sub crypt ($text, $salt) {
• eval 'crypt($text, $salt)' :lang<perl5>;}
2005年代のPerl
17
ハイブリッド式実行エンジン
Pugs
Pugs::RuntimePugs::CompilerPugs::Grammar
Pugs.EvalPugs.Prim
Pugs.Types
Perl 5
Runtime
GHC
Runtime
18
ハイブリッド式実行エンジン
⇚ Perl5Pugs
Pugs::RuntimePugs::CompilerPugs::Grammar
Pugs.EvalPugs.Prim
Pugs.Types
Perl 5
Runtime
GHC
Runtime
18
ハイブリッド式実行エンジン
⇚ Perl5
⇚ Haskell
Pugs
Pugs::RuntimePugs::CompilerPugs::Grammar
Pugs.EvalPugs.Prim
Pugs.Types
Perl 5
Runtime
GHC
Runtime
18
ハイブリッド式実行エンジン
⇚ Perl5
⇚ Haskell
⇚ C(.so/.dll)
Pugs
Pugs::RuntimePugs::CompilerPugs::Grammar
Pugs.EvalPugs.Prim
Pugs.Types
Perl 5
Runtime
GHC
Runtime
18
⇛19
PILPugs中間言語
20
コンパイルの流れ
21
コンパイルの流れpugs/src/perl6/Perl‐6.0.0‐STD.pm
21
Pugs
JavaScript
Haskell Perl 5
バックエンド
22
Pugs
JavaScript
Haskell Perl 5
YARV?JVM?
CLR? PyPy?
バックエンド
23
Perl5バックエンド
Augmentation (XS)PadWalker, Devel::Caller
autobox, re::override ...
SemanticsData::Bind, Class::MOP
Pugs::Runtime, Pugs::Compiler::Rule ...
Perl 5 SugarMoose, Moose::Autobox ...
Syntaxv6.pm
Pugs::Compiler::Perl6 ...
Core
perl
Tool SupportCPAN, PAUSE
Perldoc, Perl::Tidy ...
!"#$%&
'()&*+,&-"#%
.&*%!/01!2.34!1"#56
InfrastructureParse::Yapp
Module::Compile ...
24
Perl5バックエンド
⇛ P5VMの増強
Augmentation (XS)PadWalker, Devel::Caller
autobox, re::override ...
SemanticsData::Bind, Class::MOP
Pugs::Runtime, Pugs::Compiler::Rule ...
Perl 5 SugarMoose, Moose::Autobox ...
Syntaxv6.pm
Pugs::Compiler::Perl6 ...
Core
perl
Tool SupportCPAN, PAUSE
Perldoc, Perl::Tidy ...
!"#$%&
'()&*+,&-"#%
.&*%!/01!2.34!1"#56
InfrastructureParse::Yapp
Module::Compile ...
24
Perl5バックエンド
⇛ P5VMの増強
⇛ Perl6をPerl5に配置Augmentation (XS)PadWalker, Devel::Caller
autobox, re::override ...
SemanticsData::Bind, Class::MOP
Pugs::Runtime, Pugs::Compiler::Rule ...
Perl 5 SugarMoose, Moose::Autobox ...
Syntaxv6.pm
Pugs::Compiler::Perl6 ...
Core
perl
Tool SupportCPAN, PAUSE
Perldoc, Perl::Tidy ...
!"#$%&
'()&*+,&-"#%
.&*%!/01!2.34!1"#56
InfrastructureParse::Yapp
Module::Compile ...
24
Perl5バックエンド
⇛ P5VMの増強
⇛ Perl6をPerl5に配置
⇛ Moose.pmはCPANにAugmentation (XS)PadWalker, Devel::Caller
autobox, re::override ...
SemanticsData::Bind, Class::MOP
Pugs::Runtime, Pugs::Compiler::Rule ...
Perl 5 SugarMoose, Moose::Autobox ...
Syntaxv6.pm
Pugs::Compiler::Perl6 ...
Core
perl
Tool SupportCPAN, PAUSE
Perldoc, Perl::Tidy ...
!"#$%&
'()&*+,&-"#%
.&*%!/01!2.34!1"#56
InfrastructureParse::Yapp
Module::Compile ...
24
Perl5バックエンド
⇛ P5VMの増強
⇛ Perl6をPerl5に配置
⇛ Moose.pmはCPANにAugmentation (XS)PadWalker, Devel::Caller
autobox, re::override ...
SemanticsData::Bind, Class::MOP
Pugs::Runtime, Pugs::Compiler::Rule ...
Perl 5 SugarMoose, Moose::Autobox ...
Syntaxv6.pm
Pugs::Compiler::Perl6 ...
Core
perl
Tool SupportCPAN, PAUSE
Perldoc, Perl::Tidy ...
!"#$%&
'()&*+,&-"#%
.&*%!/01!2.34!1"#56
InfrastructureParse::Yapp
Module::Compile ...
24
JavaScriptバックエンド
25
JavaScriptバックエンド
⇛ GWT,Hop,Linksとか...
25
JavaScriptバックエンド
⇛ GWT,Hop,Linksとか...
⇛ 90%のテストを通過
25
JavaScriptバックエンド
⇛ GWT,Hop,Linksとか...
⇛ 90%のテストを通過
⇛遅い‐JS2/Tamarin狙い
25
䷗26
6.0最初のリリース
䷁
27
6.2関数
䷗
28
6.28オブジェクト
䷒
29
6.283文法
䷊
30
6.2831型
䷡
31
6.28318マクロ
䷪
32
6.283185自分自身を実装
䷀
33
2π
Perl 6!☯
34
≠35
“ふざけたおもちゃのインタプリタ”(スラドの住人曰く)
36
“ふざけたおもちゃのインタプリタ”
37
“ふざけたおもちゃのインタプリタ”
38
“おもちゃのインタプリタ”
39
“おもちゃのインタプリタ”
40
“おもちゃ”
41
-Ofun42
☺43
矢印の長さ
時間
15800以上のコミット
300以上のコミッター
44
テスト駆動
45
テスト駆動
☺バグ報告➟テスト
45
テスト駆動
☺バグ報告➟テスト
☺スモークサーバ(smokeserv.pl)
45
テスト駆動
☺バグ報告➟テスト
☺スモークサーバ(smokeserv.pl)
☺:todo<unspecced>
45
ウィキ的な開発スタイル
46
ウィキ的な開発スタイル
☺10以上の言語
46
ウィキ的な開発スタイル
☺10以上の言語
☺30超のサブプロジェクト
46
ウィキ的な開発スタイル
☺10以上の言語
☺30超のサブプロジェクト
☺積極的な求人活動
46
パッチ大歓迎!
47
パッチ大歓迎!
47
コミット大歓迎!
48
✆49
irc.freenode.net#perl6
50
λ駱駝(ラムラクダ)達
51
λ駱駝(ラムラクダ)達
✆ 200人以上の仲間たち
51
λ駱駝(ラムラクダ)達
✆ 200人以上の仲間たち✆ IRC中毒/常駐者20人超
51
λ駱駝(ラムラクダ)達
✆ 200人以上の仲間たち✆ IRC中毒/常駐者20人超✆ TimToady++(ラリー)
51
svnbot6(ボット)
52
specbot6(ボット)
53
evalbot6(ボット)
54
devbot6(ボット)
55
lambdabot(λボット)
56
IRC.pugscode.org
57
Run.pugscode.org
58
Dev.pugscode.org
59
Invite.pugscode.org
60
Smoke.pugscode.org
61
Spec.pugscode.org
62
Blog.pugscode.org
63
メーリングリスト
64
メーリングリスト
✆ perl6‐users
64
メーリングリスト
✆ perl6‐users
✆ perl6‐language
64
メーリングリスト
✆ perl6‐users
✆ perl6‐language
✆ perl6‐compiler
64
ソースコードリポジトリ
65
http://svn.pugscode.org/pugs/
ソースコードリポジトリ
65
http://svn.pugscode.org/pugs/
http://darcs.pugscode.org/pugs/
ソースコードリポジトリ
65
http://svn.pugscode.org/pugs/
http://darcs.pugscode.org/pugs/
SVK
ソースコードリポジトリ
65
♨66
私は放浪の数学者エルデシュのように
67
私は放浪の数学者エルデシュのように
♨ 2006..*
67
ハッカソン
68
ハッカソン♨ 台北
68
ハッカソン♨ 台北
♨ ウィーン
68
ハッカソン♨ 台北
♨ ウィーン
♨ トロント
68
ハッカソン♨ 台北
♨ ウィーン
♨ トロント
♨ アムステルダム
68
ハッカソン♨ 台北
♨ ウィーン
♨ トロント
♨ アムステルダム
♨ エクト
68
ハッカソン♨ 台北
♨ ウィーン
♨ トロント
♨ アムステルダム
♨ エクト
♨ リスモア
68
ハッカソン♨ 台北
♨ ウィーン
♨ トロント
♨ アムステルダム
♨ エクト
♨ リスモア
♨ Mt.アベル
68
ハッカソン♨ 台北
♨ ウィーン
♨ トロント
♨ アムステルダム
♨ エクト
♨ リスモア
♨ Mt.アベル
♨ ウィーン再び
68
ハッカソン♨ 台北
♨ ウィーン
♨ トロント
♨ アムステルダム
♨ エクト
♨ リスモア
♨ Mt.アベル
♨ ウィーン再び
♨ 東京
68
ハッカソン♨ 台北
♨ ウィーン
♨ トロント
♨ アムステルダム
♨ エクト
♨ リスモア
♨ Mt.アベル
♨ ウィーン再び
♨ 東京
♨ レドモンドTM
68
ハッカソン♨ 台北
♨ ウィーン
♨ トロント
♨ アムステルダム
♨ エクト
♨ リスモア
♨ Mt.アベル
♨ ウィーン再び
♨ 東京
♨ レドモンドTM
♨ シカゴ
68
ハッカソン♨ 台北
♨ ウィーン
♨ トロント
♨ アムステルダム
♨ エクト
♨ リスモア
♨ Mt.アベル
♨ ウィーン再び
♨ 東京
♨ レドモンドTM
♨ シカゴ
♨ ボストン
68
ハッカソン♨ 台北
♨ ウィーン
♨ トロント
♨ アムステルダム
♨ エクト
♨ リスモア
♨ Mt.アベル
♨ ウィーン再び
♨ 東京
♨ レドモンドTM
♨ シカゴ
♨ ボストン
♨ ポートランド
68
ハッカソン♨ 台北
♨ ウィーン
♨ トロント
♨ アムステルダム
♨ エクト
♨ リスモア
♨ Mt.アベル
♨ ウィーン再び
♨ 東京
♨ レドモンドTM
♨ シカゴ
♨ ボストン
♨ ポートランド
♨ サンパウロ
68
ハッカソン♨ 台北
♨ ウィーン
♨ トロント
♨ アムステルダム
♨ エクト
♨ リスモア
♨ Mt.アベル
♨ ウィーン再び
♨ 東京
♨ レドモンドTM
♨ シカゴ
♨ ボストン
♨ ポートランド
♨ サンパウロ
♨ 東京再び
68
ハッカソン♨ 台北
♨ ウィーン
♨ トロント
♨ アムステルダム
♨ エクト
♨ リスモア
♨ Mt.アベル
♨ ウィーン再び
♨ 東京
♨ レドモンドTM
♨ シカゴ
♨ ボストン
♨ ポートランド
♨ サンパウロ
♨ 東京再び
♨ マウンテンビュー!
68
ハッカソン♨ 台北
♨ ウィーン
♨ トロント
♨ アムステルダム
♨ エクト
♨ リスモア
♨ Mt.アベル
♨ ウィーン再び
♨ 東京
♨ レドモンドTM
♨ シカゴ
♨ ボストン
♨ ポートランド
♨ サンパウロ
♨ 東京再び
♨ マウンテンビュー!
68
Perl6 Reconciling theIrreconcilable
鳳たん69
Perl6 または、私はいかにして
耐え難きを耐え
結び難きを結んだか
訳: 竹迫良範 / 小飼弾
70
ℙ71
Practical実践編
72
Unixの世界 (1987)
ShellC
73
新しい次元が誕生
C
Shell
74
Manipulexity (複殺)
C がまだ良かった頃...
C
Shell
75
Manipulexity (複殺)
Shell がまだ良かった頃...
C
Shell
Whipuptitude (殺速)
76
!"#$
Manipulexity (複殺)
Perl が誕生!
C
Shell
Whipuptitude (殺速)
77
!"#$%!
Manipulexity (複殺)
進化のためのデザイン...
C
Shell
Whipuptitude (殺速)
78
!"#$%!
Manipulexity (複殺)
そして進化の道を歩む...
C
Shell
Whipuptitude (殺速)
79
!"#$%!
Manipulexity (複殺)
さらに進化、どんどん進化...
C
Shell
Whipuptitude (殺速)
80
!"#$%!
Manipulexity (複殺)
キミタチのプログラムはすべて我々がいただいた...
C
Shell
Whipuptitude (殺速)
81
!"#$%!
Manipulexity (複殺)
キミタチのプログラムはすべて我々がいただいた...
C
Shell
Whipuptitude (殺速)
681
∀82
抽象化は
➥セクシー
83
クロージャsubmake_counter{my$start=shift;returnsub{++$start};}my$from_three=make_counter(3);print$from_three‐>();#4print$from_three‐>();#5
my$from_ten=make_counter(10);print$from_ten‐>();#11print$from_ten‐>();#12
84
多段評価
BEGIN{print"Compile‐time";eval$generated_code;print'Stillincompiletime";}print"Normalruntime";eval$more_generated_code;
85
実行時の型変換
my$piece=Pawn‐>new;bless$piece=>Queen;
86
S87
省略表現は
➥自然に
88
コンテキスト
#Scalarvs.Listcontext
my$one=<STDIN>;#Readonelinemy@all=<STDIN>;#Readalllines
#Stringvs.Numericcontext
print"Lines:@all"if@all<10;
89
鯛じゃなくてTie変数
tiemy%search=>'Tie::Google';print$search{'PerlPugs'}[0]{URL};#http://www.pugscode.org/
90
正規表現
#DeCSS.pls''$/=\2048;while(<>){G=29;R=142;if((@a=unqT="C*",_)[20]&48){D=89;_=unqb24,qT,@b=map{ordqB8,unqb8,qT,_^$a[‐‐D]}@INC;s/...$/1$&/;Q=unqV,qb25,_;H=73;O=$b[4]<<9|256|$b[3];Q=Q>>8^(P=(E=255)&(Q>>12^Q>>4^Q/8^Q))<<17,O=O>>8^(E&(F=(S=O>>14&7^O)^S*8^S<<6))<<9,_=(map{U=_%16orE^=R^=110&(S=(unqT,"\xb\ntd\xbz\x14d")[_/16%8]);E^=(72,@z=(64,72,G^=12*(U‐2?0:S&17)),H^=_%64?12:0,@z)[_%8]}(16..271))[_]^((D>>=8)+=P+(~F&E))for@a[128..$#a]}print+qT,@a}';s/[D‐HO‐U_]/\$$&/g;s/q/pack+/g;eval
91
♡92
最高のコーディング
➥無コーディング
93
94
CPAN
95
♡ 11年の蓄積
CPAN
95
♡ 11年の蓄積
♡ 5791人を超える開発者
CPAN
95
♡ 11年の蓄積
♡ 5791人を超える開発者
♡ 11400以上のモジュール
CPAN
95
サービス群
96
♡ パッケージ管理
サービス群
96
♡ パッケージ管理
♡ 評判&掲示板(Ratings)
サービス群
96
♡ パッケージ管理
♡ 評判&掲示板(Ratings)
♡ スモークテスト(CPANTS)
サービス群
96
♡ パッケージ管理
♡ 評判&掲示板(Ratings)
♡ スモークテスト(CPANTS)
♡ バグ管理システム(RT)
サービス群
96
語彙≩構文
97
“Perlは今までで最高の道具でした”
98
しかし...
99
Perl 5は CPANにとって最高の道具ではありませんでした
100
☣101
構文大杉
☣102
103
• usev5;
103
• usev5;• subrender{
103
• usev5;• subrender{• my$self=shift;
103
• usev5;• subrender{• my$self=shift;• my%opts=(x=>1,y=>1,z=>0,%{$_[0]});
103
• usev5;• subrender{• my$self=shift;• my%opts=(x=>1,y=>1,z=>0,%{$_[0]});• formy$item($self‐>filter(@{$self‐>{items}})){
103
• usev5;• subrender{• my$self=shift;• my%opts=(x=>1,y=>1,z=>0,%{$_[0]});• formy$item($self‐>filter(@{$self‐>{items}})){• print$item‐>draw({
x=>$opts{x},y=>$opts{y},z=>$opts{z},}),"\n";
103
• usev5;• subrender{• my$self=shift;• my%opts=(x=>1,y=>1,z=>0,%{$_[0]});• formy$item($self‐>filter(@{$self‐>{items}})){• print$item‐>draw({
x=>$opts{x},y=>$opts{y},z=>$opts{z},}),"\n";
• }}
103
104
• usev6‐alpha;
104
• usev6‐alpha;• methodrender($x=1,$y=1,$z=0){
104
• usev6‐alpha;• methodrender($x=1,$y=1,$z=0){•for@.filter(@.items){
104
• usev6‐alpha;• methodrender($x=1,$y=1,$z=0){•for@.filter(@.items){•say.draw(:$x,:$y,:$z);
}}
104
中身はジェンガ☣
105
106
やっかいなバグと後方互換性
。・゚・(ノД`)
107
ベストプラクティスには
規律が不可欠
108
Prescription(処方箋)
109
Prescription(処方箋)
109
ベストプラクティスは
自然体であるべき!
110
⑥111
2000RFCs
112
2001Parrot
113
2002Apocalypses
(黙示録)
114
2003(故)Ponie
115
2004Synopses
(ようやく要約)
116
2005Pugs
117
2006v6‐alpha
118
2007v6‐std
119
120
120
☯121
結び難きを結び
122
静的型vs
動的型
123
型☺
124
タイピング
☹125
静的型(C++,OCaml...)
126
☯効率的Efficient
静的型(C++,OCaml...)
126
☯効率的Efficient
☯頑丈Robust
静的型(C++,OCaml...)
126
☯効率的Efficient
☯頑丈Robust
静的型(C++,OCaml...)
動的型(Python,Ruby,...)
126
☯効率的Efficient
☯頑丈Robust
☯生産性Productive
静的型(C++,OCaml...)
動的型(Python,Ruby,...)
126
☯効率的Efficient
☯頑丈Robust
☯生産性Productive
☯臨機応変Flexible
静的型(C++,OCaml...)
動的型(Python,Ruby,...)
126
段々型め
アノテーションと型推論による
127
•usev5;•subf{•sqrt($_[0]**2+$_[1]**2);•}•my$five=f(3,4);
128
•usev6‐alpha;•subf{•sqrt(@_[0]**2+@_[1]**2);•}•my$five=f(3,4);
129
•subf(Num$x,Num$y){•sqrt($x**2+$y**2);•}•myNum$five=f(3,4);
130
131
• subsetPositiveofNumwhere{$_>0}
131
• subsetPositiveofNumwhere{$_>0}
• subf(Positive$x,Positive$y‐‐>Positivewhere{$_>($x&$y)}){
131
• subsetPositiveofNumwhere{$_>0}
• subf(Positive$x,Positive$y‐‐>Positivewhere{$_>($x&$y)}){
• sqrt($x**2+$y**2);}
131
• subsetPositiveofNumwhere{$_>0}
• subf(Positive$x,Positive$y‐‐>Positivewhere{$_>($x&$y)}){
• sqrt($x**2+$y**2);}
•my$five:=f(3,4);#inferredasPositive
131
専用: DSL
vs
汎用: GPL132
DSL(SQL,Regex,...)
133
☯簡潔な表現Concise
DSL(SQL,Regex,...)
133
☯簡潔な表現Concise
☯表現力豊かExpressive
DSL(SQL,Regex,...)
133
☯簡潔な表現Concise
☯表現力豊かExpressive
DSL(SQL,Regex,...)
GPL
(Lisp,C,...)
133
☯簡潔な表現Concise
☯表現力豊かExpressive
☯多目的利用Versatile
DSL(SQL,Regex,...)
GPL
(Lisp,C,...)
133
☯簡潔な表現Concise
☯表現力豊かExpressive
☯多目的利用Versatile
☯再利用性Reusable
DSL(SQL,Regex,...)
GPL
(Lisp,C,...)
133
コンパイラの拡張性
134
マクロ
135
マクロ
☯コンパイル時に評価される
135
マクロ
☯コンパイル時に評価される
☯全ての部分が交換可能
135
マクロ
☯コンパイル時に評価される
☯全ての部分が交換可能
☯それLexerでできるよ!
135
136
• macrocircumfix:</**/>($x)isparsed/.*?/{''}
136
• macrocircumfix:</**/>($x)isparsed/.*?/{''}
• /*ThisisaC‐stylecomment*/
136
• macrocircumfix:</**/>($x)isparsed/.*?/{''}
• /*ThisisaC‐stylecomment*/
•
136
137
• subpostfix:<!>($x){[*]1..$x}
137
• subpostfix:<!>($x){[*]1..$x}
• say10!;#3628800
137
138
• macroGREETING(){#Alate‐boundmacroq:code(:COMPILING){"Hello,$s"};}
138
• macroGREETING(){#Alate‐boundmacroq:code(:COMPILING){"Hello,$s"};}
•my$s="world";sayGREETING;#Hello,world
138
遅延評価vs
先行評価
139
遅延評価(Haskell,Unixパイプ)
140
☯モジュール化Modular
遅延評価(Haskell,Unixパイプ)
140
☯モジュール化Modular
☯道理可Reasonable
遅延評価(Haskell,Unixパイプ)
140
☯モジュール化Modular
☯道理可Reasonable
遅延評価(Haskell,Unixパイプ)
先行評価(それ以外)
140
☯モジュール化Modular
☯道理可Reasonable
☯ベタ書きDirect
遅延評価(Haskell,Unixパイプ)
先行評価(それ以外)
140
☯モジュール化Modular
☯道理可Reasonable
☯ベタ書きDirect
☯予測可Predictable
遅延評価(Haskell,Unixパイプ)
先行評価(それ以外)
140
遅延アノテーションによる戻り型ポリモーフィズム
141
142
• #"cat"for=<>{.say}
142
• #"cat"for=<>{.say}
• #"cat",togetherwithlinenumbersforeach(1..*;=<>){say"Line$^num:$^text";}
142
143
• #Listsarelazybydefault
143
• #Listsarelazybydefault• my@fib:=(
143
• #Listsarelazybydefault• my@fib:=(• 0,1,
143
• #Listsarelazybydefault• my@fib:=(• 0,1,• each(@fib;@fib[1..*]).map(&infix:<+>)
);
143
• #Listsarelazybydefault• my@fib:=(• 0,1,• each(@fib;@fib[1..*]).map(&infix:<+>)
);•
say"Thefirsttennumbersare:@fib[^10]";
143
144
• #Itemsareeagervalues.However...
144
• #Itemsareeagervalues.However...• my$ignored=lazy{10**(10*10)};
144
• #Itemsareeagervalues.However...• my$ignored=lazy{10**(10*10)};• my$unused=lazy{say1..$ignored};
144
• #Itemsareeagervalues.However...• my$ignored=lazy{10**(10*10)};• my$unused=lazy{say1..$ignored};
• say"Hello,world!";
144
• #Itemsareeagervalues.However...• my$ignored=lazy{10**(10*10)};• my$unused=lazy{say1..$ignored};
• say"Hello,world!";
144
• #Itemsareeagervalues.However...• my$ignored=lazy{10**(10*10)};• my$unused=lazy{say1..$ignored};
• say"Hello,world!";
• #(ForPerl5too:Scalar::DeferonCPAN)
144
クラスベースvs
プロトタイプベース
145
クラス(Java,Smalltalk,...)
146
☯型強化Typeful
クラス(Java,Smalltalk,...)
146
☯型強化Typeful
☯規律Disciplined
クラス(Java,Smalltalk,...)
146
☯型強化Typeful
☯規律Disciplined
クラス(Java,Smalltalk,...)
プロトタイプ(JavaScript,Lua,...)
146
☯型強化Typeful
☯規律Disciplined
☯適応性Adaptive
クラス(Java,Smalltalk,...)
プロトタイプ(JavaScript,Lua,...)
146
☯型強化Typeful
☯規律Disciplined
☯適応性Adaptive
☯便利Convenient
クラス(Java,Smalltalk,...)
プロトタイプ(JavaScript,Lua,...)
146
メタオブジェクトプロトコル
147
148
• classDogisMammaldoesCompanion{
148
• classDogisMammaldoesCompanion{•
my$.countwhere0..100;
148
• classDogisMammaldoesCompanion{•
my$.countwhere0..100;•
has$!brain;
148
• classDogisMammaldoesCompanion{•
my$.countwhere0..100;•
has$!brain;
• has&.vocalize=&say;has$.nameisrw="Fido";
148
• classDogisMammaldoesCompanion{•
my$.countwhere0..100;•
has$!brain;
• has&.vocalize=&say;has$.nameisrw="Fido";
• has$.furhandlesGroomable;has$.tailhandles<waghang>;
148
• classDogisMammaldoesCompanion{•
my$.countwhere0..100;•
has$!brain;
• has&.vocalize=&say;has$.nameisrw="Fido";
• has$.furhandlesGroomable;has$.tailhandles<waghang>;
•methodcompanionhandless/^owner_//{...}}
148
149
• myDog$fido.=new;
149
• myDog$fido.=new;•
$fido.HOW;#themetaobjectforDog
149
• myDog$fido.=new;•
$fido.HOW;#themetaobjectforDog• $fido.WHAT;#theDogprototypeobject
149
• myDog$fido.=new;•
$fido.HOW;#themetaobjectforDog• $fido.WHAT;#theDogprototypeobject• $fido.WHICH;#$fido’sObjectID
149
• myDog$fido.=new;•
$fido.HOW;#themetaobjectforDog• $fido.WHAT;#theDogprototypeobject• $fido.WHICH;#$fido’sObjectID
• Dog.isa(Dog);$fido.isa(Dog);
149
150
• $fido.HOW.add_method('bark',method(){$.vocalize('Woof!')});
150
• $fido.HOW.add_method('bark',method(){$.vocalize('Woof!')});
• Dog.can('bark');$fido.can('bark');
150
スレッドvs
プロセス151
スレッド(暗黙的)
152
☯直感的Intuitive
スレッド(暗黙的)
152
☯直感的Intuitive
☯並列処理可Parallelizable
スレッド(暗黙的)
152
☯直感的Intuitive
☯並列処理可Parallelizable
スレッド(暗黙的)
プロセス
(明示的)
152
☯直感的Intuitive
☯並列処理可Parallelizable
☯決定論的Deterministic
スレッド(暗黙的)
プロセス
(明示的)
152
☯直感的Intuitive
☯並列処理可Parallelizable
☯決定論的Deterministic
☯管理が簡単Manageable
スレッド(暗黙的)
プロセス
(明示的)
152
並列処理☺☺☺
153
ロック
☹ ☹ ☹154
155
•async{$x.withdraw(3);
$y.deposit(3);}
155
•async{$x.withdraw(3);
$y.deposit(3);}
☣RaceCondition☣
155
156
• async{$x.lock;$y.lock;
156
• async{$x.lock;$y.lock;
• $x.withdraw(3);$y.deposit(3);}
156
• async{$x.lock;$y.lock;
• $x.withdraw(3);$y.deposit(3);}
• async{$y.lock;$x.lock;}
156
• async{$x.lock;$y.lock;
• $x.withdraw(3);$y.deposit(3);}
• async{$y.lock;$x.lock;}
☣Deadlock☣
156
STMトランザクション
157
158
•async{
158
•async{•contend{#begintransaction
158
•async{•contend{#begintransaction•$x.withdraw(3);$y.deposit(3);
158
•async{•contend{#begintransaction•$x.withdraw(3);$y.deposit(3);
•}#commitorrollback}
158
159
• #Retrywith"defer"methodwithdraw($n){deferif$.balance<$n;$.balance‐=$n;}
159
• #Retrywith"defer"methodwithdraw($n){deferif$.balance<$n;$.balance‐=$n;}
•#Choicewith"maybe"subtransfer($x1,$x2,$y){maybe{$x1.withdraw(3)}maybe{$x2.withdraw(3)}$y.deposit(3);}
159
• #Retrywith"defer"methodwithdraw($n){deferif$.balance<$n;$.balance‐=$n;}
•#Choicewith"maybe"subtransfer($x1,$x2,$y){maybe{$x1.withdraw(3)}maybe{$x2.withdraw(3)}$y.deposit(3);}
•#Composablewithnested"maybe"contend{maybe{transfer($x1,$x2,$y)}maybe{transfer($x3,$x4,$y)}}
159
SIMDvs
MIMD160
SIMD(APL,Fortran)
161
☯シンプルSimple
SIMD(APL,Fortran)
161
☯シンプルSimple
☯スケーラブルScalable
SIMD(APL,Fortran)
161
☯シンプルSimple
☯スケーラブルScalable
SIMD(APL,Fortran)
MIMD
(それ以外)
161
☯シンプルSimple
☯スケーラブルScalable
☯型が豊富Richertypes
SIMD(APL,Fortran)
MIMD
(それ以外)
161
☯シンプルSimple
☯スケーラブルScalable
☯型が豊富Richertypes
☯なじみ深いFamiliarflow
SIMD(APL,Fortran)
MIMD
(それ以外)
161
162
• #HyperOperator(SSE/GPUfriendly)[1,1,2,3,5]»+«[1,2,3,5,8];
162
• #HyperOperator(SSE/GPUfriendly)[1,1,2,3,5]»+«[1,2,3,5,8];
• #===[2,3,5,8,13]
162
163
•#RecursiveVisits‐«[[1,2],3];
163
•#RecursiveVisits‐«[[1,2],3];
•#===[[‐1,‐2],‐3]
163
164
•#HyperMethods[1,4,9,16]».sqrt;
164
•#HyperMethods[1,4,9,16]».sqrt;
•#===[1,2,3,4]
164
165
• %timepugs‐e'(1..100000)>>.sqrt'real9.387suser9.219s
165
• %timepugs‐e'(1..100000)>>.sqrt'real9.387suser9.219s
•%timeenvGHCRTS=‐N2pugs‐e'(1..100000)>>.sqrt'real5.807suser6.959s
165
166
• #Junctionssubis_prime(Int$n‐‐>Bool){$n%all(2..$n.sqrt+1);}
166
• #Junctionssubis_prime(Int$n‐‐>Bool){$n%all(2..$n.sqrt+1);}
•subhas_twin_prime(Int$n‐‐>Bool){is_prime($n&($n±2));}
166
• #Junctionssubis_prime(Int$n‐‐>Bool){$n%all(2..$n.sqrt+1);}
•subhas_twin_prime(Int$n‐‐>Bool){is_prime($n&($n±2));}
•subinfix:<±>($x,$y){($x+$y)|($x‐$y);}
166
• #Junctionssubis_prime(Int$n‐‐>Bool){$n%all(2..$n.sqrt+1);}
•subhas_twin_prime(Int$n‐‐>Bool){is_prime($n&($n±2));}
•subinfix:<±>($x,$y){($x+$y)|($x‐$y);}
•166
俺オレ言語
vsあなたの言語
167
Perl6
168
☯褒めるBetter
Perl6
168
☯褒めるBetter
☯褒めるBetter
Perl6
168
☯褒めるBetter
☯褒めるBetter
Perl6 その他
168
☯褒めるBetter
☯褒めるBetter
☯褒めるBetter
Perl6 その他
168
☯褒めるBetter
☯褒めるBetter
☯褒めるBetter
☯褒めるBetter
Perl6 その他
168
169
•usejsan:DOM;
169
•usejsan:DOM;•useperl5:DBI;
169
•usejsan:DOM;•useperl5:DBI;•usehaskell:Numeric;
169
•usejsan:DOM;•useperl5:DBI;•usehaskell:Numeric;•useyour_language:FavouriteModule;
169
•usejsan:DOM;•useperl5:DBI;•usehaskell:Numeric;•useyour_language:FavouriteModule;
169
170
•usejava:java.lang.System;
170
•usejava:java.lang.System;
•say"GreetingsfromJava",•System.getProperty('java.version');
170
•usejava:java.lang.System;
•say"GreetingsfromJava",•System.getProperty('java.version');
•#GreetingsfromJava1.5.0_07
170
Pugs
JavaScript
Haskell Perl 5
YARV?JVM?
CLR? PyPy?
171
❆172
で 結局 Perl 6 のリリースっていつ?
173
クリスマスに!
174
Perl 6 がキタら,
毎日がクリスマス(かもしれない)
175
ご清聴ありがとうございました
☺
176
Recommended