SlideShare una empresa de Scribd logo
1 de 118
Perl 6

                                                An Apocalypse




The Camelia image is copyright 2009 and trademarked by Larry Wall   Matt Follett matt.follett@gmail.com
Instance of Perl 6




          • Pugs - Perl 6 on Haskell
          • Niecza - Perl 6 on the CLR
          • Sprixel - Perl 6 in JavaScript
          • Elf, Mildew
          • Perlito (MiniPerl6) - JVM, Go, Perl 5, JS, Lisp
          • YAPSI - Perl 6 in Perl 6
          • Rakudo - Perl 6 on Parrot




Matt Follett matt.follett@gmail.com
Instance of Perl 6




          • Pugs - Perl 6 on Haskell
          • Niecza - Perl 6 on the CLR
          • Sprixel - Perl 6 in JavaScript
          • Elf, Mildew
          • Perlito (MiniPerl6) - JVM, Go, Perl 5, JS, Lisp
          • YAPSI - Perl 6 in Perl 6
          • Rakudo - Perl 6 on Parrot




Matt Follett matt.follett@gmail.com
Modules




Matt Follett matt.follett@gmail.com
The Backstory

• Perl 6 announced at Perl Conference in 2000
• Immediate RFCs
• First apocalypse on April 2, 2001
• Twelfth apocalypse April 13, 2004




Matt Follett matt.follett@gmail.com

                             http://www.perlfoundation.org/perl6/index.cgi?timeline
More Backstory

• Parrot April Fool’s Joke 2001
• First commit to Parrot on August 29, 2001
• Audrey Tang publicly releases Pugs in February of 2005




Matt Follett matt.follett@gmail.com
Recent History

• Parrot starts monthly releases in January 2007
• Parrot starts major releases on a yearly cycle in 2010
• Rakudo * monthly releases start in July 2010




Matt Follett matt.follett@gmail.com
Recent History

• Parrot starts monthly releases in January 2007
• Parrot starts major releases on a yearly cycle in 2010
• Rakudo * monthly releases start in July 2010




Matt Follett matt.follett@gmail.com
Rakudo *



          • a useful, usable, "early adopter" distribution of Perl
            6
                nota 1.0
                compile yourself

          • Includes modules for XML, JSON, YAML, database
            interfaces, etc
          • includes neutro
          • Helps get feedback to the Rakudo team




Matt Follett matt.follett@gmail.com
Feedback = Improvements




Matt Follett matt.follett@gmail.com
                             http://gil.di.uminho.pt/users/smash/rakudo-bench.html
The Basics




          • Variables are prepended with a sigil to indicate
            their basic type (scalar, array, hash)
          • These sigils are invariant
          • Variables declared with ‘my’ are lexically scoped
          • Perl 6 autoboxes




Matt Follett matt.follett@gmail.com
my @array = 1,2,3;
say(@array[0])

my ($fruit, $jp) = 'apples', JSON.new();
$jp.parse($something_from_somewhere);

my %dictionary = apples => 2, pears => 3;
say("I have %dictionary{$fruit} $fruit");



Matt Follett matt.follett@gmail.com
my @array = 1,2,3;
say(@array[0])

my ($fruit, $jp) = 'apples', JSON.new();
$jp.parse($something_from_somewhere);

my %dictionary = apples => 2, pears => 3;
say("I have %dictionary{$fruit} $fruit");



Matt Follett matt.follett@gmail.com
my @array = 1,2,3;
say(@array[0])

my ($fruit, $jp) = 'apples', JSON.new();
$jp.parse($something_from_somewhere);

my %dictionary = apples => 2, pears => 3;
say("I have %dictionary{$fruit} $fruit");



Matt Follett matt.follett@gmail.com
my @array = 1,2,3;
say(@array[0])

my ($fruit, $jp) = 'apples', JSON.new();
$jp.parse($something_from_somewhere);

my %dictionary = apples => 2, pears => 3;
say("I have %dictionary{$fruit} $fruit");



Matt Follett matt.follett@gmail.com
Optional Typing



      • All variables in Perl 6 have a type, declared like:



               my Str $name = 'Matt Follett';
               $name = 'Matthew Follett';
               $name = 4; # asplode
      • If a type isn’t declared the type is Any


      my $foo = 11;
      say('$foo is an '~ $foo.WHAT); # Any
Matt Follett matt.follett@gmail.com
Types




Matt Follett matt.follett@gmail.com
Custom Type & Enums




            subset Odd of Int where * % 2;
            my Odd $number = 41;

            enum Color <red green blue>;
            my Color $color = red;
            say $color == red; # true (1)
            say $color; # 0
            say $color.key; # 'red'

Matt Follett matt.follett@gmail.com
Custom Type & Enums




            subset Odd of Int where * % 2;
            my Odd $number = 41;

            enum Color <red green blue>;
            my Color $color = red;
            say $color == red; # true (1)
            say $color; # 0
            say $color.key; # 'red'

Matt Follett matt.follett@gmail.com
Custom Type & Enums




            subset Odd of Int where * % 2;
            my Odd $number = 41;

            enum Color <red green blue>;
            my Color $color = red;
            say $color == red; # true (1)
            say $color; # 0
            say $color.key; # 'red'

Matt Follett matt.follett@gmail.com
Custom Type & Enums




            subset Odd of Int where * % 2;
            my Odd $number = 41;

            enum Color <red green blue>;
            my Color $color = red;
            say $color == red; # true (1)
            say $color; # 0
            say $color.key; # 'red'

Matt Follett matt.follett@gmail.com
Custom Type & Enums




            subset Odd of Int where * % 2;
            my Odd $number = 41;

            enum Color <red green blue>;
            my Color $color = red;
            say $color == red; # true (1)
            say $color; # 0
            say $color.key; # 'red'

Matt Follett matt.follett@gmail.com
Custom Type & Enums




            subset Odd of Int where * % 2;
            my Odd $number = 41;

            enum Color <red green blue>;
            my Color $color = red;
            say $color == red; # true (1)
            say $color; # 0
            say $color.key; # 'red'

Matt Follett matt.follett@gmail.com
Custom Type & Enums




            subset Odd of Int where * % 2;
            my Odd $number = 41;

            enum Color <red green blue>;
            my Color $color = red;
            say $color == red; # true (1)
            say $color; # 0
            say $color.key; # 'red'

Matt Follett matt.follett@gmail.com
Classes

• declare:
     attributes
     accessors/mutators
     delegation

• inherit from multiple classes
• define methods
• consume roles




Matt Follett matt.follett@gmail.com
class Employee {
 has Str $.name is rw
      = <Alice Bob Charles Dorothy>.pick;
 has Rat $!salary;
 has Rat $!money = 0;

  method work_on( $project ) {
     say "$.name is working on $project."
  }

    method pay() { $!money += $!salary }
}


Matt Follett matt.follett@gmail.com
class Employee {
 has Str $.name is rw
      = <Alice Bob Charles Dorothy>.pick;
 has Rat $!salary;
 has Rat $!money = 0;

  method work_on( $project ) {
     say "$.name is working on $project."
  }

    method pay() { $!money += $!salary }
}


Matt Follett matt.follett@gmail.com
class Employee {
 has Str $.name is rw
      = <Alice Bob Charles Dorothy>.pick;
 has Rat $!salary;
 has Rat $!money = 0;

  method work_on( $project ) {
     say "$.name is working on $project."
  }

    method pay() { $!money += $!salary }
}


Matt Follett matt.follett@gmail.com
class Employee {
 has Str $.name is rw
      = <Alice Bob Charles Dorothy>.pick;
 has Rat $!salary;
 has Rat $!money = 0;

  method work_on( $project ) {
     say "$.name is working on $project."
  }

    method pay() { $!money += $!salary }
}


Matt Follett matt.follett@gmail.com
class Employee {
 has Str $.name is rw
      = <Alice Bob Charles Dorothy>.pick;
 has Rat $!salary;
 has Rat $!money = 0;

  method work_on( $project ) {
     say "$.name is working on $project."
  }

    method pay() { $!money += $!salary }
}


Matt Follett matt.follett@gmail.com
class Employee {
 has Str $.name is rw
      = <Alice Bob Charles Dorothy>.pick;
 has Rat $!salary;
 has Rat $!money = 0;

  method work_on( $project ) {
     say "$.name is working on $project."
  }

    method pay() { $!money += $!salary }
}


Matt Follett matt.follett@gmail.com
class Manager is Employee
{
    has @.employees is rw;
    has Employee $.assistant
                 is ro handles 'work_on';
}




Matt Follett matt.follett@gmail.com
class Manager is Employee
{
    has @.employees is rw;
    has Employee $.assistant
                 is ro handles 'work_on';
}




Matt Follett matt.follett@gmail.com
class Manager is Employee
{
    has @.employees is rw;
    has Employee $.assistant
                 is ro handles 'work_on';
}




Matt Follett matt.follett@gmail.com
Roles

• Classes consume roles
• Roles provide:
     new methods for a set of tasks (like mix-ins)
     modifications for existing methods

• Roles can be consumed at compile time or run time




Matt Follett matt.follett@gmail.com
role Ergonaut
 {
     method evaluate {
         say 'This ' ~ <chair desk>.pick
           ~ ' ' ~ <is isn't>.pick
           ~ ' ergonomic';
     }
 }



