Re: Functional-style pattern matching

2010-03-11 Thread Moritz Lenz
Mark J. Reed wrote: Oh, wow. I was just asking about the spec; didn't know this stuff already worked. Rakudos to the team! :) Actually there's quite much that works in Rakudo, even if some corner cases are missing or error messages might benefit from more verbosity. Especially in the area of

Re: Functional-style pattern matching

2010-03-10 Thread Moritz Lenz
Hi, Little Walker wrote: 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? It's done multi dispatch in Perl 6, and you can find an

Re: Functional-style pattern matching

2010-03-10 Thread Little Walker
That's almost exactly the example from:    http://perlcabal.org/syn/S06.html#Unpacking_tree_node_parameters 1. I feel incredibly embarrassed to have missed this 2. This is awesome!

Re: Functional-style pattern matching

2010-03-10 Thread Little Walker
Which is pretty powerful, really. Absolutely - I think you're referring to the 'type subset' stuff which is great. This is where Perl 6 is not the same as functional languages, since it's got an imperative OO element as well. True, there can be friction between the functional style and OO,

Re: Functional-style pattern matching

2010-03-10 Thread Mark J. Reed
Does the unpacking participate in dispatch? If a Hash comes in as $t with no 'left' key, will it fail to match? On Tuesday, March 9, 2010, Little Walker en...@dircon.co.uk wrote: Which is pretty powerful, really. Absolutely - I think you're referring to the 'type subset' stuff which is

Re: Functional-style pattern matching

2010-03-10 Thread Carl Mäsak
Mark (): Does the unpacking participate in dispatch?  If a Hash comes in as $t with no 'left' key, will it fail to match? Yes. $ perl6 -e 'sub foo(%h($left)) { say $left }; foo({ left = OH HAI })' OH HAI $ perl6 -e 'sub foo(%h($left)) {}; foo({ no = left key })' Not enough positional

Re: Functional-style pattern matching

2010-03-10 Thread Mark J. Reed
Oh, wow. I was just asking about the spec; didn't know this stuff already worked. Rakudos to the team! :) On Wed, Mar 10, 2010 at 9:18 AM, Carl Mäsak cma...@gmail.com wrote: Mark (): Does the unpacking participate in dispatch?  If a Hash comes in as $t with no 'left' key, will it fail to

Re: Functional-style pattern matching

2010-03-09 Thread Matthew Walton
I think the closest things we've got to pattern matching come from a combination of multiple dispatch, where clauses and signature unpacking. I don't know much about the latter, but a where clause can discriminate multiple dispatch variants based on parameter values rather than just the type, so

Re: Functional-style pattern matching

2010-03-09 Thread Larry Wall
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

Re: Functional-style pattern matching

2010-03-09 Thread Daniel Ruoso
Em Seg, 2010-03-08 às 12:45 -0800, Little Walker escreveu: 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? a Tree matching language is on

Re: Functional-style pattern matching

2010-03-09 Thread Timothy S. Nelson
On Tue, 9 Mar 2010, Daniel Ruoso wrote: Em Seg, 2010-03-08 às 12:45 -0800, Little Walker escreveu: 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