. .

YAPC::EU 2010 - The Renaissance of Perl

 

Follow


Perl 6 Signatures: The Full Story

By Jonathan Worthington (‎jnthn‎) from Bratislava.pm
Date: Thursday, 5 August 2010 12:00
Duration: 50 minutes
Target audience: Intermediate
Language: English
Tags: 6 algorithms functional rakudo signatures


A lot of my work in Rakudo over the last year has focused on Perl 6 signatures. At first glance, they seem like a nicer way to get hold of your parameters than manually unpacking @_. Digging deeper, though, they're much, much richer than that: in fact, they're first class, introspectable objects with plenty of applications.

In this talk, we'll start from the basics of writing signatures involving positional, optional, named and slurpy parameters. We'll then take a look at using types, coercions and constraints in order to validate or munge the data that is being passed.

With the preliminaries covered, we'll then dig into nested signatures, which allow us to perform functional programming style pattern matching against complex data structures with the same familiar signature syntax we've already covered. I'll demonstrate how combining this with multiple dispatch allows us to implement several algorithms in the "write what you know and...oh gosh, I have a working program" style.

Finally, we'll take signatures away from the context we've got used to seeing them in - on a sub or method - and see how they can be used to unpack data structures or function return values anywhere else in your program, and used in a given/when construct to branch based on the shape of a complex data structure.

Attended by:

Our sponsors

Platinum

  • Booking.Com
  • YAPC::Europe 2009
  • cPanel

Gold

  • Shadowcat
  • 123 people
  • Venda
  • Dada

Silver

  • YAPC::Europe Foundation
  • Smart Open Software
  • MySQL
  • Exonetric
  • pair Networks

Supporters

  • GitHub
  • Italpro
  • Geoesse
  • $foo Perl Magazin
  • Lokku
  • Apress
  • No Starch Press
  • O'Reilly Media
  • NET-A-PORTER

Media Partners

  • Linux Magazine

Patronage

  • Regione Toscana
  • Comune di Pisa