Matt Follett matt.follett@gmail.com
• Compile Time

       class EmployeeErgonaut
             is Employee does Ergonaut
       {}

       • Mixin Style
       my Employee $e1 = Employee.new(
           name    => 'Matt',
           title   => 'software developer',
           salary => 1_000_000
       );
       $e1 does Ergonaut;
Matt Follett matt.follett@gmail.com
Sub Signatures

• positional and named parameters
• Constrain method invocation on:
     number        of variables
     types
     where clauses
     pattern

• or, don’t constrain at all




Matt Follett matt.follett@gmail.com
Plain old Positional




         sub exp($base, $exponent) {
             return $base ** $exponent
         }

         exp( 2, 5) # 32




Matt Follett matt.follett@gmail.com
Named Parameters




         sub exp($base, $exponent) {
              return $base ** $exponent
         }
         exp(
              exponent => 5,
              base     => 2
         )


Matt Follett matt.follett@gmail.com
Strictly Named Parameters




sub draw_circle( $canvas, :$x, :$y,
                 :$radius, :$color )


draw_circle( $canvas2, 3, 2, 3, 442266 );




Matt Follett matt.follett@gmail.com
Strictly Named Parameters




sub draw_circle( $canvas, :$x, :$y,
                 :$radius, :$color )


draw_circle( $canvas2, 3, 2, 3, 442266 );




Matt Follett matt.follett@gmail.com
Strictly Named Parameters




sub draw_circle( $canvas, :$x, :$y,
                 :$radius, :$color )


