July 2009, DFW.p6m

Today we had another P6M meeting. There were seven of us despite the fact that three of the regulars were gone at a birthday party, so that was fairly heartening.

As you may already know from the Iron Man Feed, s1n did a talk on .WALK, which is a selector based system for introspecting the methods of a class. One really interesting thing about it is that it (apparently?) isn’t actually for dealing with inherited/overridden methods as much as it is for manually tweaking the multiple dispatch that Perl 6 supports.

Just to be clear, multiple dispatch is how Perl 6 chooses what method to run based on the parameters (and invocant) of a method. So you can do something like this:

class Frew {
   method foo($self: Int $foo, Str $bar) { ... }
   method foo($self: Str $baz) { ... }
}

And when you call the method it will call the right one based on the params passed to the method. You can even dispatch based on the value of the parameter.

Cool stuff!

Posted Wed, Jul 15, 2009