an implementation of perl 6 · 2008. 10. 5. · “official perl 6” anything that passes the...
TRANSCRIPT
Pugsan implementation of
Perl6
AudreyTang1
≝2
Pugs...
3
Pugs...
≝ Perl6Compiler
3
Pugs...
≝ Perl6Compiler
≝ Perl6Runtime
3
Pugs...
≝ Perl6Compiler
≝ Perl6Runtime
≝ Perl6TestSuite
3
4
5
6
7
✓8
Perl6Code
9
Perl6Code
✓ 120+Modules
9
Perl6Code
✓ 120+Modules
✓ 160+Examples
9
Perl6Code
✓ 120+Modules
✓ 160+Examples
✓ 18,000+UnitTests
9
“OfficialPerl6”
10
“OfficialPerl6”
✓ Anythingthatpassestheofficialtestsuite
10
“OfficialPerl6”
✓ Anythingthatpassestheofficialtestsuite
✓ Definedbysemantics,notbyaccidentsofhistory
10
Test⇔Spec
✓11
⇚12
Perl,circa1995
13
• use5.000;
Perl,circa1995
13
• use5.000;• require'fastcwd.pl';
Perl,circa1995
13
• use5.000;• require'fastcwd.pl';• require'newgetopt.pl';
Perl,circa1995
13
• use5.000;• require'fastcwd.pl';• require'newgetopt.pl';• require'exceptions.pl';
Perl,circa1995
13
Perl,circa2005
14
• use v6-alpha;
Perl,circa2005
14
• use v6-alpha;• use perl5:DBI;
Perl,circa2005
14
• use v6-alpha;• use perl5:DBI;• use perl5:Encode <encode decode>;
Perl,circa2005
14
• use v6-alpha;• use perl5:DBI;• use perl5:Encode <encode decode>;• use perl5:Template;
Perl,circa2005
14
• use v6-alpha;• use perl5:DBI;• use perl5:Encode <encode decode>;• use perl5:Template;
• # Implementation of "fork"eval "fork()" :lang<perl5>;
Perl,circa2005
14
DualCorePugs
Pugs::RuntimePugs::CompilerPugs::Grammar
Pugs.EvalPugs.Prim
Pugs.Types
Perl 5
Runtime
GHC
Runtime
15
⇛16
PugsIntermediateLanguage
17
Backends
18
Backends
⇛ Perl5
18
Backends
⇛ Perl5
⇛ Parrot
18
Backends
⇛ Perl5
⇛ Parrot
⇛ JavaScript
18
19
䷗20
6.0Primitives
䷁
21
6.2Functions
䷗
22
6.28Objects
䷒
23
6.283Grammars
䷊
24
6.2831Types
䷡
25
6.28318Macros
䷪
26
6.283185SelfHosting
䷀
27
2πPerl6!☯
28
≠29
“FrivolousToyinterpreter”(asseenonSlashdot)
30
“FrivolousToyinterpreter”
31
“FrivolousToyinterpreter”
32
“Toyinterpreter”
33
“Toyinterpreter”
34
“Toy”35
-Ofun36
☺37
Arrowlength
Time
14400+commits
240+committers
38
TestDriven
39
TestDriven
☺Bugreport➟Test
39
TestDriven
☺Bugreport➟Test
☺SmokeServer
39
TestDriven
☺Bugreport➟Test
☺SmokeServer
☺:todo<unspecced>
39
Anarchistic
40
Anarchistic
☺10+languages
40
Anarchistic
☺10+languages
☺30+sub‐projects
40
Anarchistic
☺10+languages
☺30+sub‐projects
☺Fastfeedbackloop
40
PatchesWelcome?
41
CommitsWelcome!
42
✆43
irc.freenode.net#perl6
44
λCamels
45
λCamels
✆ 200+People
45
λCamels
✆ 200+People✆ 20+Regulars
45
λCamels
✆ 200+People✆ 20+Regulars✆ TimToady++
45
svnbot6
46
evalbot6
47
lambdabot
48
IRC.pugscode.org
49
Blog.pugscode.org
50
Run.pugscode.org
51
Smoke.pugscode.org
52
Spec.pugscode.org
53
MailingLists
54
MailingLists
✆ perl6‐users
54
MailingLists
✆ perl6‐users
✆ perl6‐language
54
MailingLists
✆ perl6‐users
✆ perl6‐language
✆ perl6‐compiler
54
Repositories
55
http://svn.openfoundry.org/pugs/
Repositories
55
http://svn.openfoundry.org/pugs/
http://perlcabal.org/~audreyt/darcs/pugs/
Repositories
55
http://svn.openfoundry.org/pugs/
http://perlcabal.org/~audreyt/darcs/pugs/
SVK
Repositories
55
♨56
Erdösing
57
Erdösing
♨ 2006..*
57
Hackathons
58
Hackathons♨ Taipei
58
Hackathons♨ Taipei
♨ Vienna
58
Hackathons♨ Taipei
♨ Vienna
♨ Toronto
58
Hackathons♨ Taipei
♨ Vienna
♨ Toronto
♨ Amsterdam
58
Hackathons♨ Taipei
♨ Vienna
♨ Toronto
♨ Amsterdam
♨ Echt
58
Hackathons♨ Taipei
♨ Vienna
♨ Toronto
♨ Amsterdam
♨ Echt
♨ Lismore
58
Hackathons♨ Taipei
♨ Vienna
♨ Toronto
♨ Amsterdam
♨ Echt
♨ Lismore
♨ Mt.Arbel
58
Hackathons♨ Taipei
♨ Vienna
♨ Toronto
♨ Amsterdam
♨ Echt
♨ Lismore
♨ Mt.Arbel
♨ Vienna2
58
Hackathons♨ Taipei
♨ Vienna
♨ Toronto
♨ Amsterdam
♨ Echt
♨ Lismore
♨ Mt.Arbel
♨ Vienna2
♨ Tokyo
58
Hackathons♨ Taipei
♨ Vienna
♨ Toronto
♨ Amsterdam
♨ Echt
♨ Lismore
♨ Mt.Arbel
♨ Vienna2
♨ Tokyo
♨ Redmond
58
Hackathons♨ Taipei
♨ Vienna
♨ Toronto
♨ Amsterdam
♨ Echt
♨ Lismore
♨ Mt.Arbel
♨ Vienna2
♨ Tokyo
♨ Redmond
♨ Chicago
58
Hackathons♨ Taipei
♨ Vienna
♨ Toronto
♨ Amsterdam
♨ Echt
♨ Lismore
♨ Mt.Arbel
♨ Vienna2
♨ Tokyo
♨ Redmond
♨ Chicago
♨ Boston
58
Hackathons♨ Taipei
♨ Vienna
♨ Toronto
♨ Amsterdam
♨ Echt
♨ Lismore
♨ Mt.Arbel
♨ Vienna2
♨ Tokyo
♨ Redmond
♨ Chicago
♨ Boston
♨ Portland
58
Hackathons♨ Taipei
♨ Vienna
♨ Toronto
♨ Amsterdam
♨ Echt
♨ Lismore
♨ Mt.Arbel
♨ Vienna2
♨ Tokyo
♨ Redmond
♨ Chicago
♨ Boston
♨ Portland
♨ SaoPaulo
58
Hackathons♨ Taipei
♨ Vienna
♨ Toronto
♨ Amsterdam
♨ Echt
♨ Lismore
♨ Mt.Arbel
♨ Vienna2
♨ Tokyo
♨ Redmond
♨ Chicago
♨ Boston
♨ Portland
♨ SaoPaulo
♨ ...andmore!
58
ℙ59
Practical
60
61
62
63
64
65
66
67
68
69
∀70
Abstractions➥Sexy
71
Closuressubmake_counter{my$start=shift;returnsub{++$start};}my$from_ten=make_counter(10);my$from_three=make_counter(3);print$from_three‐>();#4print$from_three‐>();#5print$from_ten‐>();#11
72
TieuseTie::Google;tiemy%search=>'Tie::Google';
for(@{$search{'PerlPugs'}}){print"*$_‐>{title}‐$_‐>{URL}\n";}
73
Abstractions++
74
Abstractions++
∀ bless()
74
Abstractions++
∀ bless()
∀ IOLayers
74
Abstractions++
∀ bless()
∀ IOLayers
∀ BEGIN{...}
74
S75
Shorthands➥Natural
76
DeCSS
s''$/=\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
77
Shorthands++
78
Shorthands++
S Regex
78
Shorthands++
S Regex
S Context
78
Shorthands++
S Regex
S Context
S Topical$_
78
♡79
Bestcoding➥Nocoding
80
81
CPAN
82
♡ 11years
CPAN
82
♡ 11years
♡ 5000+authors
CPAN
82
♡ 11years
♡ 5000+authors
♡ 10000+modules
CPAN
82
Services
83
♡ PackageManagement
Services
83
♡ PackageManagement
♡ Rating&Discussion
Services
83
♡ PackageManagement
♡ Rating&Discussion
♡ SmokeTesting
Services
83
♡ PackageManagement
♡ Rating&Discussion
♡ SmokeTesting
♡ IssueTracking
Services
83
Vocabulary≩Syntax
84
“TheBestthinghappenedtoPerl”
85
But...
86
Perl5isnotthebestthing
forCPAN
87
☣88
SyntaxRedundancy
☣89
90
• usev5;
90
• usev5;• subrender{
90
• usev5;• subrender{• my$self=shift;
90
• usev5;• subrender{• my$self=shift;• my%opts=(x=>1,y=>1,z=>0,%{$_[0]});
90
• usev5;• subrender{• my$self=shift;• my%opts=(x=>1,y=>1,z=>0,%{$_[0]});• formy$item($self‐>filter(@{$self‐>{items}})){
90
• 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";
90
• 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";
• }}
90
91
• usev6‐alpha;
91
• usev6‐alpha;• methodrender($x=1,$y=1,$z=0){
91
• usev6‐alpha;• methodrender($x=1,$y=1,$z=0){•[email protected](@.items){
91
• usev6‐alpha;• methodrender($x=1,$y=1,$z=0){•[email protected](@.items){•say.draw(:$x,:$y,:$z);
}}
91
JengaInternals☣
92
93
Bug‐for‐bugcompatibility
☣94
BestPracticetakesdiscipline
95
96
BestPracticeshouldbeNatural!
97
⑥98
2000RFCs
99
2001Parrot
100
2002Apocalypses
101
2003Ponie
(late,asinthelateArthurDent)
102
2004Synopses
103
2005Pugs
104
2006v6‐alpha
105
106
☯107
ReconciletheIrreconcilable
108
Staticvs
Dynamic109
Types☺
110
Typing☹
111
•usev5;•subf{•sqrt($_[0]**2+$_[1]**2)•}•my$five=f(3,4);
112
•usev6‐alpha;•subf{•sqrt(@_[0]**2+@_[1]**2)•}•my$five=f(3,4);
113
GradualTypingwithAnnotations
114
• subf(Num$x,Num$y){• sqrt($x**2+$y**2);• }• myNum$five=f(3,4);
•
115
116
• subsetPositiveofNumwhere{$_>0}
116
• subsetPositiveofNumwhere{$_>0}
• subf(Positive$x,Positive$y‐‐>Positivewhere{$_>=($x&$y)}){
116
• subsetPositiveofNumwhere{$_>0}
• subf(Positive$x,Positive$y‐‐>Positivewhere{$_>=($x&$y)}){
• sqrt($x**2+$y**2);}
116
• subsetPositiveofNumwhere{$_>0}
• subf(Positive$x,Positive$y‐‐>Positivewhere{$_>=($x&$y)}){
• sqrt($x**2+$y**2);}
•my$five:=f(3,4);#inferredasPositive
116
Compilervs
Runtime117
BEGIN{...}
118
BEGIN{...}• CompilerisaREPL
118
BEGIN{...}• CompilerisaREPL
• Exposetheentirecompiler
118
BEGIN{...}• CompilerisaREPL
• Exposetheentirecompiler
• Allpartsareswappable
118
BEGIN{...}• CompilerisaREPL
• Exposetheentirecompiler
• Allpartsareswappable
• Eventhelexer!
118
• macrocircumfix:</**/>($x)• isparsed/.*?/• {''}• • /*ThisisaC‐stylecomment*/
•
119
• subpostfix:<!>($x){• [*]1..$x• }• • say10!;#3628800
120
• macroGREETING(){• #Alate‐boundmacro• q:code(:COMPILING){"Hello,$s"};• }
• my$s="world";• sayGREETING;#Hello,world
121
Lazyvs
Eager122
123
• #"cat"for=<>{.say}
123
• #"cat"for=<>{.say}
• #"cat",annotatedwithlinenumbersforeach(1..*;=<>){say"Line$^num:$^text";}
123
124
• #Listsarelazystreams!my@fib=(
124
• #Listsarelazystreams!my@fib=(
• 0,1,
124
• #Listsarelazystreams!my@fib=(
• 0,1,• each(@fib;@fib[1..*]).map(&infix:<+>)
);
124
• #Listsarelazystreams!my@fib=(
• 0,1,• each(@fib;@fib[1..*]).map(&infix:<+>)
);•
say"Thefirsttennumbersare:@fib[^10]";
124
125
• #Itemsareeagervalues.However...
125
• #Itemsareeagervalues.However...• my$ignored=lazy{9**9**9};
125
• #Itemsareeagervalues.However...• my$ignored=lazy{9**9**9};• my$unused=lazy{say[1..$ignored]};
125
• #Itemsareeagervalues.However...• my$ignored=lazy{9**9**9};• my$unused=lazy{say[1..$ignored]};
• say"Hello,world!";
125
Classesvs
Prototypes126
127
• classDogisMammaldoesPet{
127
• classDogisMammaldoesPet{•
my$.countwhere0..100;
127
• classDogisMammaldoesPet{•
my$.countwhere0..100;•
has$!brain;
127
• classDogisMammaldoesPet{•
my$.countwhere0..100;•
has$!brain;
• has&.vocalize=&say;has$.nameisrw="fido";
127
• classDogisMammaldoesPet{•
my$.countwhere0..100;•
has$!brain;
• has&.vocalize=&say;has$.nameisrw="fido";
• has$.furhandlesGroomable;has$.tailhandles<waghang>;
127
• classDogisMammaldoesPet{•
my$.countwhere0..100;•
has$!brain;
• has&.vocalize=&say;has$.nameisrw="fido";
• has$.furhandlesGroomable;has$.tailhandles<waghang>;
•methodowner()handless/^owner_//{...}
}
127
128
• myDog$fido.=new;
128
• myDog$fido.=new;•
$fido.HOW;#themetaobjectforDog
128
• myDog$fido.=new;•
$fido.HOW;#themetaobjectforDog• $fido.WHAT;#theDogprototypeobject
128
• myDog$fido.=new;•
$fido.HOW;#themetaobjectforDog• $fido.WHAT;#theDogprototypeobject• $fido.WHICH;#$fido’sObjectID
128
• myDog$fido.=new;•
$fido.HOW;#themetaobjectforDog• $fido.WHAT;#theDogprototypeobject• $fido.WHICH;#$fido’sObjectID
• Dog.isa(Dog);$fido.isa(Dog);
128
129
• $fido.HOW.add_method('bark',method(){$.vocalize('Woof!')});
129
• $fido.HOW.add_method('bark',method(){$.vocalize('Woof!')});
• Dog.can('bark');$fido.can('bark');
129
Parallelismvs
Sanity130
131
• #HyperOperator(SSE/GPUfriendly)[1,1,2,3,5]»+«[1,2,3,5,8];
131
• #HyperOperator(SSE/GPUfriendly)[1,1,2,3,5]»+«[1,2,3,5,8];
• #===[2,3,5,8,13]
131
132
•#RecursiveVisits‐«[[1,2],3];
132
•#RecursiveVisits‐«[[1,2],3];
•#===[[‐1,‐2],‐3]
132
133
•#HyperMethods[1,4,9,16]».sqrt;
133
•#HyperMethods[1,4,9,16]».sqrt;
•#===[1,2,3,4]
133
134
• %timepugs‐e'(1..100000)>>.sqrt'real9.387suser9.219s
134
• %timepugs‐e'(1..100000)>>.sqrt'real9.387suser9.219s
•%timeenvGHCRTS=‐N2pugs‐e'(1..100000)>>.sqrt'real5.807suser6.959s
134
135
• #Junctionssubis_prime(Int$n‐‐>Bool){$n%all(2..$n.sqrt+1);}
135
• #Junctionssubis_prime(Int$n‐‐>Bool){$n%all(2..$n.sqrt+1);}
•subhas_twin_prime(Int$n‐‐>Bool){is_prime($n&($n±2));}
135
• #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);}
135
• #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);}
•135
Concurrency☺☺☺
136
Locking☹ ☹ ☹
137
138
•async{$x.withdraw(3);
$y.deposit(3);}
138
•async{$x.withdraw(3);
$y.deposit(3);}
☣RaceCondition☣
138
139
• async{$x.lock;$y.lock;
139
• async{$x.lock;$y.lock;
• $x.withdraw(3);$y.deposit(3);}
139
• async{$x.lock;$y.lock;
• $x.withdraw(3);$y.deposit(3);}
• async{$y.lock;$x.lock;}
139
• async{$x.lock;$y.lock;
• $x.withdraw(3);$y.deposit(3);}
• async{$y.lock;$x.lock;}
☣Deadlock☣
139
SoftwareTransactional
Memory
140
141
•#Nolocks,noraces!contend{$x.withdraw(3);$y.deposit(3);}
141
142
• #Retrywith"defer"methodwithdraw($n){deferif$.balance<$n;$.balance‐=$n;}
142
• #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);}
142
• #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)}}
142
My Languagevs
Your Language
143
144
•usejsan:DOM;
144
•usejsan:DOM;•useperl5:DBI;
144
•usejsan:DOM;•useperl5:DBI;•usehaskell:Numeric;
144
Pugs
JavaScript
Haskell Perl 5
145
Pugs
JavaScript
Haskell Perl 5
YARV?JVM?
CLR? PyPy?
146
يژ147
PopularTargetLanguage
148
GeneratingJS
149
GeneratingJSژ Java:GoogleWebToolkit
149
GeneratingJSژ Java:GoogleWebToolkit
ژ Perl:Jifty
149
GeneratingJSژ Java:GoogleWebToolkit
ژ Perl:Jifty
ژ Ruby:Rails/JS
149
GeneratingJSژ Java:GoogleWebToolkit
ژ Perl:Jifty
ژ Ruby:Rails/JS
ژ Python:Pyjamas
149
GeneratingJSژ Java:GoogleWebToolkit
ژ Perl:Jifty
ژ Ruby:Rails/JS
ژ Python:Pyjamas
ژ C#:Script#
149
Samelanguageforbothsides
✓150
Client‐sidejustatinysubset
✗151
CompilingtoJS
152
CompilingtoJS
ژ HOP/Scheme2JS
152
CompilingtoJS
ژ HOP/Scheme2JS
ژ Links
152
CompilingtoJS
ژ HOP/Scheme2JS
ژ Links
ژ HaXe
152
CompilingtoJS
ژ HOP/Scheme2JS
ژ Links
ژ HaXe
ژ Pugs!
152
PIL2JS
153
pugs‐CJS
154
pugs‐CJS
ژ WritteninPerl5
154
pugs‐CJS
ژ WritteninPerl5
ژ Passes90%oftests
154
pugs‐CJS
ژ WritteninPerl5
ژ Passes90%oftests
ژ ~30kRuntime
154
PIL2JSRuntime
155
PIL2JSRuntime
ژ Primitives&Autoboxing
155
PIL2JSRuntime
ژ Primitives&Autoboxing
ژ Meta‐objectprotocol
155
PIL2JSRuntime
ژ Primitives&Autoboxing
ژ Meta‐objectprotocol
ژ SupportsJSANlibraries
155
JSAN
156
JSAN
ژ "CPAN".replace(/CP/,"JS")
156
JSAN
ژ "CPAN".replace(/CP/,"JS")
ژ ModulesystemwithPrototype.js
156
JSAN
ژ "CPAN".replace(/CP/,"JS")
ژ ModulesystemwithPrototype.js
ژ Test.Simple,Jemplate,etc.
156
Shortcomings
157
Shortcomings
ژ Callingconventiontoocomplex
157
Shortcomings
ژ Callingconventiontoocomplex
ژ CPSrunloopisslow
157
Shortcomings
ژ Callingconventiontoocomplex
ژ CPSrunloopisslow
ژ Notailrecursionnorgoto
157
Shortcomings
ژ Callingconventiontoocomplex
ژ CPSrunloopisslow
ژ Notailrecursionnorgoto
ژ Butthere'shope!
157
JS2.0
158
JS2.0
ژ Selfhosting
158
JS2.0
ژ Selfhosting
ژ BacktranslatetoJS1
158
JS2.0
ژ Selfhosting
ژ BacktranslatetoJS1
ژ Types,Modules,Continuations
158
JS2.0
ژ Selfhosting
ژ BacktranslatetoJS1
ژ Types,Modules,Continuations
ژ PartofFirefox3.0(nextyear)
158
⌛159
Feb1TaPLarrived
asanexercise…
160
Feb6Junctions
(1|2)+(3|4)➥(4|5|6)
161
Feb16Input/Output
say"Hello,world"
162
❀163
Mar19PCRERegex
s:P5:g/5/6/;
164
May8svnbot.p6
r2851|iblech++
165
May25Prelude.pm
subsprintf($fmt,*@args)
166
May29EmbeddedPerl5
useperl5:DBI;
167
☀168
Jun2evalbot.p6
[#perl6]?eval1+1
169
Jun24Perl6→PIL→Parrot
makesmoke‐pir170
Jul14PIL→Perl5
makesmoke‐perl5
171
Jul17PIL→JavaScript
makesmoke‐js
172
Aug3KontentWiki
useperl5:Template;
173
☁174
Nov2RuntimeAPI
Perl6::ObjectSpace
175
Nov3ConcurrencyAPI
subfisthrottled(:limit(3)){…}
176
Nov4PackagingAPI
perl5‐Foo‐1.0‐cpan+KANE.jib
177
Nov7Coroutines
coro{yield1}
178
Nov231stcommitfromLarry(stillwaitingforGuido☺)
179
❅180
Jan6YAMLSerialization
say$x.yaml;
181
Feb3Self‐parsingGrammar
grammarGrammar;
182
Feb22Larryjoins#perl6
<fglock>TimToady:welcome<Juerd>Justtrytonotgetaddicted:)<TimToady>Juerd:toolate…
183
Feb25CodeDOM
$AST=q:code/say"hi"/;
184
❀185
Mar11EvaluatorinPerl5
Pugs::Runtime
186
Mar16BootstrappedonPerl5
lrep.p6lrep.p6
187
Apr1CallingConventionAPI
$tree=\($obj:attr=>1,$child);
188
Apr21MITLicense
189
May8PredictiveParsing
<TimToady>"do,ordonot.thereisnotry..."
190
☼191
June1SummerofCode
192
SoC:Perl.org
193
SoC:Perl.org
☼ Perl6DBIModule
193
SoC:Perl.org
☼ Perl6DBIModule
☼ Perl5toPerl6Translator
193
SoC:Perl.org
☼ Perl6DBIModule
☼ Perl5toPerl6Translator
☼ PugsBootstrapFromPerl5andRules
193
SoC:Haskell.org
194
SoC:Haskell.org
☼ FastMutableCollectionTypes
194
SoC:Haskell.org
☼ FastMutableCollectionTypes
☼ UnicodeByteStringandData.Rope
194
June4SoftwareTransactionalMemory
async{contend{...}}
195
June26v6.pm
usev6‐alpha;
196
August17Smartlinks.pl
#L<S02/"bidirectionalmirrorings">isq《123》,123,"anglebrackets";
197
☁198
September16NativeGrammarEngineviaEmbeddedPerl5
s:g/PGE/PCR/;
199
October9Fullyreentrantcontinuations
subcallcc(Code&c){&c(&?CALLER_CONTINUATION)}
200
October11GHC6.6
<TimToady>Iupgradedandmy$jobprogramran60timesfaster...
201
October20SMPDataParallelism
[(1|2),(3|4)].>>sqrt
202
⇪203
204
“CPANisthelanguagePerlisjustsyntax”
205
Production
206
Production
⇪ ExistingPerl5codebase
206
Production
⇪ ExistingPerl5codebase
⇪ GHCmaybeunavailable
206
Production
⇪ ExistingPerl5codebase
⇪ GHCmaybeunavailable
⇪ Can’trewritefromscratch
206
ThePerl5VM
207
ThePerl5VM
⇪ Activelydeveloped
207
ThePerl5VM
⇪ Activelydeveloped
⇪ 5.10ismuchmorev6ish
207
ThePerl5VM
⇪ Activelydeveloped
⇪ 5.10ismuchmorev6ish
⇪ UnifiedPerlRuntime
207
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 ...
208
Moose♘
209
ObjectswithClass
210
• usev6‐alpha;• classPoint;• • • has$.xisrw;#instanceattributes• has$.y;#default"isreadonly"• • methodclear(){• • • $.x=0;#accessiblewithintheclass• $.y=0;• }•
211
• usev5;• packagePoint;• useMoose;• • hasx=>(is=>'rw');• hasy=>(is=>'ro');• • subclear{• my$self=shift;• • $self‐>{x}=0;• $self‐>y(0);• }•
212
Subclassing
213
• usev6‐alpha;• classPoint3D;• • • isPoint;• • has$.z;• • methodclear(){• • call;• $.z=0;• };•
214
• usev5;• packagePoint3D;• useMoose;• • extends'Point';• • hasz=>(isa=>'Int');• • overrideclear=>sub{• my$self=shift;• super;• $self‐>{z}=0;• };•
215
• usev5;• packagePoint3D;• useMoose;• • extends'Point';• • hasz=>(isa=>'Int');• • afterclear=>sub{• my$self=shift;• • $self‐>{z}=0;• };•
216
SubsetTypes
217
• usev6‐alpha;• classAddress;• useperl5:Locale::US;• useperl5:Regexp::Common<zip$RE>;• • my$STATES=Locale::US.new;• subsetUS_StateofStrwhere{• $STATES{any(<code2statestate2code>)}{.uc};• };• • hasUS_State$.stateisrw;• hasStr$.zip_codeisrwwhere{• $_~~$RE<zip><<US>{'‐extended'=>'allow'}• };•
218
• usev5;• packageAddress;• useMoose;• useMoose::Util::TypeConstraints;• useLocale::US;• useRegexp::Common'zip';• • my$STATES=Locale::US‐>new;• subtypeUSState=>asStr=>where{• $STATES‐>{code2state}{uc($_)}• or$STATES‐>{state2code}{uc($_)};• }• • hasstate=>(is=>'rw',isa=>'USState');• haszip_code=>(• is=>'rw',• isa=>subtypeStr=>where{• /$RE{zip}{US}{‐extended=>'allow'}/• },• );•
219
Morefeatures
220
♘ Roles(DynamicTraits)
Morefeatures
220
♘ Roles(DynamicTraits)
♘ Coercion
Morefeatures
220
♘ Roles(DynamicTraits)
♘ Coercion
♘ MetaObjects
Morefeatures
220
Module::Compile※
221
SourceFilter
222
• usev5;• useFilter::Simplesub{• s{(^sub\s+\w+\s+\{)}• {$1\nmy$self=shift;\n}mgx;• }•
223
Filter::SimpleBad
224
※ Extradependency
Filter::SimpleBad
224
※ Extradependency
※ Slowsdownstartup
Filter::SimpleBad
224
※ Extradependency
※ Slowsdownstartup
※Breaksthedebugger
Filter::SimpleBad
224
※ Extradependency
※ Slowsdownstartup
※Breaksthedebugger
※WrecksotherSourceFilters
Filter::SimpleBad
224
Wecanfixit!
225
• usev5;• useFilter::Simplesub{• s{(^sub\s+\w+\s+\{)}• {$1\nmy$self=shift;\n}mgx;• }
226
• usev5;• useFilter::Simple::Compilesub{• s{(^sub\s+\w+\s+\{)}• {$1\nmy$self=shift;\n}mgx;• }
227
How?
228
Little‐knownfact:
229
“useFoo”looksforFoo.pmcbeforeFoo.pm
230
• %echo'print"Hello\n"'>Foo.pmc• %perl‐MFoo‐e1
Hello
231
Savefilteredresultsto.pmc...
232
...nofilteringneedednexttime!
233
Module::CompileGood
234
※ Freeofdependenciesonuser’ssite
Module::CompileGood
234
※ Freeofdependenciesonuser’ssite
※ Faststartuptime
Module::CompileGood
234
※ Freeofdependenciesonuser’ssite
※ Faststartuptime
※Debuggablesourceisallin.pmc
Module::CompileGood
234
※ Freeofdependenciesonuser’ssite
※ Faststartuptime
※Debuggablesourceisallin.pmc
※ Composableprecompilers
Module::CompileGood
234
v6.pm⚅
235
Source:Rule.pm
236
• usev6‐alpha;• • grammarPugs::Grammar::Rule;
• tokenws{• [\s• |\#\N*• ]+• }• #...morerules...
237
Target:Rule.pmc
238
• #Generatedfile‐donotedit!• ##################(((32‐bitChecksumValidator)))##################• BEGIN{use5.006;local(*F,$/);($F=__FILE__)=~s!c$!!;open(F)• ordie"Cannotopen$F:$!";binmode(F,':crlf');unpack('%32N*',<F>)• ==0x1D6399E1ordie"Checksumfailedforoutdated.pmcfile:${F}c"}• #####################################################################• packagePugs::Grammar::Rule;• *ws=sub{• my$grammar=shift;• #warn"ruleargumentisundefined"unlessdefined$_[0];• $_[0]=""unlessdefined$_[0];• my$bool=$_[0]=~/^((?:\s|\#(?‐s:.)*)+)(.*)$/sx;• return{• bool=>$bool,• match=>$1,• tail=>$2,• #capture=>$1,• }• };• #...morerules...
239
WritePerl6compiletoPerl5
⇪240
✈241
WhenwillPerl6bereleased?
242
ByChristmas!
243
WhenPerl6arrives,everydaywillbelike
Christmas!❆
244
Fin.245