draw_circle( $canvas2,
     x      => 3,
     y      => 2,
     radius => 3,
     color => ”#442266” );
Matt Follett matt.follett@gmail.com
Constraining Inputs




              sub is_prime(           $input )




Matt Follett matt.follett@gmail.com
Constraining Inputs




              sub is_prime( Int $input )




Matt Follett matt.follett@gmail.com
Constraining Inputs




              sub is_prime( Int $input
                              where * % 2)




Matt Follett matt.follett@gmail.com
Methods as Objects




Matt Follett matt.follett@gmail.com
Methods as Objects

• Curry methods



   sub multiply_numbers(Num $x, Num $y) {
       $x * $y;
   }

   my $mult_by_four =
   &multiply_numbers.assuming(4);



Matt Follett matt.follett@gmail.com
Methods as Objects

• Curry methods
• Wrap around methods


   sub multiply_numbers(Num $x, Num $y) {
       $x * $y;
   }

   my $mult_and_add =
   &multiply_numbers.wrap({$^x+$^y
   +callwith($^x, $^y)});


Matt Follett matt.follett@gmail.com
Methods as Objects

• Curry methods
• Wrap around methods


   sub multiply_numbers(Num $x, Num $y) {
       $x * $y;
   }

   my $mult_and_add =
   &multiply_numbers.wrap({$^x+$^y
   +callwith($^x, $^y)});


Matt Follett matt.follett@gmail.com
Methods as Objects

• Curry methods
• Wrap around methods
• Determine method arity

   sub multiply_numbers(Num $x, Num $y) {
       $x * $y;
   }

   my $arity = &multiply_numbers.arity()




Matt Follett matt.follett@gmail.com
Functional Style Pattern Matching

• Perl subs and methods can do pattern matching in their
  parameter list
• Example:

multi divide($num, 0) {
   die 'floating point exception';
}
multi divide($num, $denom) {
    return $num/$denom
}

divide(11, 0); # dies! (would return Inf)
divide(12, 2); # 6
Matt Follett matt.follett@gmail.com
Functional Style Pattern Matching

• Perl subs and methods can do pattern matching in their
  parameter list
• Example:

multi divide($num, 0) {
   die 'floating point exception';
}
multi divide($num, $denom) {
    return $num/$denom
}

divide(11, 0); # dies! (would return Inf)
divide(12, 2); # 6
Matt Follett matt.follett@gmail.com
Functional Style Pattern Matching

• Perl subs and methods can do pattern matching in their
  parameter list
• Example:

multi divide($num, 0) {
   die 'floating point exception';
}
multi divide($num, $denom) {
    return $num/$denom
}

divide(11, 0); # dies! (would return Inf)
divide(12, 2); # 6
Matt Follett matt.follett@gmail.com
Functional Style Pattern Matching

• Perl subs and methods can do pattern matching in their
  parameter list
• Example:

multi divide($num, 0) {
   die 'floating point exception';
}
multi divide($num, $denom) {
    return $num/$denom
}

divide(11, 0); # dies! (would return Inf)
divide(12, 2); # 6
Matt Follett matt.follett@gmail.com
Functional Style Pattern Matching

• Perl subs and methods can do pattern matching in their
  parameter list
• Example:

multi divide($num, 0) {
   die 'floating point exception';
}
multi divide($num, $denom) {
    return $num/$denom
}

divide(11, 0); # dies! (would return Inf)
divide(12, 2); # 6
Matt Follett matt.follett@gmail.com
Functional Style Pattern Matching

• Perl subs and methods can do pattern matching in their
  parameter list
• Example:

multi divide($num, 0) {
   die 'floating point exception';
}
multi divide($num, $denom) {
    return $num/$denom
}

divide(11, 0); # dies! (would return Inf)
divide(12, 2); # 6
Matt Follett matt.follett@gmail.com
Functional Style Pattern Matching

• Perl subs and methods can do pattern matching in their
  parameter list
• Example:

multi divide($num, 0) {
   die 'floating point exception';
}
multi divide($num, $denom) {
    return $num/$denom
}

divide(11, 0); # dies! (would return Inf)
divide(12, 2); # 6
Matt Follett matt.follett@gmail.com
Functional Style Pattern Matching

• Perl subs and methods can do pattern matching in their
  parameter list
• Example:

multi divide($num, 0) {
   die 'floating point exception';
}
multi divide($num, $denom) {
    return $num/$denom
}

divide(11, 0); # dies! (would return Inf)
divide(12, 2); # 6
Matt Follett matt.follett@gmail.com
λ Functions

• Just as powerful as named functions
• Multiple ways to create
• A building block of the language




Matt Follett matt.follett@gmail.com
Basic Form




my $add_two_nums =
   sub (Real $x, Real $y) {$x+$y};

$add_two_nums(11,12);




Matt Follett matt.follett@gmail.com
Basic Form




my $add_two_nums =
   sub (Real $x, Real $y) {$x+$y};

$add_two_nums(11,12);




Matt Follett matt.follett@gmail.com
With Twigils




my $add_two_nums = sub {$^x+$^y};

$add_two_nums(11,12);




Matt Follett matt.follett@gmail.com
With Twigils




my $add_two_nums = sub {$^x+$^y};

$add_two_nums(11,12);




Matt Follett matt.follett@gmail.com
With Twigils




my $add_two_nums = sub {$^x+$^y};

$add_two_nums(11,12);


my $add_two_nums=sub($x,$y){$x+$y}

Matt Follett matt.follett@gmail.com
λs are Everywhere




          • All blocks are λs


my $add_two_nums = sub {$^x+$^y};

$add_two_nums(11,12);




Matt Follett matt.follett@gmail.com
λs are Everywhere




          • All blocks are λs


my $add_two_nums = sub {$^x+$^y};

$add_two_nums(11,12);




Matt Follett matt.follett@gmail.com
λs are Everywhere




          • All blocks are λs


my $add_two_nums = sub {$^x+$^y};

$add_two_nums(11,12);

my $add_two_nums = ->$x,$y{$x+$y};
$add_two_nums(11,12);

Matt Follett matt.follett@gmail.com
λs are Everywhere




          • All blocks are λs


my $add_two_nums = sub {$^x+$^y};

$add_two_nums(11,12);

my $add_two_nums = ->$x,$y{$x+$y};
$add_two_nums(11,12);

Matt Follett matt.follett@gmail.com
λs are Everywhere




         • All blocks are λs
         • All blocks benefit




                     for 1..10 -> $x
                     { say $x }



Matt Follett matt.follett@gmail.com
λs are Everywhere




         • All blocks are λs
         • All blocks benefit




                     for 1..10
                     { say $^x }



Matt Follett matt.follett@gmail.com
λs are Everywhere




         • All blocks are λs
         • All blocks benefit




                     for 1..10 -> $x, $y
                     { say "$x, $y" }



Matt Follett matt.follett@gmail.com
λs are Everywhere




         • All blocks are λs
         • All blocks benefit




                     for 1..11 -> $x, $y=''
                     { say "$x, $y" }



Matt Follett matt.follett@gmail.com
Simplest Form

• Uses the Whatever term
• Included in a unary or binary operation
• Statement returns a λ
• Examples:
  my $add_two = * + 2;
  $add_two(3); # 5

  my $invoke_method = *.sort;
  $invoke_method(@some_array);



Matt Follett matt.follett@gmail.com
Operators




Matt Follett matt.follett@gmail.com
Operators

• New Operators
• Better range operator
• Chaining Binary Operators
• New Types of Operators
     Meta Operators
     Junctive Operators

• More powerful custom operators




Matt Follett matt.follett@gmail.com
Range Operator




Matt Follett matt.follett@gmail.com
Range Operator

• Creates lazily evaluated lists:
    my @N := 0...*




Matt Follett matt.follett@gmail.com
Range Operator

• Creates lazily evaluated lists:
    my @N := 0...*




Matt Follett matt.follett@gmail.com
Range Operator

• Creates lazily evaluated lists:
    my @N := 0...*
• Basic form is very smart, versatile:

    my @negatives := -1,-2...*
    my @multiples_of_two := 0,2,4...*
    my @powers_of_two := 0,2,4,8...*
    my @letters = 'a'...'z'




Matt Follett matt.follett@gmail.com
Range Operator

• Creates lazily evaluated lists:
    my @N := 0...*
• Basic form is very smart, versatile:

    my @negatives := -1,-2...*
    my @multiples_of_two := 0,2,4...*
    my @powers_of_two := 0,2,4,8...*
    my @letters = 'a'...'z'




Matt Follett matt.follett@gmail.com
Range Operator

• Creates lazily evaluated lists:
    my @N := 0...*
• Basic form is very smart, versatile:

    my @negatives := -1,-2...*
    my @multiples_of_two := 0,2,4...*
    my @powers_of_two := 0,2,4,8...*
    my @letters = 'a'...'z'




Matt Follett matt.follett@gmail.com
Range Operator

• Creates lazily evaluated lists:
    my @N := 0...*
• Basic form is very smart, versatile:

    my @negatives := -1,-2...*
    my @multiples_of_two := 0,2,4...*
    my @powers_of_two := 0,2,4,8...*
    my @letters = 'a'...'z'




Matt Follett matt.follett@gmail.com
Range Operator

• Creates lazily evaluated lists:
    my @N := 0...*
• Basic form is very smart, versatile:

    my @negatives := -1,-2...*
    my @multiples_of_two := 0,2,4...*
    my @powers_of_two := 0,2,4,8...*
    my @letters = 'a'...'z'




Matt Follett matt.follett@gmail.com
Range Operator

• Creates lazily evaluated lists:
    my @N := 0...*
• Basic form is very smart, versatile:

    my @negatives := -1,-2...*
    my @multiples_of_two := 0,2,4...*
    my @powers_of_two := 0,2,4,8...*
    my @letters = 'a'...'z'
• Advanced form takes λs for iterator and ending condition:
    my @fib := 0,1,*+*...*
    my @double_letters := 'a'...* eq 'zz'

Matt Follett matt.follett@gmail.com
Range Operator

• Creates lazily evaluated lists:
    my @N := 0...*
• Basic form is very smart, versatile:

    my @negatives := -1,-2...*
    my @multiples_of_two := 0,2,4...*
    my @powers_of_two := 0,2,4,8...*
    my @letters = 'a'...'z'
• Advanced form takes λs for iterator and ending condition:
    my @fib := 0,1,*+*...*
    my @double_letters := 'a'...* eq 'zz'

Matt Follett matt.follett@gmail.com
Range Operator

• Creates lazily evaluated lists:
    my @N := 0...*
• Basic form is very smart, versatile:

    my @negatives := -1,-2...*
    my @multiples_of_two := 0,2,4...*
    my @powers_of_two := 0,2,4,8...*
    my @letters = 'a'...'z'
• Advanced form takes λs for iterator and ending condition:
    my @fib := 0,1,*+*...*
    my @double_letters := 'a'...* eq 'zz'

Matt Follett matt.follett@gmail.com
Range Operator

• Creates lazily evaluated lists:
    my @N := 0...*
• Basic form is very smart, versatile:

    my @negatives := -1,-2...*
    my @multiples_of_two := 0,2,4...*
    my @powers_of_two := 0,2,4,8...*
    my @letters = 'a'...'z'
• Advanced form takes λs for iterator and ending condition:
    my @fib := 0,1,*+*...*
    my @double_letters := 'a'...* eq 'zz'

Matt Follett matt.follett@gmail.com
Range Operator

• Creates lazily evaluated lists:
    my @N := 0...*
• Basic form is very smart, versatile:

    my @negatives := -1,-2...*
    my @multiples_of_two := 0,2,4...*
    my @powers_of_two := 0,2,4,8...*
    my @letters = 'a'...'z'
• Advanced form takes λs for iterator and ending condition:
    my @fib := 0,1,*+*...*
    my @double_letters := 'a'...* eq 'zz'

Matt Follett matt.follett@gmail.com
Meta Operators

• Meta operators are operators who’s operand is another
  operator
• Simplify writing operators
• Provide new strengths
     meta  reduction operator
     cross meta operator
     hyperoperator




Matt Follett matt.follett@gmail.com
Meta Operators Simplifying Operators

• Assignment operators
        A op= B
     example:

   @names .= sort
• Negated relational operators
     infix
          relational operators can all be negated by prepending ‘!’
     example:


    $foo !< 11




Matt Follett matt.follett@gmail.com
Reduction Meta Operator

• Written as []
• Takes a list and reduces it to a scalar value
• uses a specified infix operator
• like foldl, foldr but respects associativity
• Examples:
   [*] 1..$x
   [**] 1..$x # 1 ** ( 2 ** ( 3 **…$x ) )
   [<] @list or [>] @list




Matt Follett matt.follett@gmail.com
Reduction Meta Operator

• Written as []
• Takes a list and reduces it to a scalar value
• uses a specified infix operator
• like foldl, foldr but respects associativity
• Examples:
   [*] 1..$x
   [**] 1..$x # 1 ** ( 2 ** ( 3 **…$x ) )
   [<] @list or [>] @list




Matt Follett matt.follett@gmail.com
Reduction Meta Operator

• Written as []
• Takes a list and reduces it to a scalar value
• uses a specified infix operator
• like foldl, foldr but respects associativity
• Examples:
   [*] 1..$x
   [**] 1..$x # 1 ** ( 2 ** ( 3 **…$x ) )
   [<] @list or [>] @list




Matt Follett matt.follett@gmail.com
Reduction Meta Operator

• Written as []
• Takes a list and reduces it to a scalar value
• uses a specified infix operator
• like foldl, foldr but respects associativity
• Examples:
   [*] 1..$x
   [**] 1..$x # 1 ** ( 2 ** ( 3 **…$x ) )
   [<] @list or [>] @list




Matt Follett matt.follett@gmail.com
Hyper Meta Operator

• Written as Unicode ‘»’, ‘«‘ or ASCII ‘>>’, ‘<<‘
• Performs the operations as fast as possible
• Can parallelize these operations
• Does not guarantee order of results
• Examples:

 (1..10) >>+<< (21..30);
 my @nums_squared = @nums >>**>> 2;

 my @hellos = "Hello, " <<~<< <Christian
             John Michael Eleanor Chris>;

 @hellos>>.say;
Matt Follett matt.follett@gmail.com
Hyper Meta Operator

• Written as Unicode ‘»’, ‘«‘ or ASCII ‘>>’, ‘<<‘
• Performs the operations as fast as possible
• Can parallelize these operations
• Does not guarantee order of results
• Examples:

 (1..10) >>+<< (21..30);
 my @nums_squared = @nums >>**>> 2;

 my @hellos = "Hello, " <<~<< <Christian
             John Michael Eleanor Chris>;

 @hellos>>.say;
Matt Follett matt.follett@gmail.com
Hyper Meta Operator

• Written as Unicode ‘»’, ‘«‘ or ASCII ‘>>’, ‘<<‘
• Performs the operations as fast as possible
• Can parallelize these operations
• Does not guarantee order of results
• Examples:

 (1..10) >>+<< (21..30);
 my @nums_squared = @nums >>**>> 2;

 my @hellos = "Hello, " <<~<< <Christian
             John Michael Eleanor Chris>;

 @hellos>>.say;
Matt Follett matt.follett@gmail.com
Hyper Meta Operator

• Written as Unicode ‘»’, ‘«‘ or ASCII ‘>>’, ‘<<‘
• Performs the operations as fast as possible
• Can parallelize these operations
• Does not guarantee order of results
• Examples:

 (1..10) >>+<< (21..30);
 my @nums_squared = @nums >>**>> 2;

 my @hellos = "Hello, " <<~<< <Christian
             John Michael Eleanor Chris>;

 @hellos>>.say;
Matt Follett matt.follett@gmail.com
Hyper Meta Operator

• Written as Unicode ‘»’, ‘«‘ or ASCII ‘>>’, ‘<<‘
• Performs the operations as fast as possible
• Can parallelize these operations
• Does not guarantee order of results
• Examples:

 (1..10) >>+<< (21..30);
 my @nums_squared = @nums >>**>> 2;

 my @hellos = "Hello, " <<~<< <Christian
             John Michael Eleanor Chris>;

 @hellos>>.say;
Matt Follett matt.follett@gmail.com
Cross Meta Operator

• Written as ‘X’
• Crosses two arrays, making tuples of each cell then applying
  the operator to them
• examples:

(1,2) X* (3,4);




Matt Follett matt.follett@gmail.com
Cross Meta Operator

• Written as ‘X’
• Crosses two arrays, making tuples of each cell then applying
  the operator to them
• examples:

(1,2) X* (3,4);#((1,3),(1,4)(2,3),(2,4))




Matt Follett matt.follett@gmail.com
Cross Meta Operator

• Written as ‘X’
• Crosses two arrays, making tuples of each cell then applying
  the operator to them
• examples:

(1,2) X* (3,4);#((1*3),(1*4)(2*3),(2*4))




Matt Follett matt.follett@gmail.com
Cross Meta Operator

• Written as ‘X’
• Crosses two arrays, making tuples of each cell then applying
  the operator to them
• examples:

(1,2) X* (3,4);#(3,4,6,8)




Matt Follett matt.follett@gmail.com
Cross Meta Operator

• Written as ‘X’
• Crosses two arrays, making tuples of each cell then applying
  the operator to them
• examples:

(1,2) X* (3,4);#(3,4,6,8)
 <                                > X~ ('A',2..10,'J','Q','K');




Matt Follett matt.follett@gmail.com
Junctive Operators

• A variable can be any of some number of values via ‘|’
• A variable can be all of some number of values via ‘&’
  my $superposition = 4 | 5 | 6;
  $superposition += 1; # 5|6|7
  6 ~~ $superposition; #true
  9 ~~ $superposition; #false

  my $qualifications = *.can('sort')
                     & *.can('push')
                     & *.can('pop');
  @array ~~ $qualifications; # true
  $scalar ~~ $qualifications; # false
Matt Follett matt.follett@gmail.com
Junctive Operators

• A variable can be any of some number of values via ‘|’
• A variable can be all of some number of values via ‘&’
  my $superposition = 4 | 5 | 6;
  $superposition += 1; # 5|6|7
  6 ~~ $superposition; #true
  9 ~~ $superposition; #false

  my $qualifications = *.can('sort')
                     & *.can('push')
                     & *.can('pop');
  @array ~~ $qualifications; # true
  $scalar ~~ $qualifications; # false
Matt Follett matt.follett@gmail.com
Junctive Operators

• A variable can be any of some number of values via ‘|’
• A variable can be all of some number of values via ‘&’
  my $superposition = 4 | 5 | 6;
  $superposition += 1; # 5|6|7
  6 ~~ $superposition; #true
  9 ~~ $superposition; #false

  my $qualifications = *.can('sort')
                     & *.can('push')
                     & *.can('pop');
  @array ~~ $qualifications; # true
  $scalar ~~ $qualifications; # false
Matt Follett matt.follett@gmail.com
Junctive Operators

• A variable can be any of some number of values via ‘|’
• A variable can be all of some number of values via ‘&’
  my $superposition = 4 | 5 | 6;
  $superposition += 1; # 5|6|7
  6 ~~ $superposition; #true
  9 ~~ $superposition; #false

  my $qualifications = *.can('sort')
                     & *.can('push')
                     & *.can('pop');
  @array ~~ $qualifications; # true
  $scalar ~~ $qualifications; # false
Matt Follett matt.follett@gmail.com
Junctive Operators

• A variable can be any of some number of values via ‘|’
• A variable can be all of some number of values via ‘&’
  my $superposition = 4 | 5 | 6;
  $superposition += 1; # 5|6|7
  6 ~~ $superposition; #true
  9 ~~ $superposition; #false

  my $qualifications = *.can('sort')
                     & *.can('push')
                     & *.can('pop');
  @array ~~ $qualifications; # true
  $scalar ~~ $qualifications; # false
Matt Follett matt.follett@gmail.com
Junctive Operators

• A variable can be any of some number of values via ‘|’
• A variable can be all of some number of values via ‘&’
  my $superposition = 4 | 5 | 6;
  $superposition += 1; # 5|6|7
  6 ~~ $superposition; #true
  9 ~~ $superposition; #false

  my $qualifications = *.can('sort')
                     & *.can('push')
                     & *.can('pop');
  @array ~~ $qualifications; # true
  $scalar ~~ $qualifications; # false
Matt Follett matt.follett@gmail.com
Custom Operators

• Any unicode string
• Define precedence
     ‘is tighter’ - higher precedence than the given operator
     ‘is looser’ - lower precedence
     ‘is equiv’ - same precedence

• Many types
     infix
     postfix
     prefix
     circumfix
     postcircumfix




Matt Follett matt.follett@gmail.com
Custom Operator Example




 sub infix:<⊕> ($a, $b) is tighter(&infix:<*>)
 {
             sqrt($a**2+$b**2);
 };

 say 2 ⊕ 4;




Matt Follett matt.follett@gmail.com
Custom Operator Example




 sub infix:<⊕> ($a, $b) is tighter(&infix:<*>)
 {
             sqrt($a**2+$b**2);
 };

 say 2 ⊕ 4;




Matt Follett matt.follett@gmail.com
Grammars

• Composed of rules and tokens
• Reusable through inheritance
• Defined like classes or modules
• starts from the TOP rule




Matt Follett matt.follett@gmail.com
grammar Mercurial::rc {
 rule TOP {^<line>*$};
 rule line {<header>|<assignment>|<comment>};
    rule header {'[' ~ ']' <header_name> };
    rule assignment {<variable>'='<value>};
    rule comment { '#' <message> };

    token           header_name {w<-[]]>+};
    token           variable {<-[=]>+};
    token           value {.*};
    token           message {.*};
}
Matt Follett matt.follett@gmail.com
[ui]
                             username=Matt Follett
                             email=matt.follett@gmail.com

                             [extensions]
                             #best extension ever!
                             hg.cowlog=



