. .

YAPC::EU 2010 - The Renaissance of Perl



Perl 6 Signatures: The Full Story

Perl 6 Signatures: The Full Story

By Jonathan Worthington (‎jnthn‎) from Prague.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: Sébastien Aperghis-Tramoni (‎Maddingue‎), Nicholas Clark, Stefano Rodighiero (‎larsen‎), Bernhard Schmalhofer (‎bernhard‎), Aldo Calpini (‎dada‎), Léon Brocard (‎acme‎), Gabor Szabo (‎szabgab‎), Dagfinn Ilmari Mannsåker (‎ilmari‎), Martin Vorländer (‎mvorl‎), Smylers, Paul van Eldijk (‎pavel‎), Tina Müller (‎tinita‎), Karl Rune Nilsen (‎krunen‎), Bálint Szilakszi (‎szbalint‎), Carl Mäsak (‎masak‎), Markus Pinkert (‎Bedivere‎), Sam Vilain (‎mugwump‎), Roman Baumer (‎rba‎), Tim Bunce, Olivier Mengué (‎dolmen‎), Jonathan Worthington (‎jnthn‎), Jörg Plate (‎Patterner‎), Florian Ragwitz (‎rafl‎), Damian Conway (‎damian‎), Erik Johansen (‎uniejo‎), Henrik Andersen (‎HEM‎), Aristotle, Dave Rolsky (‎autarch‎), Patrick Michaud (‎Pm‎), Lars Holgaard, Andrew Shitov (‎ash‎), Clinton Gormley (‎DrTech‎), Ronald Blaschke (‎rblasch‎), Steffen Schwigon (‎renormalist‎), David Faux, David Leadbeater (‎dg‎), Mark Morgan, Herbert Breunung (‎lichtkind‎), Adde Nilsson, Francesco Rivetti (‎oha‎), lorenzo, valerio crini, Martin Berends (‎mberends‎), Leon Timmermans (‎leont‎), Markus Wichmann (‎telemorphix‎), Alan Haggai Alavi (‎alanhaggai‎), simotrone, Moritz Lenz (‎moritz‎), Andreas Vögele, Sawyer X, Zefram .,

Our sponsors


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


  • Shadowcat
  • 123 people
  • Venda
  • Dada


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


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

Media Partners

  • Linux Magazine


  • Regione Toscana
  • Comune di Pisa