Perl 6 Signatures: The Full Story

Perl 6 Signatures: The Full Story

Par Jonathan Worthington (‎jnthn‎)
Date : dimanche 10 octobre 2010 15h30
Durée : 40 minutes
Langue : English
Tags : algorithms functional perl6 rakudo signatures


At first glance, signatures in Perl 6 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.


Présentation suivie par: Alexandre Jousset (‎Mid'‎), Adrien Kunysz (‎Krunch‎), Franck Cuny, Jérôme Fenal, Philippe Bruhat (‎BooK‎), Arnaud Berthomier (‎oz‎), Pierre Chapuis (‎catwell‎), Jean Forget, Stéphane Payrard (‎cognominal‎), François Perrad (‎fperrad‎),