Matt Follett matt.follett@gmail.com
Where to go for more

• Try Rakudo: http://try.rakudo.org
• Using Perl 6: http://github.com/perl6/book/downloads
• Get Rakudo: http://rakudo.org/how-to-get-rakudo
• The official Perl 6 site: http://www.perl6.org
• Perl 6 synopses: http://perlcabal.org/syn/
• Planet Perl 6: http://planetsix.perl.org/
• Rosetta Code: http://www.rosettacode.org
• My posts: http://mfollett.com/tag/perl6




Matt Follett matt.follett@gmail.com

Más contenido relacionado

La actualidad más candente

Wx::Perl::Smart
Wx::Perl::SmartWx::Perl::Smart
Wx::Perl::Smartlichtkind
 
Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)brian d foy
 
Perl 5.10 for People Who Aren't Totally Insane
Perl 5.10 for People Who Aren't Totally InsanePerl 5.10 for People Who Aren't Totally Insane
Perl 5.10 for People Who Aren't Totally InsaneRicardo Signes
 
Perl 101 - The Basics of Perl Programming
Perl  101 - The Basics of Perl ProgrammingPerl  101 - The Basics of Perl Programming
Perl 101 - The Basics of Perl ProgrammingUtkarsh Sengar
 
Zend Certification Preparation Tutorial
Zend Certification Preparation TutorialZend Certification Preparation Tutorial
Zend Certification Preparation TutorialLorna Mitchell
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottO'Reilly Media
 
Intermediate Perl
Intermediate PerlIntermediate Perl
Intermediate PerlDave Cross
 
PERL for QA - Important Commands and applications
PERL for QA - Important Commands and applicationsPERL for QA - Important Commands and applications
PERL for QA - Important Commands and applicationsSunil Kumar Gunasekaran
 
Improving Dev Assistant
Improving Dev AssistantImproving Dev Assistant
Improving Dev AssistantDave Cross
 
PHP7. Game Changer.
PHP7. Game Changer. PHP7. Game Changer.
PHP7. Game Changer. Haim Michael
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1Dave Cross
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to PerlDave Cross
 
Business Rules with Brick
Business Rules with BrickBusiness Rules with Brick
Business Rules with Brickbrian d foy
 
Learning Perl 6
Learning Perl 6 Learning Perl 6
Learning Perl 6 brian d foy
 
Learning Perl 6 (NPW 2007)
Learning Perl 6 (NPW 2007)Learning Perl 6 (NPW 2007)
Learning Perl 6 (NPW 2007)brian d foy
 
Climbing the Abstract Syntax Tree (IPC Fall 2017)
Climbing the Abstract Syntax Tree (IPC Fall 2017)Climbing the Abstract Syntax Tree (IPC Fall 2017)
Climbing the Abstract Syntax Tree (IPC Fall 2017)James Titcumb
 
Climbing the Abstract Syntax Tree (Bulgaria PHP 2016)
Climbing the Abstract Syntax Tree (Bulgaria PHP 2016)Climbing the Abstract Syntax Tree (Bulgaria PHP 2016)
Climbing the Abstract Syntax Tree (Bulgaria PHP 2016)James Titcumb
 
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)James Titcumb
 

La actualidad más candente (20)

Wx::Perl::Smart
Wx::Perl::SmartWx::Perl::Smart
Wx::Perl::Smart
 
Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)
 
Perl 5.10 for People Who Aren't Totally Insane
Perl 5.10 for People Who Aren't Totally InsanePerl 5.10 for People Who Aren't Totally Insane
Perl 5.10 for People Who Aren't Totally Insane
 
PHP - Introduction to String Handling
PHP -  Introduction to  String Handling PHP -  Introduction to  String Handling
PHP - Introduction to String Handling
 
Perl 101 - The Basics of Perl Programming
Perl  101 - The Basics of Perl ProgrammingPerl  101 - The Basics of Perl Programming
Perl 101 - The Basics of Perl Programming
 
Zend Certification Preparation Tutorial
Zend Certification Preparation TutorialZend Certification Preparation Tutorial
Zend Certification Preparation Tutorial
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter Scott
 
