Download - Neuperl6
Was ist neu an Perl 6?
Herbert Breunung
Mansfelder Land
Mansfelder Land
Ägypten aka Khem
Was ist neu an Perl 6?
Was ist neu an Perl 5?
rekursive Regex
named captures
smartmatch
Was ist neu an Perl 5?
Moose
TryCatch
Perl::Critic
Catalyst / Mojo / Dancer / Plack
Was ist neu an Perl 5?
Task::Kensho
Eiskreme Perl
Padre / Kephra
Perl 6Der heilige Gral
Auf der Suche ...
Suche nach dem ver...
19. Juli 2000
Altlasten● ewig veraltete ' package syntax
● schlecht funktionierende do{ } while() schleifen
● unmoderne OOP & Parameterübergabe
● kryptische Spezialvariablen
● aufwändig zu ändernde Innereien
● XS
Entwicklung der Syntax● Apokalypsen
● Exegesen
● Synopsen
Entwicklung der Syntax● Apokalypsen
● Exegesen
● Synopsen
Entwicklung der Syntax● Apokalypsen
● Exegesen
● Synopsen
● wiki.perl-community.de/bin/view/Wissensbasis/PerlTafel
● http://perl-6.de/
Entwicklung der Syntax
● p6l ([email protected])
● #perl6 (irc.freenode.org/perl6)
● Larry Wall, Damian Conway, Patrick R. Michaud, Allison Randal, chromatic
Entwicklung der Syntax
● p6l ([email protected])
● #perl6 (irc.freenode.org/perl6)
● Larry Wall, Damian Conway, Patrick R. Michaud, Allison Randal, chromatic
● Dan Sugalski, Luke Palmer, Audrey Tang
Larry Wall
Larry Wall
Perl 5 - Philosophie
TIMTOWTDI
simple and possible
context sensitive
Perl 6 - Philosophie
TIMTOWTDI
huffman coding
context sensitive
waterbed theory of complexity
Perl 6 - Philosophie
Tim Toady
huffman coding
context sensitive
waterbed theory of complexity
Freiheit
Freiheit
Freiheit
Freiheit
So wie ich denke, kann ich's auch aufschreiben.
Was ist neu an Perl 6?
Damian Conway
Was ist neu an Perl 6?
Freiheit
So wie ich denke, kann ich's auch aufschreiben.
Baut Grenzen zwischen Sprachen, Programmierstilen und Ökosystemen ab.
The World of Unix (1987)
C shell
A new dimension
C
shell
Perl 6 Syntax
Variablen $scalar $scalar
@array @array $array[0] @array[0]
$array[-1] @array[*-1] @array[0..3] @array[0..3]
%hash %hash $hash{'key'} %hash{'key'} $hash{'key'} %hash<key>
@hash{'k1','k2'} %hash<k1 k2>
Operator Roulette-> => .
. => ~
=~ => ~~
| & => +| +&
qw() => <>
<> => .get
? : => ?? !!
Spezialvar RouletteSTDIN => $*IN
@ARGS => $*ARGS
$^V => $*PERLVER
$^O => $*OS
__LINE__ => $?LINE
%+ => $/
Variable Ausgebenprint "$var \n"; say $var;
Variable Ausgebenprint "$var \n"; say $var;
use Data::Dumper;my @a = (1, 1, 2, 3, 5, 8, 13, 23, 36, [qw(a b c)]);print Dumper(@a);
Variable Ausgeben$VAR1 = 2; 2 3 4 5 6 7 7 2 5 ARRAY(0x568e94)$VAR2 = 3;$VAR3 = 4;$VAR4 = 5;$VAR5 = 6;$VAR6 = 7;$VAR7 = 7;$VAR8 = 2;$VAR9 = 5;$VAR10 = [ 'a', 'b', 'c' ]; [2, 3, 4, 5, 6, 7, 7, 2, 5, ["a", "b", "c"]]
Variable Ausgebenprint "$var \n"; say $var;
use Data::Dumper;my @a = (1, 1, 2, 3, 5, 8, 13, 23, 36, [qw(a b c)]);print Dumper(@a);
my @a = 1, 1, 2, 3, 5, 8, 13, 23, 36, [<a b c>];@a.perl.say;
kleines Spiel
my @a = ('A'..'Z');print $a[int rand 26] for 1..3;
say ('A'..'Z').pick(3, :replace);
Shell auslesen
print "Was ist ... ";chomp($ergebnis = <STDIN>);
$ergebnis = prompt "Was ist ... ";
Shell auslesen
print "Was ist ... ";chomp($ergebnis = <STDIN>);
$ergebnis = prompt "Was ist ... ";$ergebnis = $*IN.get;
Datei auslesen
$inhalt = do {open my $fh, '<', 'ordner/datei.txt';
local $/; <$fh> };
$inhalt = slurp 'ordner/datei.txt';
Datei zeilenweise
open my $fh, '<', 'ordner/datei.txt';while (my $zeile = <$fh>) { chomp $zeile;
for lines 'ordner/datei.txt' -> $zeile {
for - Schleife
for my $zeile (@zeilen) { ...
for @zeilen -> $zeile { ...
for - Schleife
for (1 .. 5) { ...
for ^ 5 { ...
for - Schleife
for my $zeile (@zeilen) { ...
for @zeilen -> $zeile { ...
for - Schleife
while (@zahlen) { … my $a = shift @zahlen; my $a = shift @zahlen;
for @zahlen -> $a, $b { ...
for - Schleife
my %tabelle = (Paul => 1.78, Heinz => 2.03);while (($name, $laenge) = each %tabelle) { say "$name ist $laenge lang.";}
my %tabelle = (Paul => 1.78, Heinz => 2.03);for %tabelle.kv -> $name, $länge { say "$name ist $länge lang.";}
for - Schleifemy @c = (\@za, \@zb);my $i = 0;for (0 .. $#a + $#b){ my $a = shift @{$c[$i]}; $i = abs 1 - $i;
for @za Z @zb -> $a { …
Schleifenfor my $i (0 .. $#a) { my $a = @a[$i]; my $b = @b[$i]; my $c = @c[$i]; ...
for zip (@a; @b; @c) -> $a, $b, $c { ...
Schleifenfor my $i (0 .. $#a) { @c[$i] = @a[$i] + @b[$i];}
Metaoperatorenfor my $i (0 .. $#a) { @c[$i] = @a[$i] + @b[$i];}
@c = @a >> + << @b;
Metaoperatorenmy $summe; $summe += $_ for @zahlen;
my $summe = [+] @zahlen;
Metaoperatorenmy $sortiert = 0;for ($#zahlen – 1) { last unless $zahlen[$_] > $zahlen[$_ + 1]; $sortiert = 1 if $_ == $#zahlen;}
my $sortiert = [>] @zahlen;
Werte vergleichen
if ( 2 < $a and $a <= 7) { ...
if 2 < $a <= 7 { …if $a ~~ 2^ .. 7 { ...
Junction
if ( $a == 2 or $a == 5 or $a == 7) { ...
if $a ~~ 2 | 5 |7 { ...
Junction
if $a ~~ 2 | 5 |7 { …
my @zahlen = 2, 5, 7;if $a ~~ any(@zahlen) { …
Junction
if $a ~~ 2 | 5 |7 { …
my @zahlen = 2, 5, 7;if $a ~~ any(@zahlen) { …
# alle in @ a müssen auch in @b vorkommenif all(@a) ~~ any(@b) { …
Junction
if $a ~~ 2 | 5 |7 { …
my @zahlen = 2, 5, 7;if $a ~~ any(@zahlen) { …
# identischer inhaltif @a ~~ @b { …
Smartmatch
if $a ~~ 2 | 5 |7 { …
my @zahlen = 2, 5, 7;if $a ~~ any(@zahlen) { …
# identischer inhaltif @a ~~ @b { …
Signaturen
sub routine { my $a = shift; my $b = shift; return unless defined $b; my $c = shift; }
sub routine ($a!, $b!, $c?) { … }
Signaturen
sub routine { my $a = shift; my $b = shift; return unless defined $b; my @rest = @_; }
sub routine ($a!, $b!, *@rest) { … }
Signaturen
sub potenz { my $par = shift; $par->{b} ** $par->{e}; }potenz( {b => 2, e => 7} );
sub potenz (:$b, :$e) { $b ** $e }potenz(b => 2, e => 7 );
Objekte
class UFO {
has $.speed;
method stop { $.speed = 0 }}
Objektepackage UFO; sub new { bless {speed => 0 }, shift; } sub length { my $self = shift; my $speed = shift; if ($speed) { $self->{speed} = $speed } else { $self->{speed} }}sub stop { my $self = shift; $self->{speed} = 0;}
Objekteclass UFO is Raumschiff {
has $.speed; has $!crew;
method stop { $.speed = 0 }}
$arv = UFO.new();$arv.speed = 20;$arv.stop;
Roles class WebCrawler does Log4Perl { … }
$objekt does Log4Perl;
Roles class WebCrawler does Log4Perl { … }
$objekt does Log4Perl;
role Log4Perl { has @.log_lines; has $.log_size is rw = 100; method log_message($message) { ... }}
Grammarsgrammar Fließkommazahl { rule top {<vorzeichen>? <man> <exponent>? } token vorzeichen { \+ | - } rule man { \. <ziffern> | <ziffern> [ \. <ziffern>? ]? } rule exponent :i { e <vorzeichen>? <ziffern> } token ziffern { \d+: }}
Fließkommazahl.top("-6.02e+23");say $/<exponent><sign>
Macros
macro postfix:<!>
Macros
macro postfix:<!> is equiv(&postfix:<++>) { [*] 1 .. $^n }
say 5!;> 120
Macros
macro circumfix:('<!-- -->') ($text) is parsed / .*? / { "" }
Macros
macro circumfix:('<!-- -->') ($text) is parsed / .*? / { "" }
augment slang Regex { token regex_metachar:<^> { ... }}
Macros
macro circumfix:('<!-- -->') ($text) is parsed / .*? / { "" }
augment slang Regex { token regex_metachar:<^> { ... }}
$?PARSER
Interpreter / CompilerPerl 6 auf Parrot => Rakudo
Perl 6 auf CLR => Sprixel
Perl 6 auf LLVM => vill
Perl 6 auf SMOP => Mildew
Perl 6 auf GHC => Pugs
Perl 6 auf Perl 6 => elf
PugsAudrey Tang
GHC
Perl 6 Users Golfing System
junction
-O Fun
Parrot
1. April 2001
Parrot Code
#copy stdin to stdout, except for lines starting with #
while left_angle_right_angle: if dollar_underscore[0] =eq= "#": continue_next; } print dollar_underscore;}
Parrot● VM (Virtuelle Maschine)
Parrot● VM (Virtuelle Maschine)
● Software - CPU
Parrot● VM (Virtuelle Maschine)
● native/magische Register
Parrot● VM (Virtuelle Maschine)
● native/magische Register
● Continuations
Parrot● VM (Virtuelle Maschine)
● native/magische Register
● Continuations
● Dan Sugalski
Parrot● VM (Virtuelle Maschine)
● native/magische Register
● Continuations
● Dan Sugalski
● Mastermind
Parrot● VM (Virtuelle Maschine)
● native/magische Register
● Continuations
● Dan Sugalski
● Mastermind – Einzelkämpfer
Parrot● VM (Virtuelle Maschine)
● native/magische Register
● Continuations
● Dan Sugalski
● Allison Randal
Allison Randal● Exchefin der Perl Foundation
Allison Randal● Exchefin der Perl Foundation
● Parrot Leiterin
Allison Randal● Exchefin der Perl Foundation
● Parrot Leiterin
● Parrot Hacker
Allison Randal● Exchefin der Perl Foundation
● Parrot Leiterin
● Parrot Hacker
● Specschreiber
Allison Randal● Exchefin der Perl Foundation
● Parrot Leiterin
● Parrot Hacker
● Specschreiber
● TGE / Punie
Parrot's Sprachen
Parrot's Sprachen● .pbc Parrot bytecode
Parrot's Sprachen● .pbc Parrot bytecode
● .pasm P. Assembler
Pasm new P0, 'PerlArray' set I0, 100000 time N0lp1: push P0, I0 dec I0 if I0, lp1 time N1 sub N1, N0 print "constr.time " print N1 print "\n"
Parrot's Sprachen● .pbc Parrot bytecode
● .pasm P. Assembler
● .pir P. Intermed. Repr.
PIR .sub main :main $I0 = 0 # initialized if $I0 goto l1 $I1 = 1 # init in block 1 goto l2 l1: $I1 = 2 # init in block 2 l2: print $I0 print $I1 # all paths leading here do init print "\n" end .end
Parrot's Sprachen● .pbc Parrot bytecode
● .pasm P. Assembler
● .pir P. Intermed. Repr.
● PGE P.Grammar Engine
Parrot's Sprachen● .pbc Parrot bytecode
● .pasm P. Assembler
● .pir P. Intermed. Repr.
● PGE P.Grammar Engine
Parrot's Sprachen● .pbc Parrot bytecode
● .pasm P. Assembler
● .pir P. Intermed. Repr.
● PGE P.Grammar Engine
● NQP Not Quit Perl 6
Parrot's Sprachen● .pbc Parrot bytecode
● .pasm P. Assembler
● .pir P. Intermed. Repr.
● PGE P.Grammar Engine
● NQP Not Quite Perl 6
Parrot's Sprachen● .pbc Parrot bytecode
● .pasm P. Assembler
● .pir P. Intermed. Repr.
● PGE P.Grammar Engine
● NQPrx
Patrick Michaud
Parrot
Parrot Compiler Tools
PGE
Rakudo
Jonathan Worthington
Rakudo, Blikost, Zavolaj
STD.pm
Syntaxregeln
in P6 rules
Bootstrapping
In Benutzung
elf
STD.pm parsen
mithilfe von Ruby
kp6
Flavio Glock
mp6
p5
pugs
SMOP
Daniel Ruoso
runloop
in C
simple MOP
sm0p / s1p → now RI / Mildew
mehr für alle
Perl 6 - Land
Noch Fragen?
Danke