Wednesday, July 25, 2007

OSCON: Perl 6 Update

I'm in the Perl 6 Update given by Larry Wall and Damian Conway in absentia. There was a lot of material in this talk, as always, so this is a high-lights and low-lights summary only, mostly of the bits and pieces I managed to write down in time before Larry flipped the slides away...

Class and module names can now have adverbial modifiers allowing you to put author (naming authority) and version numbers into the class. Also introduced inline comments, if you follow the # symbol with a bracket, then the comment only goes to the end of the matching bracket.

No more defaulting to $_. Built-in functions no longer default to $_ by, well, default,

#Perl 5
for ( @data ) {

# Perl 6
for( @data ) {

The file test operators -r -w -x are gone from Perl 6 and have been replaced by something that look a lot like this,

if $file ~~ :r { 
say 'we can read the file';

if $file.:w {
when :r | :w | :x { say "r,w,x" }
when "w & :!±r { day "write-only" }

All global variables now have a star, e.g. @*ARGS, which by-the-by is the replacement for @ARGV...

There is a new loop type,

repeat {
print "Name: ";
$name ==<>;
} while $name !~~/\S/

repeat while $name !~~ /\S/ {
print "Name: ";
$name ==<>;

which fixes the "mess I made of Perl 5 do/while loops" according to Larry.

One of (many) interesting regexp fixes in Perl 6 is match boundaries, which are being added to Perl 5.10 but with far worse syntax,

/ bar < before baz>/
//foo <(bar)> baz/

You can now define fixed size arrays, if you really want to,

my @calendar[12]; # indices are 0..11 only

and it'll give you error if you go outside the range.

It looks like there are lots of new semantic features added into POD, like tables, and a much better implementation of nested lists and link syntax. Can also use DIY mark-up, and add parser and translator support for new block types.

...and we're done.

Update: Both Brad and Chris were covering this session.