Intermediate Perl
Intermediate PerlIntermediate Perl
Intermediate Perl
 
PERL for QA - Important Commands and applications
PERL for QA - Important Commands and applicationsPERL for QA - Important Commands and applications
PERL for QA - Important Commands and applications
 
Improving Dev Assistant
Improving Dev AssistantImproving Dev Assistant
Improving Dev Assistant
 
PHP7. Game Changer.
PHP7. Game Changer. PHP7. Game Changer.
PHP7. Game Changer.
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Business Rules with Brick
Business Rules with BrickBusiness Rules with Brick
Business Rules with Brick
 
Learning Perl 6
Learning Perl 6 Learning Perl 6
Learning Perl 6
 
Learning Perl 6 (NPW 2007)
Learning Perl 6 (NPW 2007)Learning Perl 6 (NPW 2007)
Learning Perl 6 (NPW 2007)
 
Working with text, Regular expressions
Working with text, Regular expressionsWorking with text, Regular expressions
Working with text, Regular expressions
 
Climbing the Abstract Syntax Tree (IPC Fall 2017)
Climbing the Abstract Syntax Tree (IPC Fall 2017)Climbing the Abstract Syntax Tree (IPC Fall 2017)
Climbing the Abstract Syntax Tree (IPC Fall 2017)
 
Climbing the Abstract Syntax Tree (Bulgaria PHP 2016)
Climbing the Abstract Syntax Tree (Bulgaria PHP 2016)Climbing the Abstract Syntax Tree (Bulgaria PHP 2016)
Climbing the Abstract Syntax Tree (Bulgaria PHP 2016)
 
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
 

Similar a Perl 6 talk

Scripting3
Scripting3Scripting3
Scripting3Nao Dara
 
Perl Xpath Lightning Talk
Perl Xpath Lightning TalkPerl Xpath Lightning Talk
Perl Xpath Lightning Talkddn123456
 
Whatsnew in-perl
Whatsnew in-perlWhatsnew in-perl
Whatsnew in-perldaoswald
 
Migrating to Puppet 4.0
Migrating to Puppet 4.0Migrating to Puppet 4.0
Migrating to Puppet 4.0Puppet
 
ScotRuby - Dark side of ruby
ScotRuby - Dark side of rubyScotRuby - Dark side of ruby
ScotRuby - Dark side of rubyGautam Rege
 
Ruby - Uma Introdução
Ruby - Uma IntroduçãoRuby - Uma Introdução
Ruby - Uma IntroduçãoÍgor Bonadio
 
Writing Maintainable Perl
Writing Maintainable PerlWriting Maintainable Perl
Writing Maintainable Perltinypigdotcom
 
2010/7/31 LTの虎@LL Tiger
2010/7/31 LTの虎@LL Tiger2010/7/31 LTの虎@LL Tiger
2010/7/31 LTの虎@LL TigerAkihiro Okuno
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Wen-Tien Chang
 
Code with Style - PyOhio
Code with Style - PyOhioCode with Style - PyOhio
Code with Style - PyOhioClayton Parker
 
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013Puppet
 
Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Contextlichtkind
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In PerlKang-min Liu
 
Puppet future parser
Puppet future parserPuppet future parser
Puppet future parserMartin Alfke
 

Similar a Perl 6 talk (20)

Scripting3
Scripting3Scripting3
Scripting3
 
Perl Xpath Lightning Talk
Perl Xpath Lightning TalkPerl Xpath Lightning Talk
Perl Xpath Lightning Talk
 
Whatsnew in-perl
Whatsnew in-perlWhatsnew in-perl
Whatsnew in-perl
 
Migrating to Puppet 4.0
Migrating to Puppet 4.0Migrating to Puppet 4.0
Migrating to Puppet 4.0
 
Introducing perl6
Introducing perl6Introducing perl6
Introducing perl6
 
ScotRuby - Dark side of ruby
ScotRuby - Dark side of rubyScotRuby - Dark side of ruby
ScotRuby - Dark side of ruby
 
Ruby - Uma Introdução
Ruby - Uma IntroduçãoRuby - Uma Introdução
Ruby - Uma Introdução
 
Writing Maintainable Perl
Writing Maintainable PerlWriting Maintainable Perl
Writing Maintainable Perl
 
2010/7/31 LTの虎@LL Tiger
2010/7/31 LTの虎@LL Tiger2010/7/31 LTの虎@LL Tiger
2010/7/31 LTの虎@LL Tiger
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手
 
Code with Style - PyOhio
Code with Style - PyOhioCode with Style - PyOhio
Code with Style - PyOhio
 
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
 
Starting Out With PHP
Starting Out With PHPStarting Out With PHP
Starting Out With PHP
 
Python slide
Python slidePython slide
Python slide
 
Code with style
Code with styleCode with style
Code with style
 
php_string.pdf
php_string.pdfphp_string.pdf
php_string.pdf
 
Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Context
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
Intro to Perl and Bioperl
Intro to Perl and BioperlIntro to Perl and Bioperl
Intro to Perl and Bioperl
 
Puppet future parser
Puppet future parserPuppet future parser
Puppet future parser
 

Último

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 

Último (20)

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 

