On Mon, Mar 08, 2010 at 12:45:44PM -0800, Little Walker wrote:
: Hi there,
: 
: I've been looking around to see if there's been any discussion of
: introducing functional programming-style pattern matching for method/
: function dispatch.  Could someone point me to any such discussions?

Why settle for discussion when you can have specs?  See the
Parameters and Arguments section of:

    http://perlcabal.org/syn/S06.html

: I've seen that perl6 is taking on a lot of ideas from the functional
: world (lazy evaluation for instance).  With multi-method dispatch on
: the agenda pattern matching seems inevitable but I haven't been able
: to find information about this or any related discussions.
: 
: This is a contrived example of what I'm referring to:
: 
: sub traverse([Leaf $a]) {
:   # do something
: }
: 
: sub traverse([Tree $left, Tree $right]) {
:   traverse($left);
:   traverse($right);
: }
: 
: my $t = Tree(...);
: traverse($t);

That's almost exactly the example from:

    http://perlcabal.org/syn/S06.html#Unpacking_tree_node_parameters

In fact, a grep of the specs for any of 'Tree', 'traverse', or
even 'left.*right' would have found it.

If any of you wants a greppable version of the specs, use svn to checkout

    http://svn.pugscode.org/pugs

and then look in docs/Perl6/Spec.

Larry

Reply via email to