SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
In this talk I introduce Perl 6 and some of its exciting new features, especially gradual typing, roles and some functional programming features like lazy lists.
This talk was given at the Scottish Programming Languages Seminar on 24th Feb 2016 at the School of Computing Science of Glasgow University.
In this talk I introduce Perl 6 and some of its exciting new features, especially gradual typing, roles and some functional programming features like lazy lists.
This talk was given at the Scottish Programming Languages Seminar on 24th Feb 2016 at the School of Computing Science of Glasgow University.
5.
• Perl6/Pugs invited talk at POPL 2007
• Audrey Tang had created Pugs, a Perl 6
implementa6on in Haskell
• Perl 6 was promised for "Christmas”
• And there was some delay …
19.
Parsing
• Perl 6 has Grammars, Rules, Tokens and Regexes as
part of the language
• Similar to classes but used to organize parsers
• Rules are lexeme parsers
• Tokens are token parsers
• Regexes are PCREs
• Perl 6 is parsed and executed using a Perl 6-style
grammar.
24.
Perl 6 Objects
• Accessors for free
• Default constructor
• Inheritance
• Roles (mixins)
• Built on a Meta Object Protocol
• Full introspec6on
• So s6ll nothing special …
29.
Gradual typing
• By default variables are dynamically typed.
• Explicitly typed variables are sta6cally typed.
• But type checks can be deferred to run 6me.
• Underlying theory:
hZps://github.com/samth/gradual-typing-bib
30.
Gradual typing: subsets
• Type constraint checked at run 6me
31.
Gradual typing: type capture
• Defer the specifica6on of a type constraint to the
6me the func6on is called.
• Allows to refer to a type both in the signature and
the func6on body.
32.
Gradual typing: type capture
• Defer the specifica6on of a type constraint to the
6me the func6on is called.
• Allows to refer to a type both in the signature and
the func6on body.
34.
Roles
• Basis for the Perl 6 type system
• Used for composi6on and mixins
• In Perl 6, the “funny characters” are syntax for a set
of predefined roles:
@: Posi6onal (array)
%: Associa6ve (hash)
&: Callable (subrou6ne)
• So …
35.
No more funny characters!
• Actually, the “funny characters” are now op6onal:
36.
Polymorphic func6ons
• Also known as mul6ple dispatch
37.
Polymorphic func6ons
• Also known as mul6ple dispatch
43.
Type capture revisited
• Type capture also works with closures and lambdas
44.
Lazy lists
• Perl 6 dis6nguishes between sequences, lists and
arrays.
• Sequences are immutable, but are consumed
when iterated.
• Lists are immutable
• Arrays are mutable
• By defaults Seq, List and Array are lazy, but can be
made eager.