Perl 6 talk

  • 1. Perl 6 An Apocalypse The Camelia image is copyright 2009 and trademarked by Larry Wall Matt Follett matt.follett@gmail.com
  • 2. Instance of Perl 6 • Pugs - Perl 6 on Haskell • Niecza - Perl 6 on the CLR • Sprixel - Perl 6 in JavaScript • Elf, Mildew • Perlito (MiniPerl6) - JVM, Go, Perl 5, JS, Lisp • YAPSI - Perl 6 in Perl 6 • Rakudo - Perl 6 on Parrot Matt Follett matt.follett@gmail.com
  • 3. Instance of Perl 6 • Pugs - Perl 6 on Haskell • Niecza - Perl 6 on the CLR • Sprixel - Perl 6 in JavaScript • Elf, Mildew • Perlito (MiniPerl6) - JVM, Go, Perl 5, JS, Lisp • YAPSI - Perl 6 in Perl 6 • Rakudo - Perl 6 on Parrot Matt Follett matt.follett@gmail.com
  • 5. The Backstory • Perl 6 announced at Perl Conference in 2000 • Immediate RFCs • First apocalypse on April 2, 2001 • Twelfth apocalypse April 13, 2004 Matt Follett matt.follett@gmail.com http://www.perlfoundation.org/perl6/index.cgi?timeline
  • 6. More Backstory • Parrot April Fool’s Joke 2001 • First commit to Parrot on August 29, 2001 • Audrey Tang publicly releases Pugs in February of 2005 Matt Follett matt.follett@gmail.com
  • 7. Recent History • Parrot starts monthly releases in January 2007 • Parrot starts major releases on a yearly cycle in 2010 • Rakudo * monthly releases start in July 2010 Matt Follett matt.follett@gmail.com
  • 8. Recent History • Parrot starts monthly releases in January 2007 • Parrot starts major releases on a yearly cycle in 2010 • Rakudo * monthly releases start in July 2010 Matt Follett matt.follett@gmail.com
  • 9. Rakudo * • a useful, usable, "early adopter" distribution of Perl 6  nota 1.0  compile yourself • Includes modules for XML, JSON, YAML, database interfaces, etc • includes neutro • Helps get feedback to the Rakudo team Matt Follett matt.follett@gmail.com
  • 10. Feedback = Improvements Matt Follett matt.follett@gmail.com http://gil.di.uminho.pt/users/smash/rakudo-bench.html
  • 11. The Basics • Variables are prepended with a sigil to indicate their basic type (scalar, array, hash) • These sigils are invariant • Variables declared with ‘my’ are lexically scoped • Perl 6 autoboxes Matt Follett matt.follett@gmail.com
  • 12. my @array = 1,2,3; say(@array[0]) my ($fruit, $jp) = 'apples', JSON.new(); $jp.parse($something_from_somewhere); my %dictionary = apples => 2, pears => 3; say("I have %dictionary{$fruit} $fruit"); Matt Follett matt.follett@gmail.com
  • 13. my @array = 1,2,3; say(@array[0]) my ($fruit, $jp) = 'apples', JSON.new(); $jp.parse($something_from_somewhere); my %dictionary = apples => 2, pears => 3; say("I have %dictionary{$fruit} $fruit"); Matt Follett matt.follett@gmail.com
  • 14. my @array = 1,2,3; say(@array[0]) my ($fruit, $jp) = 'apples', JSON.new(); $jp.parse($something_from_somewhere); my %dictionary = apples => 2, pears => 3; say("I have %dictionary{$fruit} $fruit"); Matt Follett matt.follett@gmail.com
  • 15. my @array = 1,2,3; say(@array[0]) my ($fruit, $jp) = 'apples', JSON.new(); $jp.parse($something_from_somewhere); my %dictionary = apples => 2, pears => 3; say("I have %dictionary{$fruit} $fruit"); Matt Follett matt.follett@gmail.com
  • 16. Optional Typing • All variables in Perl 6 have a type, declared like: my Str $name = 'Matt Follett'; $name = 'Matthew Follett'; $name = 4; # asplode • If a type isn’t declared the type is Any my $foo = 11; say('$foo is an '~ $foo.WHAT); # Any Matt Follett matt.follett@gmail.com
  • 18. Custom Type & Enums subset Odd of Int where * % 2; my Odd $number = 41; enum Color <red green blue>; my Color $color = red; say $color == red; # true (1) say $color; # 0 say $color.key; # 'red' Matt Follett matt.follett@gmail.com
  • 19. Custom Type & Enums subset Odd of Int where * % 2; my Odd $number = 41; enum Color <red green blue>; my Color $color = red; say $color == red; # true (1) say $color; # 0 say $color.key; # 'red' Matt Follett matt.follett@gmail.com
  • 20. Custom Type & Enums subset Odd of Int where * % 2; my Odd $number = 41; enum Color <red green blue>; my Color $color = red; say $color == red; # true (1) say $color; # 0 say $color.key; # 'red' Matt Follett matt.follett@gmail.com
  • 21. Custom Type & Enums subset Odd of Int where * % 2; my Odd $number = 41; enum Color <red green blue>; my Color $color = red; say $color == red; # true (1) say $color; # 0 say $color.key; # 'red' Matt Follett matt.follett@gmail.com
  • 22. Custom Type & Enums subset Odd of Int where * % 2; my Odd $number = 41; enum Color <red green blue>; my Color $color = red; say $color == red; # true (1) say $color; # 0 say $color.key; # 'red' Matt Follett matt.follett@gmail.com
  • 23. Custom Type & Enums subset Odd of Int where * % 2; my Odd $number = 41; enum Color <red green blue>; my Color $color = red; say $color == red; # true (1) say $color; # 0 say $color.key; # 'red' Matt Follett matt.follett@gmail.com
  • 24. Custom Type & Enums subset Odd of Int where * % 2; my Odd $number = 41; enum Color <red green blue>; my Color $color = red; say $color == red; # true (1) say $color; # 0 say $color.key; # 'red' Matt Follett matt.follett@gmail.com
  • 25. Classes • declare:  attributes  accessors/mutators  delegation • inherit from multiple classes • define methods • consume roles Matt Follett matt.follett@gmail.com
  • 26. class Employee { has Str $.name is rw = <Alice Bob Charles Dorothy>.pick; has Rat $!salary; has Rat $!money = 0; method work_on( $project ) { say "$.name is working on $project." } method pay() { $!money += $!salary } } Matt Follett matt.follett@gmail.com
  • 27. class Employee { has Str $.name is rw = <Alice Bob Charles Dorothy>.pick; has Rat $!salary; has Rat $!money = 0; method work_on( $project ) { say "$.name is working on $project." } method pay() { $!money += $!salary } } Matt Follett matt.follett@gmail.com
  • 28. class Employee { has Str $.name is rw = <Alice Bob Charles Dorothy>.pick; has Rat $!salary; has Rat $!money = 0; method work_on( $project ) { say "$.name is working on $project." } method pay() { $!money += $!salary } } Matt Follett matt.follett@gmail.com
  • 29. class Employee { has Str $.name is rw = <Alice Bob Charles Dorothy>.pick; has Rat $!salary; has Rat $!money = 0; method work_on( $project ) { say "$.name is working on $project." } method pay() { $!money += $!salary } } Matt Follett matt.follett@gmail.com
  • 30. class Employee { has Str $.name is rw = <Alice Bob Charles Dorothy>.pick; has Rat $!salary; has Rat $!money = 0; method work_on( $project ) { say "$.name is working on $project." } method pay() { $!money += $!salary } } Matt Follett matt.follett@gmail.com
  • 31. class Employee { has Str $.name is rw = <Alice Bob Charles Dorothy>.pick; has Rat $!salary; has Rat $!money = 0; method work_on( $project ) { say "$.name is working on $project." } method pay() { $!money += $!salary } } Matt Follett matt.follett@gmail.com
  • 32. class Manager is Employee { has @.employees is rw; has Employee $.assistant is ro handles 'work_on'; } Matt Follett matt.follett@gmail.com
  • 33. class Manager is Employee { has @.employees is rw; has Employee $.assistant is ro handles 'work_on'; } Matt Follett matt.follett@gmail.com
  • 34. class Manager is Employee { has @.employees is rw; has Employee $.assistant is ro handles 'work_on'; } Matt Follett matt.follett@gmail.com
  • 35. Roles • Classes consume roles • Roles provide:  new methods for a set of tasks (like mix-ins)  modifications for existing methods • Roles can be consumed at compile time or run time Matt Follett matt.follett@gmail.com
  • 36. role Ergonaut { method evaluate { say 'This ' ~ <chair desk>.pick ~ ' ' ~ <is isn't>.pick ~ ' ergonomic'; } } Matt Follett matt.follett@gmail.com
  • 37. • Compile Time class EmployeeErgonaut is Employee does Ergonaut {} • Mixin Style my Employee $e1 = Employee.new( name => 'Matt', title => 'software developer', salary => 1_000_000 ); $e1 does Ergonaut; Matt Follett matt.follett@gmail.com
  • 38. Sub Signatures • positional and named parameters • Constrain method invocation on:  number of variables  types  where clauses  pattern • or, don’t constrain at all Matt Follett matt.follett@gmail.com
  • 39. Plain old Positional sub exp($base, $exponent) { return $base ** $exponent } exp( 2, 5) # 32 Matt Follett matt.follett@gmail.com
  • 40. Named Parameters sub exp($base, $exponent) { return $base ** $exponent } exp( exponent => 5, base => 2 ) Matt Follett matt.follett@gmail.com
  • 41. Strictly Named Parameters sub draw_circle( $canvas, :$x, :$y, :$radius, :$color ) draw_circle( $canvas2, 3, 2, 3, 442266 ); Matt Follett matt.follett@gmail.com
  • 42. Strictly Named Parameters sub draw_circle( $canvas, :$x, :$y, :$radius, :$color ) draw_circle( $canvas2, 3, 2, 3, 442266 ); Matt Follett matt.follett@gmail.com
  • 43. Strictly Named Parameters sub draw_circle( $canvas, :$x, :$y, :$radius, :$color ) draw_circle( $canvas2, x => 3, y => 2, radius => 3, color => ”#442266” ); Matt Follett matt.follett@gmail.com
  • 44. Constraining Inputs sub is_prime( $input ) Matt Follett matt.follett@gmail.com
  • 45. Constraining Inputs sub is_prime( Int $input ) Matt Follett matt.follett@gmail.com
  • 46. Constraining Inputs sub is_prime( Int $input where * % 2) Matt Follett matt.follett@gmail.com
  • 47. Methods as Objects Matt Follett matt.follett@gmail.com
  • 48. Methods as Objects • Curry methods sub multiply_numbers(Num $x, Num $y) { $x * $y; } my $mult_by_four = &multiply_numbers.assuming(4); Matt Follett matt.follett@gmail.com
  • 49. Methods as Objects • Curry methods • Wrap around methods sub multiply_numbers(Num $x, Num $y) { $x * $y; } my $mult_and_add = &multiply_numbers.wrap({$^x+$^y +callwith($^x, $^y)}); Matt Follett matt.follett@gmail.com
  • 50. Methods as Objects • Curry methods • Wrap around methods sub multiply_numbers(Num $x, Num $y) { $x * $y; } my $mult_and_add = &multiply_numbers.wrap({$^x+$^y +callwith($^x, $^y)}); Matt Follett matt.follett@gmail.com
  • 51. Methods as Objects • Curry methods • Wrap around methods • Determine method arity sub multiply_numbers(Num $x, Num $y) { $x * $y; } my $arity = &multiply_numbers.arity() Matt Follett matt.follett@gmail.com
  • 52. Functional Style Pattern Matching • Perl subs and methods can do pattern matching in their parameter list • Example: multi divide($num, 0) { die 'floating point exception'; } multi divide($num, $denom) { return $num/$denom } divide(11, 0); # dies! (would return Inf) divide(12, 2); # 6 Matt Follett matt.follett@gmail.com
  • 53. Functional Style Pattern Matching • Perl subs and methods can do pattern matching in their parameter list • Example: multi divide($num, 0) { die 'floating point exception'; } multi divide($num, $denom) { return $num/$denom } divide(11, 0); # dies! (would return Inf) divide(12, 2); # 6 Matt Follett matt.follett@gmail.com
  • 54. Functional Style Pattern Matching • Perl subs and methods can do pattern matching in their parameter list • Example: multi divide($num, 0) { die 'floating point exception'; } multi divide($num, $denom) { return $num/$denom } divide(11, 0); # dies! (would return Inf) divide(12, 2); # 6 Matt Follett matt.follett@gmail.com
  • 55. Functional Style Pattern Matching • Perl subs and methods can do pattern matching in their parameter list • Example: multi divide($num, 0) { die 'floating point exception'; } multi divide($num, $denom) { return $num/$denom } divide(11, 0); # dies! (would return Inf) divide(12, 2); # 6 Matt Follett matt.follett@gmail.com
  • 56. Functional Style Pattern Matching • Perl subs and methods can do pattern matching in their parameter list • Example: multi divide($num, 0) { die 'floating point exception'; } multi divide($num, $denom) { return $num/$denom } divide(11, 0); # dies! (would return Inf) divide(12, 2); # 6 Matt Follett matt.follett@gmail.com
  • 57. Functional Style Pattern Matching • Perl subs and methods can do pattern matching in their parameter list • Example: multi divide($num, 0) { die 'floating point exception'; } multi divide($num, $denom) { return $num/$denom } divide(11, 0); # dies! (would return Inf) divide(12, 2); # 6 Matt Follett matt.follett@gmail.com
  • 58. Functional Style Pattern Matching • Perl subs and methods can do pattern matching in their parameter list • Example: multi divide($num, 0) { die 'floating point exception'; } multi divide($num, $denom) { return $num/$denom } divide(11, 0); # dies! (would return Inf) divide(12, 2); # 6 Matt Follett matt.follett@gmail.com
  • 59. Functional Style Pattern Matching • Perl subs and methods can do pattern matching in their parameter list • Example: multi divide($num, 0) { die 'floating point exception'; } multi divide($num, $denom) { return $num/$denom } divide(11, 0); # dies! (would return Inf) divide(12, 2); # 6 Matt Follett matt.follett@gmail.com
  • 60. λ Functions • Just as powerful as named functions • Multiple ways to create • A building block of the language Matt Follett matt.follett@gmail.com
  • 61. Basic Form my $add_two_nums = sub (Real $x, Real $y) {$x+$y}; $add_two_nums(11,12); Matt Follett matt.follett@gmail.com
  • 62. Basic Form my $add_two_nums = sub (Real $x, Real $y) {$x+$y}; $add_two_nums(11,12); Matt Follett matt.follett@gmail.com
  • 63. With Twigils my $add_two_nums = sub {$^x+$^y}; $add_two_nums(11,12); Matt Follett matt.follett@gmail.com
  • 64. With Twigils my $add_two_nums = sub {$^x+$^y}; $add_two_nums(11,12); Matt Follett matt.follett@gmail.com
  • 65. With Twigils my $add_two_nums = sub {$^x+$^y}; $add_two_nums(11,12); my $add_two_nums=sub($x,$y){$x+$y} Matt Follett matt.follett@gmail.com
  • 66. λs are Everywhere • All blocks are λs my $add_two_nums = sub {$^x+$^y}; $add_two_nums(11,12); Matt Follett matt.follett@gmail.com
  • 67. λs are Everywhere • All blocks are λs my $add_two_nums = sub {$^x+$^y}; $add_two_nums(11,12); Matt Follett matt.follett@gmail.com
  • 68. λs are Everywhere • All blocks are λs my $add_two_nums = sub {$^x+$^y}; $add_two_nums(11,12); my $add_two_nums = ->$x,$y{$x+$y}; $add_two_nums(11,12); Matt Follett matt.follett@gmail.com
  • 69. λs are Everywhere • All blocks are λs my $add_two_nums = sub {$^x+$^y}; $add_two_nums(11,12); my $add_two_nums = ->$x,$y{$x+$y}; $add_two_nums(11,12); Matt Follett matt.follett@gmail.com
  • 70. λs are Everywhere • All blocks are λs • All blocks benefit for 1..10 -> $x { say $x } Matt Follett matt.follett@gmail.com
  • 71. λs are Everywhere • All blocks are λs • All blocks benefit for 1..10 { say $^x } Matt Follett matt.follett@gmail.com
  • 72. λs are Everywhere • All blocks are λs • All blocks benefit for 1..10 -> $x, $y { say "$x, $y" } Matt Follett matt.follett@gmail.com
  • 73. λs are Everywhere • All blocks are λs • All blocks benefit for 1..11 -> $x, $y='' { say "$x, $y" } Matt Follett matt.follett@gmail.com
  • 74. Simplest Form • Uses the Whatever term • Included in a unary or binary operation • Statement returns a λ • Examples: my $add_two = * + 2; $add_two(3); # 5 my $invoke_method = *.sort; $invoke_method(@some_array); Matt Follett matt.follett@gmail.com
  • 76. Operators • New Operators • Better range operator • Chaining Binary Operators • New Types of Operators  Meta Operators  Junctive Operators • More powerful custom operators Matt Follett matt.follett@gmail.com
  • 77. Range Operator Matt Follett matt.follett@gmail.com
  • 78. Range Operator • Creates lazily evaluated lists: my @N := 0...* Matt Follett matt.follett@gmail.com
  • 79. Range Operator • Creates lazily evaluated lists: my @N := 0...* Matt Follett matt.follett@gmail.com
  • 80. Range Operator • Creates lazily evaluated lists: my @N := 0...* • Basic form is very smart, versatile: my @negatives := -1,-2...* my @multiples_of_two := 0,2,4...* my @powers_of_two := 0,2,4,8...* my @letters = 'a'...'z' Matt Follett matt.follett@gmail.com
  • 81. Range Operator • Creates lazily evaluated lists: my @N := 0...* • Basic form is very smart, versatile: my @negatives := -1,-2...* my @multiples_of_two := 0,2,4...* my @powers_of_two := 0,2,4,8...* my @letters = 'a'...'z' Matt Follett matt.follett@gmail.com
  • 82. Range Operator • Creates lazily evaluated lists: my @N := 0...* • Basic form is very smart, versatile: my @negatives := -1,-2...* my @multiples_of_two := 0,2,4...* my @powers_of_two := 0,2,4,8...* my @letters = 'a'...'z' Matt Follett matt.follett@gmail.com
  • 83. Range Operator • Creates lazily evaluated lists: my @N := 0...* • Basic form is very smart, versatile: my @negatives := -1,-2...* my @multiples_of_two := 0,2,4...* my @powers_of_two := 0,2,4,8...* my @letters = 'a'...'z' Matt Follett matt.follett@gmail.com
  • 84. Range Operator • Creates lazily evaluated lists: my @N := 0...* • Basic form is very smart, versatile: my @negatives := -1,-2...* my @multiples_of_two := 0,2,4...* my @powers_of_two := 0,2,4,8...* my @letters = 'a'...'z' Matt Follett matt.follett@gmail.com
  • 85. Range Operator • Creates lazily evaluated lists: my @N := 0...* • Basic form is very smart, versatile: my @negatives := -1,-2...* my @multiples_of_two := 0,2,4...* my @powers_of_two := 0,2,4,8...* my @letters = 'a'...'z' • Advanced form takes λs for iterator and ending condition: my @fib := 0,1,*+*...* my @double_letters := 'a'...* eq 'zz' Matt Follett matt.follett@gmail.com
  • 86. Range Operator • Creates lazily evaluated lists: my @N := 0...* • Basic form is very smart, versatile: my @negatives := -1,-2...* my @multiples_of_two := 0,2,4...* my @powers_of_two := 0,2,4,8...* my @letters = 'a'...'z' • Advanced form takes λs for iterator and ending condition: my @fib := 0,1,*+*...* my @double_letters := 'a'...* eq 'zz' Matt Follett matt.follett@gmail.com
  • 87. Range Operator • Creates lazily evaluated lists: my @N := 0...* • Basic form is very smart, versatile: my @negatives := -1,-2...* my @multiples_of_two := 0,2,4...* my @powers_of_two := 0,2,4,8...* my @letters = 'a'...'z' • Advanced form takes λs for iterator and ending condition: my @fib := 0,1,*+*...* my @double_letters := 'a'...* eq 'zz' Matt Follett matt.follett@gmail.com
  • 88. Range Operator • Creates lazily evaluated lists: my @N := 0...* • Basic form is very smart, versatile: my @negatives := -1,-2...* my @multiples_of_two := 0,2,4...* my @powers_of_two := 0,2,4,8...* my @letters = 'a'...'z' • Advanced form takes λs for iterator and ending condition: my @fib := 0,1,*+*...* my @double_letters := 'a'...* eq 'zz' Matt Follett matt.follett@gmail.com
  • 89. Range Operator • Creates lazily evaluated lists: my @N := 0...* • Basic form is very smart, versatile: my @negatives := -1,-2...* my @multiples_of_two := 0,2,4...* my @powers_of_two := 0,2,4,8...* my @letters = 'a'...'z' • Advanced form takes λs for iterator and ending condition: my @fib := 0,1,*+*...* my @double_letters := 'a'...* eq 'zz' Matt Follett matt.follett@gmail.com
  • 90. Meta Operators • Meta operators are operators who’s operand is another operator • Simplify writing operators • Provide new strengths  meta reduction operator  cross meta operator  hyperoperator Matt Follett matt.follett@gmail.com
  • 91. Meta Operators Simplifying Operators • Assignment operators A op= B  example: @names .= sort • Negated relational operators  infix relational operators can all be negated by prepending ‘!’  example: $foo !< 11 Matt Follett matt.follett@gmail.com
  • 92. Reduction Meta Operator • Written as [] • Takes a list and reduces it to a scalar value • uses a specified infix operator • like foldl, foldr but respects associativity • Examples: [*] 1..$x [**] 1..$x # 1 ** ( 2 ** ( 3 **…$x ) ) [<] @list or [>] @list Matt Follett matt.follett@gmail.com
  • 93. Reduction Meta Operator • Written as [] • Takes a list and reduces it to a scalar value • uses a specified infix operator • like foldl, foldr but respects associativity • Examples: [*] 1..$x [**] 1..$x # 1 ** ( 2 ** ( 3 **…$x ) ) [<] @list or [>] @list Matt Follett matt.follett@gmail.com
  • 94. Reduction Meta Operator • Written as [] • Takes a list and reduces it to a scalar value • uses a specified infix operator • like foldl, foldr but respects associativity • Examples: [*] 1..$x [**] 1..$x # 1 ** ( 2 ** ( 3 **…$x ) ) [<] @list or [>] @list Matt Follett matt.follett@gmail.com
  • 95. Reduction Meta Operator • Written as [] • Takes a list and reduces it to a scalar value • uses a specified infix operator • like foldl, foldr but respects associativity • Examples: [*] 1..$x [**] 1..$x # 1 ** ( 2 ** ( 3 **…$x ) ) [<] @list or [>] @list Matt Follett matt.follett@gmail.com
  • 96. Hyper Meta Operator • Written as Unicode ‘»’, ‘«‘ or ASCII ‘>>’, ‘<<‘ • Performs the operations as fast as possible • Can parallelize these operations • Does not guarantee order of results • Examples: (1..10) >>+<< (21..30); my @nums_squared = @nums >>**>> 2; my @hellos = "Hello, " <<~<< <Christian John Michael Eleanor Chris>; @hellos>>.say; Matt Follett matt.follett@gmail.com
  • 97. Hyper Meta Operator • Written as Unicode ‘»’, ‘«‘ or ASCII ‘>>’, ‘<<‘ • Performs the operations as fast as possible • Can parallelize these operations • Does not guarantee order of results • Examples: (1..10) >>+<< (21..30); my @nums_squared = @nums >>**>> 2; my @hellos = "Hello, " <<~<< <Christian John Michael Eleanor Chris>; @hellos>>.say; Matt Follett matt.follett@gmail.com
  • 98. Hyper Meta Operator • Written as Unicode ‘»’, ‘«‘ or ASCII ‘>>’, ‘<<‘ • Performs the operations as fast as possible • Can parallelize these operations • Does not guarantee order of results • Examples: (1..10) >>+<< (21..30); my @nums_squared = @nums >>**>> 2; my @hellos = "Hello, " <<~<< <Christian John Michael Eleanor Chris>; @hellos>>.say; Matt Follett matt.follett@gmail.com
  • 99. Hyper Meta Operator • Written as Unicode ‘»’, ‘«‘ or ASCII ‘>>’, ‘<<‘ • Performs the operations as fast as possible • Can parallelize these operations • Does not guarantee order of results • Examples: (1..10) >>+<< (21..30); my @nums_squared = @nums >>**>> 2; my @hellos = "Hello, " <<~<< <Christian John Michael Eleanor Chris>; @hellos>>.say; Matt Follett matt.follett@gmail.com
  • 100. Hyper Meta Operator • Written as Unicode ‘»’, ‘«‘ or ASCII ‘>>’, ‘<<‘ • Performs the operations as fast as possible • Can parallelize these operations • Does not guarantee order of results • Examples: (1..10) >>+<< (21..30); my @nums_squared = @nums >>**>> 2; my @hellos = "Hello, " <<~<< <Christian John Michael Eleanor Chris>; @hellos>>.say; Matt Follett matt.follett@gmail.com
  • 101. Cross Meta Operator • Written as ‘X’ • Crosses two arrays, making tuples of each cell then applying the operator to them • examples: (1,2) X* (3,4); Matt Follett matt.follett@gmail.com
  • 102. Cross Meta Operator • Written as ‘X’ • Crosses two arrays, making tuples of each cell then applying the operator to them • examples: (1,2) X* (3,4);#((1,3),(1,4)(2,3),(2,4)) Matt Follett matt.follett@gmail.com
  • 103. Cross Meta Operator • Written as ‘X’ • Crosses two arrays, making tuples of each cell then applying the operator to them • examples: (1,2) X* (3,4);#((1*3),(1*4)(2*3),(2*4)) Matt Follett matt.follett@gmail.com
  • 104. Cross Meta Operator • Written as ‘X’ • Crosses two arrays, making tuples of each cell then applying the operator to them • examples: (1,2) X* (3,4);#(3,4,6,8) Matt Follett matt.follett@gmail.com
  • 105. Cross Meta Operator • Written as ‘X’ • Crosses two arrays, making tuples of each cell then applying the operator to them • examples: (1,2) X* (3,4);#(3,4,6,8) < > X~ ('A',2..10,'J','Q','K'); Matt Follett matt.follett@gmail.com
  • 106. Junctive Operators • A variable can be any of some number of values via ‘|’ • A variable can be all of some number of values via ‘&’ my $superposition = 4 | 5 | 6; $superposition += 1; # 5|6|7 6 ~~ $superposition; #true 9 ~~ $superposition; #false my $qualifications = *.can('sort') & *.can('push') & *.can('pop'); @array ~~ $qualifications; # true $scalar ~~ $qualifications; # false Matt Follett matt.follett@gmail.com
  • 107. Junctive Operators • A variable can be any of some number of values via ‘|’ • A variable can be all of some number of values via ‘&’ my $superposition = 4 | 5 | 6; $superposition += 1; # 5|6|7 6 ~~ $superposition; #true 9 ~~ $superposition; #false my $qualifications = *.can('sort') & *.can('push') & *.can('pop'); @array ~~ $qualifications; # true $scalar ~~ $qualifications; # false Matt Follett matt.follett@gmail.com
  • 108. Junctive Operators • A variable can be any of some number of values via ‘|’ • A variable can be all of some number of values via ‘&’ my $superposition = 4 | 5 | 6; $superposition += 1; # 5|6|7 6 ~~ $superposition; #true 9 ~~ $superposition; #false my $qualifications = *.can('sort') & *.can('push') & *.can('pop'); @array ~~ $qualifications; # true $scalar ~~ $qualifications; # false Matt Follett matt.follett@gmail.com
  • 109. Junctive Operators • A variable can be any of some number of values via ‘|’ • A variable can be all of some number of values via ‘&’ my $superposition = 4 | 5 | 6; $superposition += 1; # 5|6|7 6 ~~ $superposition; #true 9 ~~ $superposition; #false my $qualifications = *.can('sort') & *.can('push') & *.can('pop'); @array ~~ $qualifications; # true $scalar ~~ $qualifications; # false Matt Follett matt.follett@gmail.com
  • 110. Junctive Operators • A variable can be any of some number of values via ‘|’ • A variable can be all of some number of values via ‘&’ my $superposition = 4 | 5 | 6; $superposition += 1; # 5|6|7 6 ~~ $superposition; #true 9 ~~ $superposition; #false my $qualifications = *.can('sort') & *.can('push') & *.can('pop'); @array ~~ $qualifications; # true $scalar ~~ $qualifications; # false Matt Follett matt.follett@gmail.com
  • 111. Junctive Operators • A variable can be any of some number of values via ‘|’ • A variable can be all of some number of values via ‘&’ my $superposition = 4 | 5 | 6; $superposition += 1; # 5|6|7 6 ~~ $superposition; #true 9 ~~ $superposition; #false my $qualifications = *.can('sort') & *.can('push') & *.can('pop'); @array ~~ $qualifications; # true $scalar ~~ $qualifications; # false Matt Follett matt.follett@gmail.com
  • 112. Custom Operators • Any unicode string • Define precedence  ‘is tighter’ - higher precedence than the given operator  ‘is looser’ - lower precedence  ‘is equiv’ - same precedence • Many types  infix  postfix  prefix  circumfix  postcircumfix Matt Follett matt.follett@gmail.com
  • 113. Custom Operator Example sub infix:<⊕> ($a, $b) is tighter(&infix:<*>) { sqrt($a**2+$b**2); }; say 2 ⊕ 4; Matt Follett matt.follett@gmail.com
  • 114. Custom Operator Example sub infix:<⊕> ($a, $b) is tighter(&infix:<*>) { sqrt($a**2+$b**2); }; say 2 ⊕ 4; Matt Follett matt.follett@gmail.com
  • 115. Grammars • Composed of rules and tokens • Reusable through inheritance • Defined like classes or modules • starts from the TOP rule Matt Follett matt.follett@gmail.com
  • 116. grammar Mercurial::rc { rule TOP {^<line>*$}; rule line {<header>|<assignment>|<comment>}; rule header {'[' ~ ']' <header_name> }; rule assignment {<variable>'='<value>}; rule comment { '#' <message> }; token header_name {w<-[]]>+}; token variable {<-[=]>+}; token value {.*}; token message {.*}; } Matt Follett matt.follett@gmail.com
  • 117. [ui] username=Matt Follett email=matt.follett@gmail.com [extensions] #best extension ever! hg.cowlog= Matt Follett matt.follett@gmail.com
  • 118. Where to go for more • Try Rakudo: http://try.rakudo.org • Using Perl 6: http://github.com/perl6/book/downloads • Get Rakudo: http://rakudo.org/how-to-get-rakudo • The official Perl 6 site: http://www.perl6.org • Perl 6 synopses: http://perlcabal.org/syn/ • Planet Perl 6: http://planetsix.perl.org/ • Rosetta Code: http://www.rosettacode.org • My posts: http://mfollett.com/tag/perl6 Matt Follett matt.follett@gmail.com