On Fri, Aug 13, 2004 at 02:21:30PM -0400, Matt Diephouse wrote: : All this talk of blocks and Ruby (and A12 Lookahead Notions) brings up : an important question in my mind: how will Perl 6 handle multiple : blocks? When using Ruby, I found blocks both easy and pretty. But I : found writing a method with multiple blocks to be both less easy and : less pretty.
Yes, that's precisely why I'm trying to generalize Ruby's single "magic" block into one or more ordinary parameters. : >From what I understand, something like this will be possible (but will : it need parens?): : : @array.each :odd{ $^odd.bar() } :even{ $^even.baz() }; No parens necessary there. But parens are necessary if you want to pass any non-adverbial arguments to a method. On the other hand, since adverbs are just named parameters you can also write that: @array.each( :odd{ $^odd.bar() } :even{ $^even.baz() } ); or equivalently @array.each( 'odd' => { $^odd.bar() }, 'even' => { $^even.baz() } ); : But what about this? : : @array.each:{$^odd.bar() }:{ $^even.baz() }; : : Admittedly it's a much smaller case, but it should be useful, even if : I can't think of a non trivial case offhand. Two anonymous adverbs? Hmm. While I can think of ways to force it to work, I'm inclined to disallow it simply because it'd make another arbitrary rule we'd have to explain. You know, at some point you just break down and write them positionally: @array.each( { $^odd.bar() }, { $^even.baz() }); On the other hand, the parser will have to deal with multi-block structures all the time, so perhaps something could be modelled on how we eventually handle if/elsif/else, presuming we actually declare those as macros, and not strictly as grammar rules. Larry