[Perth-pm] Report from last night's gathering.

James Bromberger james at rcpt.to
Wed Jan 5 19:20:42 PST 2011


Hello Perl Mongers,

Firstly, we had yum beers last night and /des frites/. Ahhh!

The next two pubs have been chosen - Nick selected The Moon & Six Pence
for February, and I've plucked out The Lucky Shag at Barrack Street
Jerry for March; see the http://perth.pm.org/ site for the calendar
(unless you've already imported it into your own calendaring software).
I'd like to get the next pub afte that chosen too - suggestions?
Preferably with good transport (parking, rail) and reasonably central
across the metro area.



So last night we read up on the Perl 5 to Perl 6 doco, and with the help
of Parrot and Radoku Star, tried the examples out and varied them a bit
to see what's new. It was good; exceptions happen and are caught -
mostly. We ended up filing one possible bug (#81682) for using strict
types and Container aliasing (like Perl 5 references) that isn't
handled. We only managed to get around 20 pages of the document read,
understood, and played with - there's plenty more in there.

My favourites was probably "multi sub"s - define a subroutine with
different argument lists and/or types, and the Right One will be used.
For example, if you define:

    multi sub add(Int $a, Int $b) { return $a + $b }
    multi sub add(Str %a, Str $b) { return $a ~ $b }

Then calling add(5, 4) will give 9, and add("5", "4") will give "54".
Likewise, instead of using the pre-baked types (Int, Str, Rat
(rational/float), etc) you can also put your own types in:

    multi sub add_friend(Person $a, Person $b) {  say "$a and $b are now
    friends" }


We played with the object class (we made a class called "Beer"), and
inheritance from a super class ("Drink"), and multiple inheritance
("Vegetable"); we played with read only variables in classes (only can
be set at instantiation), and with private variables. Defining a
variable appears to make the variable accessible by name as a method call:

    class Beer {
      has $.name
      has $.retail_price
      has $!cost_price
    }
    my $drink = Beer.new( name => 'Leffe', retail_price => 6, cost_price
    => 3);
    say "This drink is a $drink.WHAT called $drink.name";

If we try and access $drink.cost_price we get an exception. This
contradicts the Perl5 reason for private variables; as Larry Wall said
way back then (1999 or so):

    /Perl doesn't have an infatuation with enforced privacy. It would
    prefer that you stayed out of its living room because you weren't
    invited, not because it has a shotgun/


Brackets around if() clauses are gone, arrays and hashes retain the same
sigil (symbol) when accessing an element (@array[1] = "foo", not
$array[1]), everything is an object (eg, $drink.WHAT as shown above,
@array.sort), plus lots more we have yet to play with. For more info,
see http://perl6.org/.



So, a rather good Perl night. Can I get a volunteer to present for next
month at all??? :)


  James
PS: We found that unicode 00BD (0189, "one half", ½) when multiplied by
2, does not equal 1. But I added that as a /PS/ to the bug report
above... :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/perth-pm/attachments/20110106/33bce6a5/attachment.html>


More information about the Perth-pm mailing list